From 0ab6485a5617fb56c84deac8fc36272ab81e75a0 Mon Sep 17 00:00:00 2001 From: tianshangfei <31125751+tianshangfei@users.noreply.github.com> Date: Sun, 18 Dec 2022 16:16:53 +0800 Subject: [PATCH] two platforms supporting S3IP SYSFS (TCS8400, TCS9400) (#12386) Why I did it Add two platform that support s3IP framework How I did it Add two platforms supporting S3IP SYSFS (TCS8400, TCS9400) How to verify it Manual test --- .../TCS8400-24CC8CD/TCS8400-24CC8CD.yml | 574 +++ .../TCS8400-24CC8CD/port_config.ini | 33 + .../TCS8400-24CC8CD/sai.profile | 1 + .../config_db.TCS8400-24CC8CD.json | 268 ++ .../x86_64-tencent_tcs8400-r0/cpu.cint | 85 + .../x86_64-tencent_tcs8400-r0/custom_led.bin | Bin 0 -> 700 bytes .../x86_64-tencent_tcs8400-r0/default_sku | 1 + .../tencent/x86_64-tencent_tcs8400-r0/dev.xml | 349 ++ .../x86_64-tencent_tcs8400-r0/dev_0x407b.xml | 349 ++ .../tencent/x86_64-tencent_tcs8400-r0/fru.py | 953 ++++ .../x86_64-tencent_tcs8400-r0/installer.conf | 1 + .../led_proc_init.soc | 6 + .../x86_64-tencent_tcs8400-r0/monitor.py | 431 ++ .../x86_64-tencent_tcs8400-r0/platform_asic | 1 + .../platform_env.conf | 2 + .../x86_64-tencent_tcs8400-r0/prbs.cint | 17 + .../TCS9400-128CC/TCS9400-128CC.yml | 1783 +++++++ .../TCS9400-128CC/port_config.ini | 128 + .../TCS9400-128CC/sai.profile | 1 + .../config_db.TCS9400-128CC.json | 1028 ++++ .../x86_64-tencent_tcs9400-r0/custom_led.bin | Bin 0 -> 636 bytes .../x86_64-tencent_tcs9400-r0/default_sku | 1 + .../tencent/x86_64-tencent_tcs9400-r0/dev.xml | 572 +++ .../x86_64-tencent_tcs9400-r0/dev_0x407c.xml | 572 +++ .../tencent/x86_64-tencent_tcs9400-r0/fru.py | 953 ++++ .../x86_64-tencent_tcs9400-r0/installer.conf | 1 + .../led_proc_init.soc | 6 + .../x86_64-tencent_tcs9400-r0/monitor.py | 431 ++ .../x86_64-tencent_tcs9400-r0/platform_asic | 1 + .../platform_env.conf | 2 + platform/broadcom/one-image.mk | 4 +- .../broadcom/platform-modules-tencent.dep | 8 + platform/broadcom/platform-modules-tencent.mk | 18 + platform/broadcom/rules.mk | 1 + .../sonic-platform-modules-tencent/LICENSE | 15 + .../common/Makefile | 37 + .../common/lib/algorithm/__init__.py | 0 .../common/lib/algorithm/hysteresis.py | 167 + .../common/lib/algorithm/openloop.py | 104 + .../common/lib/algorithm/pid.py | 106 + .../common/lib/eepromutil/__init__.py | 0 .../common/lib/eepromutil/fru.py | 953 ++++ .../common/lib/eepromutil/onietlv.py | 449 ++ .../common/lib/plat_hal/__init__.py | 0 .../common/lib/plat_hal/baseutil.py | 141 + .../common/lib/plat_hal/chassisbase.py | 322 ++ .../common/lib/plat_hal/component.py | 33 + .../common/lib/plat_hal/cpld.py | 63 + .../common/lib/plat_hal/cpu.py | 36 + .../common/lib/plat_hal/dcdc.py | 11 + .../common/lib/plat_hal/devicebase.py | 223 + .../common/lib/plat_hal/fan.py | 381 ++ .../common/lib/plat_hal/interface.py | 1331 ++++++ .../common/lib/plat_hal/led.py | 54 + .../common/lib/plat_hal/onie_e2.py | 127 + .../common/lib/plat_hal/osutil.py | 401 ++ .../common/lib/plat_hal/psu.py | 620 +++ .../common/lib/plat_hal/rotor.py | 156 + .../common/lib/plat_hal/sensor.py | 220 + .../common/lib/plat_hal/temp.py | 138 + .../common/lib/rjutil/__init__.py | 0 .../common/lib/rjutil/baseutil.py | 39 + .../common/lib/rjutil/smbus.py | 777 +++ .../kernel_drivers_blacklist.conf | 2 + .../common/modules/Makefile | 50 + .../common/modules/dfd_tlveeprom.c | 516 ++ .../common/modules/dfd_tlveeprom.h | 121 + .../common/modules/fpga_i2c.h | 129 + .../common/modules/rg_csu550.c | 203 + .../common/modules/rg_eeprom_93xx46.c | 555 +++ .../common/modules/rg_fpga_i2c_bus_drv.c | 1106 +++++ .../common/modules/rg_fpga_pca954x_drv.c | 531 +++ .../common/modules/rg_fpga_pcie.c | 167 + .../common/modules/rg_gpio_d1500.c | 367 ++ .../common/modules/rg_gpio_device.c | 54 + .../common/modules/rg_i2c_dev.c | 777 +++ .../common/modules/rg_i2c_dev.h | 18 + .../common/modules/rg_i2c_gpio_device.c | 110 + .../common/modules/rg_ina3221.c | 445 ++ .../common/modules/rg_io_dev.c | 574 +++ .../common/modules/rg_io_dev.h | 19 + .../common/modules/rg_lpc_drv.c | 169 + .../common/modules/rg_lpc_drv.h | 18 + .../common/modules/rg_mac_bsc.c | 658 +++ .../common/modules/rg_optoe.c | 1190 +++++ .../common/modules/rg_pcie_dev.c | 773 +++ .../common/modules/rg_pcie_dev.h | 23 + .../common/modules/rg_plat_sysfs/Makefile | 20 + .../modules/rg_plat_sysfs/rg_dev_cfg/Makefile | 31 + .../rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg.c | 815 ++++ .../rg_dev_cfg/cfg/dfd_cfg_adapter.c | 354 ++ .../rg_dev_cfg/cfg/dfd_cfg_file.c | 239 + .../rg_dev_cfg/cfg/dfd_cfg_info.c | 590 +++ .../rg_dev_cfg/cfg/dfd_cfg_listnode.c | 85 + .../rg_dev_cfg/cfg/dfd_frueeprom.c | 496 ++ .../rg_dev_cfg/cfg/dfd_tlveeprom.c | 474 ++ .../rg_dev_cfg/dfd_cpld_driver.c | 117 + .../rg_plat_sysfs/rg_dev_cfg/dfd_fan_driver.c | 487 ++ .../rg_plat_sysfs/rg_dev_cfg/dfd_led_driver.c | 86 + .../rg_plat_sysfs/rg_dev_cfg/dfd_module.c | 134 + .../rg_plat_sysfs/rg_dev_cfg/dfd_psu_driver.c | 206 + .../rg_dev_cfg/dfd_sensors_driver.c | 178 + .../rg_plat_sysfs/rg_dev_cfg/dfd_sff_driver.c | 199 + .../rg_plat_sysfs/rg_dev_cfg/dfd_sfpbase.c | 986 ++++ .../rg_dev_cfg/dfd_slot_driver.c | 81 + .../rg_dev_cfg/dfd_syseeprom_driver.c | 59 + .../rg_dev_cfg/include/dfd_cfg.h | 113 + .../rg_dev_cfg/include/dfd_cfg_adapter.h | 46 + .../rg_dev_cfg/include/dfd_cfg_file.h | 37 + .../rg_dev_cfg/include/dfd_cfg_info.h | 109 + .../rg_dev_cfg/include/dfd_cfg_listnode.h | 30 + .../rg_dev_cfg/include/dfd_cpld_driver.h | 14 + .../rg_dev_cfg/include/dfd_fan_driver.h | 32 + .../rg_dev_cfg/include/dfd_frueeprom.h | 67 + .../rg_dev_cfg/include/dfd_led_driver.h | 6 + .../rg_dev_cfg/include/dfd_module.h | 148 + .../rg_dev_cfg/include/dfd_psu_driver.h | 14 + .../rg_dev_cfg/include/dfd_sensors_driver.h | 12 + .../rg_dev_cfg/include/dfd_sff_driver.h | 18 + .../rg_dev_cfg/include/dfd_sfpparse.h | 558 +++ .../rg_dev_cfg/include/dfd_slot_driver.h | 10 + .../rg_dev_cfg/include/dfd_syseeprom_driver.h | 6 + .../rg_dev_cfg/include/dfd_tlveeprom.h | 70 + .../rg_plat_sysfs/rg_dev_sysfs/Makefile | 20 + .../rg_dev_sysfs/include/rg_plat_switch.h | 86 + .../rg_dev_sysfs/include/rg_sysfs_common.h | 194 + .../rg_plat_sysfs/rg_dev_sysfs/rg_plat_fan.c | 544 +++ .../rg_plat_sysfs/rg_dev_sysfs/rg_plat_psu.c | 458 ++ .../rg_dev_sysfs/rg_plat_sensor.c | 494 ++ .../rg_plat_sysfs/rg_dev_sysfs/rg_plat_sff.c | 391 ++ .../rg_dev_sysfs/rg_plat_switch.c | 141 + .../common/modules/rg_pmbus.h | 466 ++ .../common/modules/rg_pmbus_core.c | 2570 ++++++++++ .../common/modules/rg_spi_93xx46.c | 111 + .../common/modules/rg_spi_gpio.c | 477 ++ .../common/modules/rg_spi_gpio_device.c | 150 + .../common/modules/rg_tps53622.c | 120 + .../common/modules/rg_ucd9000.c | 294 ++ .../common/modules/rg_wdt.c | 1041 ++++ .../common/modules/rg_wdt.h | 46 + .../common/modules/rg_xdpe132g5c.c | 574 +++ .../common/modules/ruijie.h | 71 + .../common/modules/ruijie_common_module.c | 210 + .../common/modules/spi-bitbang-txrx.h | 107 + .../common/script/dev_monitor.py | 345 ++ .../common/script/hal_fanctrl.py | 1012 ++++ .../common/script/hal_ledctrl.py | 792 +++ .../common/script/platform_intf.py | 252 + .../common/script/platform_manufacturer.py | 609 +++ .../common/script/platform_sensors.py | 262 + .../common/script/platform_util.py | 539 +++ .../common/script/rg_platform_driver.py | 244 + .../common/script/rg_platform_process.py | 227 + .../common/script/rg_pmon_syslog.py | 518 ++ .../common/script/ruijiecommon.py | 43 + .../common/script/ruijieconfig.py | 86 + .../common/script/ruijieutil.py | 72 + .../common/script/sensors | 8 + .../common/script/sfp_highest_temperatue.py | 150 + .../common/script/xdpe_avscontrol.py | 217 + .../common/service/rg_platform_driver.service | 15 + .../service/rg_platform_process.service | 15 + .../common/sonic_platform/__init__.py | 2 + .../common/sonic_platform/chassis.py | 577 +++ .../common/sonic_platform/component.py | 78 + .../common/sonic_platform/dcdc.py | 94 + .../common/sonic_platform/eeprom.py | 54 + .../common/sonic_platform/fan.py | 310 ++ .../common/sonic_platform/fan_drawer.py | 99 + .../common/sonic_platform/logger.py | 18 + .../common/sonic_platform/platform.py | 25 + .../common/sonic_platform/psu.py | 360 ++ .../common/sonic_platform/sfp.py | 301 ++ .../common/sonic_platform/thermal.py | 237 + .../common/sonic_platform/watchdog.py | 72 + .../common_custom/common_tx/Makefile | 39 + .../common_tx/S3IP_sysfs/Makefile | 19 + .../S3IP_sysfs/device_driver/Makefile | 34 + .../device_driver/cpld_device_driver.c | 207 + .../device_driver/curr_sensor_device_driver.c | 188 + .../device_driver/fan_device_driver.c | 459 ++ .../device_driver/fpga_device_driver.c | 206 + .../include/device_driver_common.h | 49 + .../device_driver/psu_device_driver.c | 737 +++ .../device_driver/slot_device_driver.c | 1016 ++++ .../device_driver/syseeprom_device_driver.c | 125 + .../device_driver/sysled_device_driver.c | 229 + .../device_driver/temp_sensor_device_driver.c | 196 + .../device_driver/transceiver_device_driver.c | 424 ++ .../device_driver/vol_sensor_device_driver.c | 234 + .../device_driver/watchdog_device_driver.c | 204 + .../S3IP_sysfs/switch_driver/Makefile | 36 + .../S3IP_sysfs/switch_driver/cfg/dfd_cfg.c | 964 ++++ .../switch_driver/cfg/dfd_cfg_adapter.c | 415 ++ .../switch_driver/cfg/dfd_cfg_file.c | 203 + .../switch_driver/cfg/dfd_cfg_info.c | 583 +++ .../switch_driver/cfg/dfd_cfg_listnode.c | 95 + .../switch_driver/cfg/dfd_frueeprom.c | 498 ++ .../switch_driver/cfg/dfd_tlveeprom.c | 443 ++ .../dfd_cfg/ko/cfg_file/TCS8400-CPLD.cfg | 143 + .../dfd_cfg/ko/cfg_file/TCS8400-FAN.cfg | 386 ++ .../dfd_cfg/ko/cfg_file/TCS8400-FPGA.cfg | 41 + .../dfd_cfg/ko/cfg_file/TCS8400-LED.cfg | 89 + .../dfd_cfg/ko/cfg_file/TCS8400-PSU.cfg | 325 ++ .../dfd_cfg/ko/cfg_file/TCS8400-SENSOR.cfg | 1348 ++++++ .../dfd_cfg/ko/cfg_file/TCS8400-SFF.cfg | 1032 ++++ .../dfd_cfg/ko/cfg_file/TCS8400-V2-SENSOR.cfg | 1348 ++++++ .../dfd_cfg/ko/cfg_file/TCS9400-CPLD.cfg | 219 + .../dfd_cfg/ko/cfg_file/TCS9400-FAN.cfg | 501 ++ .../dfd_cfg/ko/cfg_file/TCS9400-FPGA.cfg | 103 + .../dfd_cfg/ko/cfg_file/TCS9400-LED.cfg | 101 + .../dfd_cfg/ko/cfg_file/TCS9400-PSU.cfg | 622 +++ .../dfd_cfg/ko/cfg_file/TCS9400-SENSOR.cfg | 2402 ++++++++++ .../dfd_cfg/ko/cfg_file/TCS9400-SFF.cfg | 4233 +++++++++++++++++ .../dfd_cfg/ko/cfg_file/TCS9400-V2-SENSOR.cfg | 2405 ++++++++++ .../switch_driver/dfd_cfg/ko/file_name/0x4074 | 7 + .../switch_driver/dfd_cfg/ko/file_name/0x4078 | 7 + .../switch_driver/dfd_cfg/ko/file_name/0x407b | 7 + .../switch_driver/dfd_cfg/ko/file_name/0x407c | 7 + .../switch_driver/include/dfd_cfg.h | 139 + .../switch_driver/include/dfd_cfg_adapter.h | 49 + .../switch_driver/include/dfd_cfg_file.h | 37 + .../switch_driver/include/dfd_cfg_info.h | 110 + .../switch_driver/include/dfd_cfg_listnode.h | 30 + .../switch_driver/include/dfd_frueeprom.h | 69 + .../switch_driver/include/dfd_sysfs_common.h | 192 + .../switch_driver/include/dfd_tlveeprom.h | 70 + .../switch_driver/include/rg_cpld_driver.h | 19 + .../switch_driver/include/rg_eeprom_driver.h | 9 + .../switch_driver/include/rg_fan_driver.h | 35 + .../switch_driver/include/rg_fpga_driver.h | 19 + .../switch_driver/include/rg_led_driver.h | 8 + .../switch_driver/include/rg_module.h | 267 ++ .../switch_driver/include/rg_psu_driver.h | 14 + .../switch_driver/include/rg_sensors_driver.h | 15 + .../switch_driver/include/rg_sff_driver.h | 8 + .../switch_driver/include/rg_slot_driver.h | 8 + .../include/rg_watchdog_driver.h | 8 + .../switch_driver/include/switch_driver.h | 61 + .../S3IP_sysfs/switch_driver/rg_cpld_driver.c | 196 + .../switch_driver/rg_eeprom_driver.c | 107 + .../S3IP_sysfs/switch_driver/rg_fan_driver.c | 724 +++ .../S3IP_sysfs/switch_driver/rg_fpga_driver.c | 275 ++ .../S3IP_sysfs/switch_driver/rg_led_driver.c | 103 + .../S3IP_sysfs/switch_driver/rg_module.c | 47 + .../S3IP_sysfs/switch_driver/rg_psu_driver.c | 390 ++ .../switch_driver/rg_sensors_driver.c | 230 + .../S3IP_sysfs/switch_driver/rg_sff_driver.c | 69 + .../S3IP_sysfs/switch_driver/rg_slot_driver.c | 104 + .../switch_driver/rg_watchdog_driver.c | 155 + .../S3IP_sysfs/switch_driver/switch_driver.c | 2546 ++++++++++ .../S3IP_sysfs/sysfs_driver/Makefile | 27 + .../S3IP_sysfs/sysfs_driver/cpld_sysfs.c | 365 ++ .../sysfs_driver/curr_sensor_sysfs.c | 391 ++ .../S3IP_sysfs/sysfs_driver/fan_sysfs.c | 753 +++ .../S3IP_sysfs/sysfs_driver/fpga_sysfs.c | 365 ++ .../sysfs_driver/include/cpld_sysfs.h | 16 + .../sysfs_driver/include/curr_sensor_sysfs.h | 17 + .../sysfs_driver/include/fan_sysfs.h | 26 + .../sysfs_driver/include/fpga_sysfs.h | 16 + .../sysfs_driver/include/psu_sysfs.h | 38 + .../sysfs_driver/include/slot_sysfs.h | 57 + .../S3IP_sysfs/sysfs_driver/include/switch.h | 68 + .../sysfs_driver/include/syseeprom_sysfs.h | 12 + .../sysfs_driver/include/sysled_sysfs.h | 19 + .../sysfs_driver/include/temp_sensor_sysfs.h | 17 + .../sysfs_driver/include/transceiver_sysfs.h | 26 + .../sysfs_driver/include/vol_sensor_sysfs.h | 19 + .../sysfs_driver/include/watchdog_sysfs.h | 16 + .../S3IP_sysfs/sysfs_driver/psu_sysfs.c | 990 ++++ .../S3IP_sysfs/sysfs_driver/slot_sysfs.c | 2099 ++++++++ .../S3IP_sysfs/sysfs_driver/switch.c | 270 ++ .../S3IP_sysfs/sysfs_driver/sysled_sysfs.c | 314 ++ .../sysfs_driver/temp_sensor_sysfs.c | 391 ++ .../sysfs_driver/transceiver_sysfs.c | 618 +++ .../sysfs_driver/vol_sensor_sysfs.c | 433 ++ .../S3IP_sysfs/sysfs_driver/watchdog_sysfs.c | 263 + .../common_tx/script/s3ip_load.py | 30 + .../common_tx/script/s3ip_sysfs_tool.sh | 33 + .../common_tx/service/s3ip_sysfs.service | 17 + .../debian/changelog | 5 + .../debian/compat | 1 + .../debian/control | 13 + .../debian/copyright | 16 + .../platform-modules-ruijie-tcs8400.install | 1 + .../platform-modules-ruijie-tcs8400.postinst | 10 + .../debian/rule-tx.mk | 6 + .../debian/rules | 100 + .../tcs8400/Makefile | 28 + ...x86_64_tencent_tcs8400_r0_0x407b_config.py | 975 ++++ .../x86_64_tencent_tcs8400_r0_config.py | 975 ++++ .../x86_64_tencent_tcs8400_r0_port_config.py | 6 + ...x86_64_tencent_tcs8400_r0_0x407b_device.py | 1108 +++++ .../x86_64_tencent_tcs8400_r0_device.py | 1108 +++++ .../x86_64_tencent_tcs8400_r0_monitor.py | 212 + .../tcs8400/modules/driver/Makefile | 12 + .../modules/driver/rg_fpga_i2c_bus_device.c | 874 ++++ .../modules/driver/rg_fpga_pca954x_device.c | 308 ++ .../modules/driver/rg_i2c_dev_device.c | 155 + .../tcs8400/modules/driver/rg_io_dev_device.c | 138 + .../modules/driver/rg_lpc_drv_device.c | 130 + .../modules/driver/rg_pcie_dev_device.c | 93 + .../tcs8400/modules/driver/rg_wdt_device.c | 104 + .../tcs8400/plat_sysfs_cfg/TCS8400-CPLD.cfg | 20 + .../tcs8400/plat_sysfs_cfg/TCS8400-FAN.cfg | 413 ++ .../tcs8400/plat_sysfs_cfg/TCS8400-PSU.cfg | 50 + .../tcs8400/plat_sysfs_cfg/TCS8400-SFF.cfg | 292 ++ .../tcs8400/plat_sysfs_cfg/cfg_file_name | 4 + .../tcs8400/s3ip_config/customer_sysfs.json | 70 + .../tcs8400/setup.py | 40 + .../tcs9400/Makefile | 28 + ...x86_64_tencent_tcs9400_r0_0x407c_config.py | 1422 ++++++ .../x86_64_tencent_tcs9400_r0_config.py | 1422 ++++++ .../x86_64_tencent_tcs9400_r0_port_config.py | 6 + ...x86_64_tencent_tcs9400_r0_0x407c_device.py | 1739 +++++++ .../x86_64_tencent_tcs9400_r0_device.py | 1739 +++++++ .../x86_64_tencent_tcs9400_r0_monitor.py | 154 + .../tcs9400/modules/driver/Makefile | 12 + .../modules/driver/rg_fpga_i2c_bus_device.c | 2394 ++++++++++ .../modules/driver/rg_fpga_pca954x_device.c | 824 ++++ .../modules/driver/rg_i2c_dev_device.c | 185 + .../tcs9400/modules/driver/rg_io_dev_device.c | 103 + .../modules/driver/rg_lpc_drv_device.c | 111 + .../modules/driver/rg_pcie_dev_device.c | 132 + .../tcs9400/modules/driver/rg_wdt_device.c | 104 + .../tcs9400/plat_sysfs_cfg/TCS9400-CPLD.cfg | 29 + .../tcs9400/plat_sysfs_cfg/TCS9400-FAN.cfg | 422 ++ .../tcs9400/plat_sysfs_cfg/TCS9400-PSU.cfg | 98 + .../tcs9400/plat_sysfs_cfg/TCS9400-SENSOR.cfg | 188 + .../tcs9400/plat_sysfs_cfg/TCS9400-SFF.cfg | 1157 +++++ .../tcs9400/plat_sysfs_cfg/cfg_file_name | 5 + .../tcs9400/s3ip_config/customer_sysfs.json | 70 + .../tcs9400/setup.py | 40 + 333 files changed, 103583 insertions(+), 1 deletion(-) create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/TCS8400-24CC8CD.yml create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/port_config.ini create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/sai.profile create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/config_db.TCS8400-24CC8CD.json create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/cpu.cint create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/custom_led.bin create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/default_sku create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/dev.xml create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/dev_0x407b.xml create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/fru.py create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/installer.conf create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/led_proc_init.soc create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/monitor.py create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/platform_asic create mode 100644 device/tencent/x86_64-tencent_tcs8400-r0/platform_env.conf create mode 100755 device/tencent/x86_64-tencent_tcs8400-r0/prbs.cint create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/TCS9400-128CC.yml create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/port_config.ini create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/sai.profile create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/config_db.TCS9400-128CC.json create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/custom_led.bin create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/default_sku create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/dev.xml create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/dev_0x407c.xml create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/fru.py create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/installer.conf create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/led_proc_init.soc create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/monitor.py create mode 100755 device/tencent/x86_64-tencent_tcs9400-r0/platform_asic create mode 100644 device/tencent/x86_64-tencent_tcs9400-r0/platform_env.conf mode change 100644 => 100755 platform/broadcom/one-image.mk create mode 100644 platform/broadcom/platform-modules-tencent.dep create mode 100644 platform/broadcom/platform-modules-tencent.mk mode change 100644 => 100755 platform/broadcom/rules.mk create mode 100755 platform/broadcom/sonic-platform-modules-tencent/LICENSE create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/Makefile create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/__init__.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/hysteresis.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/openloop.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/pid.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/__init__.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/fru.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/onietlv.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/__init__.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/baseutil.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/chassisbase.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/component.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpld.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpu.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/dcdc.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/devicebase.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/fan.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/interface.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/led.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/onie_e2.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/osutil.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/psu.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/rotor.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/sensor.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/temp.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/__init__.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/baseutil.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/smbus.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/modprobe_conf/kernel_drivers_blacklist.conf create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/modules/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/fpga_i2c.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_csu550.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_eeprom_93xx46.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_i2c_bus_drv.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pca954x_drv.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pcie.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_d1500.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_gpio_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ina3221.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_mac_bsc.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_optoe.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.h create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/Makefile create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_adapter.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_file.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_info.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_listnode.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_frueeprom.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_tlveeprom.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_cpld_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_fan_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_led_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_module.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_psu_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sensors_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sff_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sfpbase.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_slot_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_syseeprom_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_adapter.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_file.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_info.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_listnode.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cpld_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_fan_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_frueeprom.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_led_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_module.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_psu_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sensors_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sff_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sfpparse.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_slot_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_syseeprom_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_tlveeprom.h create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_plat_switch.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_sysfs_common.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_fan.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_psu.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sensor.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sff.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_switch.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus_core.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_93xx46.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_tps53622.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ucd9000.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_xdpe132g5c.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie_common_module.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common/modules/spi-bitbang-txrx.h create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/dev_monitor.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/hal_fanctrl.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/hal_ledctrl.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/platform_intf.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/platform_manufacturer.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/platform_sensors.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/platform_util.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_driver.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_process.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/rg_pmon_syslog.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/ruijiecommon.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieconfig.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieutil.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/sensors create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/sfp_highest_temperatue.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/script/xdpe_avscontrol.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_driver.service create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_process.service create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/__init__.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/chassis.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/component.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/dcdc.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/eeprom.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan_drawer.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/logger.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/platform.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/psu.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/sfp.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/thermal.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/watchdog.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/Makefile create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/Makefile create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/cpld_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/curr_sensor_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fan_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fpga_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/include/device_driver_common.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/psu_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/slot_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/syseeprom_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/sysled_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/temp_sensor_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/transceiver_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/vol_sensor_device_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/watchdog_device_driver.c create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_adapter.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_file.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_info.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_listnode.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_frueeprom.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_tlveeprom.c create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-CPLD.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FAN.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FPGA.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-LED.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-PSU.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SENSOR.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SFF.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-V2-SENSOR.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-CPLD.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FAN.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FPGA.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-LED.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-PSU.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SENSOR.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SFF.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-V2-SENSOR.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4074 create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4078 create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407b create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_adapter.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_file.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_info.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_listnode.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_frueeprom.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_sysfs_common.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_tlveeprom.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_cpld_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_eeprom_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fan_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fpga_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_led_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_module.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_psu_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sensors_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sff_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_slot_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_watchdog_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/switch_driver.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_cpld_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_eeprom_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fan_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fpga_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_led_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_module.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_psu_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sensors_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sff_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_slot_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_watchdog_driver.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/switch_driver.c create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/cpld_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/curr_sensor_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fan_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fpga_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/cpld_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/curr_sensor_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fan_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fpga_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/psu_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/slot_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/switch.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/syseeprom_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/sysled_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/temp_sensor_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/transceiver_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/vol_sensor_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/watchdog_sysfs.h create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/psu_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/slot_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/switch.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/sysled_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/temp_sensor_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/transceiver_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/vol_sensor_sysfs.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/watchdog_sysfs.c create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_load.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_sysfs_tool.sh create mode 100755 platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/service/s3ip_sysfs.service create mode 100644 platform/broadcom/sonic-platform-modules-tencent/debian/changelog create mode 100644 platform/broadcom/sonic-platform-modules-tencent/debian/compat create mode 100755 platform/broadcom/sonic-platform-modules-tencent/debian/control create mode 100755 platform/broadcom/sonic-platform-modules-tencent/debian/copyright create mode 100644 platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.install create mode 100755 platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.postinst create mode 100755 platform/broadcom/sonic-platform-modules-tencent/debian/rule-tx.mk create mode 100755 platform/broadcom/sonic-platform-modules-tencent/debian/rules create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/Makefile create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_0x407b_config.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_config.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_port_config.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_0x407b_device.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_device.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_monitor.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_i2c_bus_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_pca954x_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_i2c_dev_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_io_dev_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_lpc_drv_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_pcie_dev_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_wdt_device.c create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-CPLD.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-FAN.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-PSU.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-SFF.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/cfg_file_name create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/s3ip_config/customer_sysfs.json create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs8400/setup.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/Makefile create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_0x407c_config.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_config.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_port_config.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_0x407c_device.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_device.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_monitor.py create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_i2c_bus_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_pca954x_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_i2c_dev_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_io_dev_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_lpc_drv_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_pcie_dev_device.c create mode 100644 platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_wdt_device.c create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-CPLD.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-FAN.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-PSU.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SENSOR.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SFF.cfg create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/cfg_file_name create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/s3ip_config/customer_sysfs.json create mode 100755 platform/broadcom/sonic-platform-modules-tencent/tcs9400/setup.py diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/TCS8400-24CC8CD.yml b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/TCS8400-24CC8CD.yml new file mode 100755 index 000000000000..e7a029efc700 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/TCS8400-24CC8CD.yml @@ -0,0 +1,574 @@ +# +# BCM56880 128x100g port configuration. +# +# configuration yaml file +# device: +# : +# : +# ? +# : +# : +# ... +# : +# : +# : +# : +# ... +# : +# +# $Copyright: (c) 2019 Broadcom. +# Broadcom Proprietary and Confidential. All rights reserved.$ +# + +--- +bcm_device: + 0: + global: + bcm_tunnel_term_compatible_mode: 1 + # Multicast group allocated by brcm-sai, setting "vlan_flooding_l2mc_num_reserved=0" + vlan_flooding_l2mc_num_reserved: 0 + shared_block_mask_section: uc_bc + sai_tunnel_support: 1 + l3_alpm_template: 1 + l3_alpm2_bnk_threshold: 100 + uft_mode: 1 + l3_enable: 1 + l2_hitbit_enable: 1 + pktio_mode: 1 + skip_protocol_default_entries: 1 + ifa_enable: 1 +... + +--- +bcm_device: + 0: + port: + "*": + encap_mode: IEEE + dport_map_enable: 1 + 11: + dport_map_port: 1 + 13: + dport_map_port: 2 + 20: + dport_map_port: 3 + 22: + dport_map_port: 4 + 24: + dport_map_port: 5 + 26: + dport_map_port: 6 + 28: + dport_map_port: 7 + 30: + dport_map_port: 8 + 3: + dport_map_port: 9 + 5: + dport_map_port: 10 + 7: + dport_map_port: 11 + 9: + dport_map_port: 12 + 40: + dport_map_port: 13 + 42: + dport_map_port: 14 + 44: + dport_map_port: 15 + 46: + dport_map_port: 16 + 48: + dport_map_port: 17 + 50: + dport_map_port: 18 + 64: + dport_map_port: 19 + 66: + dport_map_port: 20 + 68: + dport_map_port: 21 + 70: + dport_map_port: 22 + 72: + dport_map_port: 23 + 74: + dport_map_port: 24 + 1: + dport_map_port: 25 + 15: + dport_map_port: 26 + 32: + dport_map_port: 27 + 34: + dport_map_port: 28 + 52: + dport_map_port: 29 + 54: + dport_map_port: 30 + 60: + dport_map_port: 31 + 62: + dport_map_port: 32 + +... + +--- +device: + 0: + DEVICE_CONFIG: + # CORE CLOCK FREQUENCY + CORE_CLK_FREQ: CLK_1350MHZ + # PP CLOCK FREQUENCY + PP_CLK_FREQ: CLK_1350MHZ +... + +--- +device: + 0: + PC_PM_CORE: + ? + PC_PM_ID: 1 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x73510624 + RX_LANE_MAP: 0x46270513 + TX_POLARITY_FLIP: 0xa + RX_POLARITY_FLIP: 0x17 + ? + PC_PM_ID: 2 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x52317046 + RX_LANE_MAP: 0x31247056 + TX_POLARITY_FLIP: 0x90 + RX_POLARITY_FLIP: 0x47 + ? + PC_PM_ID: 3 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x23104567 + RX_LANE_MAP: 0x64752310 + TX_POLARITY_FLIP: 0x29 + RX_POLARITY_FLIP: 0x5a + ? + PC_PM_ID: 4 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x23104567 + RX_LANE_MAP: 0x64752310 + TX_POLARITY_FLIP: 0x29 + RX_POLARITY_FLIP: 0x5a + ? + PC_PM_ID: 5 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25047361 + RX_LANE_MAP: 0x10452736 + TX_POLARITY_FLIP: 0xf5 + RX_POLARITY_FLIP: 0xc0 + ? + PC_PM_ID: 6 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x45763210 + RX_LANE_MAP: 0x13026457 + TX_POLARITY_FLIP: 0xa + RX_POLARITY_FLIP: 0xf9 + ? + PC_PM_ID: 7 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x45763210 + RX_LANE_MAP: 0x13026457 + TX_POLARITY_FLIP: 0xa + RX_POLARITY_FLIP: 0xf9 + ? + PC_PM_ID: 8 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x45673210 + RX_LANE_MAP: 0x13026457 + TX_POLARITY_FLIP: 0x4a + RX_POLARITY_FLIP: 0xf3 + ? + PC_PM_ID: 9 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x02476531 + RX_LANE_MAP: 0x05261734 + TX_POLARITY_FLIP: 0xdf + RX_POLARITY_FLIP: 0x84 + ? + PC_PM_ID: 10 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x37065241 + RX_LANE_MAP: 0x04175263 + TX_POLARITY_FLIP: 0x36 + RX_POLARITY_FLIP: 0x39 + ? + PC_PM_ID: 11 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x54762301 + RX_LANE_MAP: 0x13025467 + TX_POLARITY_FLIP: 0x70 + RX_POLARITY_FLIP: 0x6f + ? + PC_PM_ID: 12 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x73125046 + RX_LANE_MAP: 0x21437056 + TX_POLARITY_FLIP: 0x78 + RX_POLARITY_FLIP: 0x5c + ? + PC_PM_ID: 13 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x32104567 + RX_LANE_MAP: 0x64572310 + TX_POLARITY_FLIP: 0xd6 + RX_POLARITY_FLIP: 0xad + ? + PC_PM_ID: 14 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x03172465 + RX_LANE_MAP: 0x45173620 + TX_POLARITY_FLIP: 0xed + RX_POLARITY_FLIP: 0x36 + ? + PC_PM_ID: 15 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x36175042 + RX_LANE_MAP: 0x04176253 + TX_POLARITY_FLIP: 0x10 + RX_POLARITY_FLIP: 0xfa + ? + PC_PM_ID: 16 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x74615203 + RX_LANE_MAP: 0x51704236 + TX_POLARITY_FLIP: 0x5f + RX_POLARITY_FLIP: 0x56 + ? + PC_PM_ID: 17 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x26374051 + RX_LANE_MAP: 0x37046251 + TX_POLARITY_FLIP: 0xaa + RX_POLARITY_FLIP: 0x21 + ? + PC_PM_ID: 18 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x45672310 + RX_LANE_MAP: 0x32105476 + TX_POLARITY_FLIP: 0x15 + RX_POLARITY_FLIP: 0x92 + ? + PC_PM_ID: 19 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x70465321 + RX_LANE_MAP: 0x63107542 + TX_POLARITY_FLIP: 0xe6 + RX_POLARITY_FLIP: 0xf2 + ? + PC_PM_ID: 20 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x23015476 + RX_LANE_MAP: 0x64752301 + TX_POLARITY_FLIP: 0x50 + RX_POLARITY_FLIP: 0x6c +... + +--- +device: + 0: + PC_PORT_PHYS_MAP: + ? + # CPU port + PORT_ID: 0 + : + PC_PHYS_PORT_ID: 0 + ? + PORT_ID: 1 + : + PC_PHYS_PORT_ID: 1 + ? + PORT_ID: 3 + : + PC_PHYS_PORT_ID: 9 + ? + PORT_ID: 5 + : + PC_PHYS_PORT_ID: 13 + ? + PORT_ID: 7 + : + PC_PHYS_PORT_ID: 17 + ? + PORT_ID: 9 + : + PC_PHYS_PORT_ID: 21 + ? + PORT_ID: 11 + : + PC_PHYS_PORT_ID: 25 + ? + PORT_ID: 13 + : + PC_PHYS_PORT_ID: 29 + ? + PORT_ID: 15 + : + PC_PHYS_PORT_ID: 33 + ? + PORT_ID: 20 + : + PC_PHYS_PORT_ID: 41 + ? + PORT_ID: 22 + : + PC_PHYS_PORT_ID: 45 + ? + PORT_ID: 24 + : + PC_PHYS_PORT_ID: 49 + ? + PORT_ID: 26 + : + PC_PHYS_PORT_ID: 53 + ? + PORT_ID: 28 + : + PC_PHYS_PORT_ID: 57 + ? + PORT_ID: 30 + : + PC_PHYS_PORT_ID: 61 + ? + PORT_ID: 32 + : + PC_PHYS_PORT_ID: 65 + ? + PORT_ID: 34 + : + PC_PHYS_PORT_ID: 73 + ? + PORT_ID: 40 + : + PC_PHYS_PORT_ID: 81 + ? + PORT_ID: 42 + : + PC_PHYS_PORT_ID: 85 + ? + PORT_ID: 44 + : + PC_PHYS_PORT_ID: 89 + ? + PORT_ID: 46 + : + PC_PHYS_PORT_ID: 93 + ? + PORT_ID: 48 + : + PC_PHYS_PORT_ID: 97 + ? + PORT_ID: 50 + : + PC_PHYS_PORT_ID: 101 + ? + PORT_ID: 52 + : + PC_PHYS_PORT_ID: 105 + ? + PORT_ID: 54 + : + PC_PHYS_PORT_ID: 113 + ? + PORT_ID: 60 + : + PC_PHYS_PORT_ID: 121 + ? + PORT_ID: 62 + : + PC_PHYS_PORT_ID: 129 + ? + PORT_ID: 64 + : + PC_PHYS_PORT_ID: 137 + ? + PORT_ID: 66 + : + PC_PHYS_PORT_ID: 141 + ? + PORT_ID: 68 + : + PC_PHYS_PORT_ID: 145 + ? + PORT_ID: 70 + : + PC_PHYS_PORT_ID: 149 + ? + PORT_ID: 72 + : + PC_PHYS_PORT_ID: 153 + ? + PORT_ID: 74 + : + PC_PHYS_PORT_ID: 157 + +... + +--- +device: + 0: + PC_PORT: + ? + PORT_ID: 0 + : + ENABLE: 0 + SPEED: 10000 + NUM_LANES: 1 + ? + PORT_ID: [3, 5, 7, 9, 11, 13, + 20, 22, 24, 26, 28, 30, + 40, 42, 44, 46, 48, 50, + 64, 66, 68, 70, 72, 74] + : + ENABLE: 0 + SPEED: 200000 + FEC_MODE: PC_FEC_RS544_2XN + NUM_LANES: 4 + LINK_TRAINING: 0 + MAX_FRAME_SIZE: 9416 + ? + PORT_ID: [1, 15, 32, 34, 52, 54, 60, 62] + : + ENABLE: 0 + SPEED: 400000 + FEC_MODE: PC_FEC_RS544_2XN + NUM_LANES: 8 + LINK_TRAINING: 0 + MAX_FRAME_SIZE: 9416 +... + +--- +device: + 0: + TM_SCHEDULER_CONFIG: + NUM_MC_Q: NUM_MC_Q_4 +... + +--- +device: + 0: + FP_CONFIG: + FP_ING_OPERMODE: GLOBAL_PIPE_AWARE +... +--- +device: + 0: + PORT_PROPERTY: + ? + PORT_ID: 19 + : + PORT_TYPE: 1 + PORT_PARSER: 5 + EGR_PORT_PROPERTY: 2 + ? + PORT_ID: 59 + : + PORT_TYPE: 1 + PORT_PARSER: 5 + EGR_PORT_PROPERTY: 2 +... diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/port_config.ini b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/port_config.ini new file mode 100755 index 000000000000..781cb6eb953b --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/port_config.ini @@ -0,0 +1,33 @@ +# name lanes alias index speed +Ethernet1 25,26,27,28 Eth200GE0/1 1 200000 +Ethernet2 29,30,31,32 Eth200GE0/2 2 200000 +Ethernet3 41,42,43,44 Eth200GE0/3 3 200000 +Ethernet4 45,46,47,48 Eth200GE0/4 4 200000 +Ethernet5 49,50,51,52 Eth200GE0/5 5 200000 +Ethernet6 53,54,55,56 Eth200GE0/6 6 200000 +Ethernet7 57,58,59,60 Eth200GE0/7 7 200000 +Ethernet8 61,62,63,64 Eth200GE0/8 8 200000 +Ethernet9 9,10,11,12 Eth200GE0/9 9 200000 +Ethernet10 13,14,15,16 Eth200GE0/10 10 200000 +Ethernet11 17,18,19,20 Eth200GE0/11 11 200000 +Ethernet12 21,22,23,24 Eth200GE0/12 12 200000 +Ethernet13 81,82,83,84 Eth200GE0/13 13 200000 +Ethernet14 85,86,87,88 Eth200GE0/14 14 200000 +Ethernet15 89,90,91,92 Eth200GE0/15 15 200000 +Ethernet16 93,94,95,96 Eth200GE0/16 16 200000 +Ethernet17 97,98,99,100 Eth200GE0/17 17 200000 +Ethernet18 101,102,103,104 Eth200GE0/18 18 200000 +Ethernet19 137,138,139,140 Eth200GE0/19 19 200000 +Ethernet20 141,142,143,144 Eth200GE0/20 20 200000 +Ethernet21 145,146,147,148 Eth200GE0/21 21 200000 +Ethernet22 149,150,151,152 Eth200GE0/22 22 200000 +Ethernet23 153,154,155,156 Eth200GE0/23 23 200000 +Ethernet24 157,158,159,160 Eth200GE0/24 24 200000 +Ethernet25 1,2,3,4,5,6,7,8 Eth400GE0/25 25 400000 +Ethernet26 33,34,35,36,37,38,39,40 Eth400GE0/26 26 400000 +Ethernet27 65,66,67,68,69,70,71,72 Eth400GE0/27 27 400000 +Ethernet28 73,74,75,76,77,78,79,80 Eth400GE0/28 28 400000 +Ethernet29 105,106,107,108,109,110,111,112 Eth400GE0/29 29 400000 +Ethernet30 113,114,115,116,117,118,119,120 Eth400GE0/30 30 400000 +Ethernet31 121,122,123,124,125,126,127,128 Eth400GE0/31 31 400000 +Ethernet32 129,130,131,132,133,134,135,136 Eth400GE0/32 32 400000 diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/sai.profile b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/sai.profile new file mode 100755 index 000000000000..06a5d9778660 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/TCS8400-24CC8CD/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/TCS8400-24CC8CD.yml diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/config_db.TCS8400-24CC8CD.json b/device/tencent/x86_64-tencent_tcs8400-r0/config_db.TCS8400-24CC8CD.json new file mode 100755 index 000000000000..98586cb35c6b --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/config_db.TCS8400-24CC8CD.json @@ -0,0 +1,268 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hwsku": "TCS8400-24CC8CD", + "platform": "x86_64-tencent_tcs8400-r0", + "mac": "58:69:6c:f1:23:12", + "hostname": "sonic" + } + }, + "PORT": { + "Ethernet1": { + "lanes": "25,26,27,28", + "alias": "Eth200GE0/1", + "index": "1", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet2": { + "lanes": "29,30,31,32", + "alias": "Eth200GE0/2", + "index": "2", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet3": { + "lanes": "41,42,43,44", + "alias": "Eth200GE0/3", + "index": "3", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet4": { + "lanes": "45,46,47,48", + "alias": "Eth200GE0/4", + "index": "4", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet5": { + "lanes": "49,50,51,52", + "alias": "Eth200GE0/5", + "index": "5", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet6": { + "lanes": "53,54,55,56", + "alias": "Eth200GE0/6", + "index": "6", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet7": { + "lanes": "57,58,59,60", + "alias": "Eth200GE0/7", + "index": "7", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet8": { + "lanes": "61,62,63,64", + "alias": "Eth200GE0/8", + "index": "8", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet9": { + "lanes": "9,10,11,12", + "alias": "Eth200GE0/9", + "index": "9", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet10": { + "lanes": "13,14,15,16", + "alias": "Eth200GE0/10", + "index": "10", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet11": { + "lanes": "17,18,19,20", + "alias": "Eth200GE0/11", + "index": "11", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet12": { + "lanes": "21,22,23,24", + "alias": "Eth200GE0/12", + "index": "12", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet13": { + "lanes": "81,82,83,84", + "alias": "Eth200GE0/13", + "index": "13", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet14": { + "lanes": "85,86,87,88", + "alias": "Eth200GE0/14", + "index": "14", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet15": { + "lanes": "89,90,91,92", + "alias": "Eth200GE0/15", + "index": "15", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet16": { + "lanes": "93,94,95,96", + "alias": "Eth200GE0/16", + "index": "16", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet17": { + "lanes": "97,98,99,100", + "alias": "Eth200GE0/17", + "index": "17", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet18": { + "lanes": "101,102,103,104", + "alias": "Eth200GE0/18", + "index": "18", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet19": { + "lanes": "137,138,139,140", + "alias": "Eth200GE0/19", + "index": "19", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet20": { + "lanes": "141,142,143,144", + "alias": "Eth200GE0/20", + "index": "20", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet21": { + "lanes": "145,146,147,148", + "alias": "Eth200GE0/21", + "index": "21", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet22": { + "lanes": "149,150,151,152", + "alias": "Eth200GE0/22", + "index": "22", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet23": { + "lanes": "153,154,155,156", + "alias": "Eth200GE0/23", + "index": "23", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet24": { + "lanes": "157,158,159,160", + "alias": "Eth200GE0/24", + "index": "24", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet25": { + "lanes": "1,2,3,4,5,6,7,8", + "alias": "Eth400GE0/25", + "index": "25", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet26": { + "lanes": "33,34,35,36,37,38,39,40", + "alias": "Eth400GE0/26", + "index": "26", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet27": { + "lanes": "65,66,67,68,69,70,71,72", + "alias": "Eth400GE0/27", + "index": "27", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet28": { + "lanes": "73,74,75,76,77,78,79,80", + "alias": "Eth400GE0/28", + "index": "28", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet29": { + "lanes": "105,106,107,108,109,110,111,112", + "alias": "Eth400GE0/29", + "index": "29", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet30": { + "lanes": "113,114,115,116,117,118,119,120", + "alias": "Eth400GE0/30", + "index": "30", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet31": { + "lanes": "121,122,123,124,125,126,127,128", + "alias": "Eth400GE0/31", + "index": "31", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet32": { + "lanes": "129,130,131,132,133,134,135,136", + "alias": "Eth400GE0/32", + "index": "32", + "speed": "400000", + "admin_status": "up", + "mtu": "9100" + } + } +} diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/cpu.cint b/device/tencent/x86_64-tencent_tcs8400-r0/cpu.cint new file mode 100755 index 000000000000..e286d3cf42a6 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/cpu.cint @@ -0,0 +1,85 @@ +cint_reset(); + +int cint_field_group_create(int unit, bcm_field_group_t grp) +{ + int rv; + + bcm_field_qset_t qset; + bcm_field_aset_t aset; + + BCM_FIELD_QSET_INIT(qset); + BCM_FIELD_QSET_ADD(qset,bcmFieldQualifyDstMac); + BCM_FIELD_QSET_ADD(qset, bcmFieldQualifyStageIngress); + + BCM_FIELD_ASET_INIT(aset); + BCM_FIELD_ASET_ADD(aset, bcmFieldActionCopyToCpu); + + rv = bcm_field_group_create_mode_id(unit, qset, 103, bcmFieldGroupModeAuto, grp); + if (rv != BCM_E_NONE) { + printf("bcm_field_group_create_mode_id failed, rv = %d\r\n", rv); + return -1; + } + printf("cint_field_group_create success!!!, rv = %d\r\n", rv); + + bcm_field_group_dump(unit,grp); + return 0; +} + +int cint_field_entry_create1(int unit, bcm_field_group_t grp,bcm_field_entry_t entry) +{ + int rv; + bcm_mac_t dst_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + bcm_mac_t mac_mask = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + rv = bcm_field_entry_create_id(unit, grp, entry); + if (rv != BCM_E_NONE) { + printf("bcm_field_entry_create_id failed, rv = %d\r\n", rv); + return -1; + } + + + rv =bcm_field_qualify_DstMac(unit, entry, dst_mac, mac_mask); + if (rv != BCM_E_NONE) { + printf("bcm_field_qualify_DstMac failed,ret = %d\r\n", rv); + bcm_field_entry_destroy(unit, entry); + return -1; + } + + rv = bcm_field_action_add(unit, entry, bcmFieldActionCopyToCpu, 1, 0); + if (rv != BCM_E_NONE) { + printf("bcm_field_action_add failed, rv = %d \r\n", rv); + bcm_field_entry_destroy(unit, entry); + return -1; + } + + rv = bcm_field_action_add(unit, entry, bcmFieldActionDrop, 1, 0); + if (rv != BCM_E_NONE) { + printf("bcm_field_action_add failed, rv = %d \r\n", rv); + bcm_field_entry_destroy(unit, entry); + return -1; + } + + rv = bcm_field_entry_install(unit, entry); + if (rv != BCM_E_NONE) { + printf("bcm_field_entry_install failed,ret = %d\r\n", rv); + bcm_field_entry_destroy(unit, entry); + return -1; + } + + printf("********************* BEGIN ****************************\r\n"); + bcm_field_entry_dump(unit, entry); + printf("*********************** END ****************************\r\n"); + + return 0; +} + +cint_field_group_create(0,5); +cint_field_entry_create1(0,5,2048); + +//bcm_field_entry_destroy(0, 2048); +//bcm_field_group_destroy(0, 5); + + + + + diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/custom_led.bin b/device/tencent/x86_64-tencent_tcs8400-r0/custom_led.bin new file mode 100755 index 0000000000000000000000000000000000000000..00dfde29fa27165794e0d72627d9715d06c38293 GIT binary patch literal 700 zcma*k&ui0g7zXg?yOhv&Q>j%pNa@5v3&hl3&Z-4MwcySnOL~@#=nb)0$9(QS%@*ICJwe-e+8rIb_Qk9C zOoR~i8a*njLlKPv2|+)Xk)q|5FlA|pwI8q6P7eaAdjv(IUg zJdrKt1SMz}|9{uAH9<*=^7qnuDa>C=joYI2RvIm7 zoa5xRol{*phpnl<&RW@VsujmsX*+vtr|vj|ZD*|GoFO^khjaY^gjh;T#dDg>6ZQwP z>CIg_*?}hw=q?piJ_O_UcNW9|+k0$}Ymiwi_NkHC`L%(4q8VUu>Em=?{$zeG|Esy3 zy^+36yOf{nqUBLw9BRr + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/dev_0x407b.xml b/device/tencent/x86_64-tencent_tcs8400-r0/dev_0x407b.xml new file mode 100755 index 000000000000..82433485f8db --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/dev_0x407b.xml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/fru.py b/device/tencent/x86_64-tencent_tcs8400-r0/fru.py new file mode 100755 index 000000000000..2ccfba01dea2 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/fru.py @@ -0,0 +1,953 @@ +#!/usr/bin/python3 +import collections +from bitarray import bitarray +from datetime import datetime, timedelta + + +__DEBUG__ = "N" + + +class FruException(Exception): + def __init__(self, message='fruerror', code=-100): + err = 'errcode: {0} message:{1}'.format(code, message) + Exception.__init__(self, err) + self.code = code + self.message = message + + +def e_print(err): + print("ERROR: " + err) + + +def d_print(debug_info): + if(__DEBUG__ == "Y"): + print(debug_info) + + +class FruUtil(): + @staticmethod + def decodeLength(value): + a = bitarray(8) + a.setall(True) + a[0:1] = 0 + a[1:2] = 0 + x = ord(a.tobytes()) + return x & ord(value) + + @staticmethod + def minToData(): + starttime = datetime(1996, 1, 1, 0, 0, 0) + endtime = datetime.now() + seconds = (endtime - starttime).total_seconds() + mins = seconds // 60 + m = int(round(mins)) + return m + + @staticmethod + def getTimeFormat(): + return datetime.now().strftime('%Y-%m-%d') + + @staticmethod + def getTypeLength(value): + if value is None or len(value) == 0: + return 0 + a = bitarray(8) + a.setall(False) + a[0:1] = 1 + a[1:2] = 1 + x = ord(a.tobytes()) + return x | len(value) + + @staticmethod + def checksum(b): + result = 0 + for i in range(len(b)): + result += ord(b[i]) + return (0x100 - (result & 0xff)) & 0xff + + +class BaseArea(object): + SUGGESTED_SIZE_COMMON_HEADER = 8 + SUGGESTED_SIZE_INTERNAL_USE_AREA = 72 + SUGGESTED_SIZE_CHASSIS_INFO_AREA = 32 + SUGGESTED_SIZE_BOARD_INFO_AREA = 80 + SUGGESTED_SIZE_PRODUCT_INFO_AREA = 80 + + INITVALUE = b'\x00' + resultvalue = INITVALUE * 256 + COMMON_HEAD_VERSION = b'\x01' + __childList = None + + def __init__(self, name="", size=0, offset=0): + self.__childList = [] + self._offset = offset + self.name = name + self._size = size + self._isPresent = False + self._data = b'\x00' * size + self.__dataoffset = 0 + + @property + def childList(self): + return self.__childList + + @childList.setter + def childList(self, value): + self.__childList = value + + @property + def offset(self): + return self._offset + + @offset.setter + def offset(self, value): + self._offset = value + + @property + def size(self): + return self._size + + @size.setter + def size(self, value): + self._size = value + + @property + def data(self): + return self._data + + @data.setter + def data(self, value): + self._data = value + + @property + def isPresent(self): + return self._isPresent + + @isPresent.setter + def isPresent(self, value): + self._isPresent = value + + +class InternalUseArea(BaseArea): + pass + + +class ChassisInfoArea(BaseArea): + pass + + +class BoardInfoArea(BaseArea): + _boardTime = None + _fields = None + _mfg_date = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "mfg_date : %s \n" \ + "boardManufacturer : %s \n" \ + "boardProductName : %s \n" \ + "boardSerialNumber : %s \n" \ + "boardPartNumber : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.boardversion), self.size, + self.language, self.getMfgRealData(), + self.boardManufacturer, self.boardProductName, + self.boardSerialNumber, self.boardPartNumber, + self.fruFileId) + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "boardextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["boardversion"] = ord(self.boardversion) + dic["boardlength"] = self.size + dic["boardlanguage"] = self.language + dic["boardmfg_date"] = self.getMfgRealData() + dic["boardManufacturer"] = self.boardManufacturer + dic["boardProductName"] = self.boardProductName + dic["boardSerialNumber"] = self.boardSerialNumber + dic["boardPartNumber"] = self.boardPartNumber + dic["boardfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] + index += 1 + d_print("decode length :%d class size:%d" % + ((ord(self.data[index]) * 8), self.size)) + index += 2 + + timetmp = self.data[index: index + 3] + self.mfg_date = ord(timetmp[0]) | ( + ord(timetmp[1]) << 8) | (ord(timetmp[2]) << 16) + d_print("decode getMfgRealData :%s" % self.getMfgRealData()) + index += 3 + + templen = FruUtil.decodeLength(self.data[index]) + self.boardManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardManufacturer:%s" % self.boardManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardProductName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardProductName:%s" % self.boardProductName) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardSerialNumber:%s" % self.boardSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardPartNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardPartNumber:%s" % self.boardPartNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if self.data[index] != chr(0xc1): + templen = FruUtil.decodeLength(self.data[index]) + tmpval = self.data[index + 1: index + templen + 1] + setattr(self, valtmp, tmpval) + index += templen + 1 + d_print("decode boardextra%d:%s" % (i, tmpval)) + else: + break + return + + def recalcute(self): + d_print("boardInfoArea version:%x" % ord(self.boardversion)) + d_print("boardInfoArea length:%d" % self.size) + d_print("boardInfoArea language:%x" % self.language) + self.mfg_date = FruUtil.minToData() + d_print("boardInfoArea mfg_date:%x" % self.mfg_date) + + self.data = chr(ord(self.boardversion)) + \ + chr(self.size // 8) + chr(self.language) + + self.data += chr(self.mfg_date & 0xFF) + self.data += chr((self.mfg_date >> 8) & 0xFF) + self.data += chr((self.mfg_date >> 16) & 0xFF) + + d_print("boardInfoArea boardManufacturer:%s" % self.boardManufacturer) + typelength = FruUtil.getTypeLength(self.boardManufacturer) + self.data += chr(typelength) + self.data += self.boardManufacturer + + d_print("boardInfoArea boardProductName:%s" % self.boardProductName) + self.data += chr(FruUtil.getTypeLength(self.boardProductName)) + self.data += self.boardProductName + + d_print("boardInfoArea boardSerialNumber:%s" % self.boardSerialNumber) + self.data += chr(FruUtil.getTypeLength(self.boardSerialNumber)) + self.data += self.boardSerialNumber + + d_print("boardInfoArea boardPartNumber:%s" % self.boardPartNumber) + self.data += chr(FruUtil.getTypeLength(self.boardPartNumber)) + self.data += self.boardPartNumber + + d_print("boardInfoArea fruFileId:%s" % self.fruFileId) + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea boardextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + d_print("self data:%d" % len(self.data)) + d_print("self size:%d" % self.size) + d_print("adjust size:%d" % (self.size - len(self.data) - 1)) + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + + # checksum + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + def getMfgRealData(self): + starttime = datetime(1996, 1, 1, 0, 0, 0) + mactime = starttime + timedelta(minutes=self.mfg_date) + return mactime + + @property + def language(self): + self._language = 25 + return self._language + + @property + def mfg_date(self): + return self._mfg_date + + @mfg_date.setter + def mfg_date(self, val): + self._mfg_date = val + + @property + def boardversion(self): + self._boardversion = self.COMMON_HEAD_VERSION + return self._boardversion + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, val): + self._FRUFileID = val + + @property + def boardPartNumber(self): + return self._boardPartNumber + + @boardPartNumber.setter + def boardPartNumber(self, val): + self._boardPartNumber = val + + @property + def boardSerialNumber(self): + return self._boardSerialNumber + + @boardSerialNumber.setter + def boardSerialNumber(self, val): + self._boardSerialNumber = val + + @property + def boardProductName(self): + return self._boradProductName + + @boardProductName.setter + def boardProductName(self, val): + self._boradProductName = val + + @property + def boardManufacturer(self): + return self._boardManufacturer + + @boardManufacturer.setter + def boardManufacturer(self, val): + self._boardManufacturer = val + + @property + def boardTime(self): + return self._boardTime + + @boardTime.setter + def boardTime(self, val): + self._boardTime = val + + @property + def fields(self): + return self._fields + + @fields.setter + def fields(self, val): + self._fields = val + + +class ProductInfoArea(BaseArea): + _productManufacturer = None + _productAssetTag = None + _FRUFileID = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "productManufacturer : %s \n" \ + "productName : %s \n" \ + "productPartModelName: %s \n" \ + "productVersion : %s \n" \ + "productSerialNumber : %s \n" \ + "productAssetTag : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.areaversion), self.size, + self.language, self.productManufacturer, + self.productName, self.productPartModelName, + self.productVersion, self.productSerialNumber, + self.productAssetTag, self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "productextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["productversion"] = ord(self.areaversion) + dic["productlength"] = self.size + dic["productlanguage"] = self.language + dic["productManufacturer"] = self.productManufacturer + dic["productName"] = self.productName + dic["productPartModelName"] = self.productPartModelName + dic["productVersion"] = int(self.productVersion, 16) + dic["productSerialNumber"] = self.productSerialNumber + dic["productAssetTag"] = self.productAssetTag + dic["productfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] # 0 + index += 1 + d_print("decode length %d" % (ord(self.data[index]) * 8)) + d_print("class size %d" % self.size) + index += 2 + + templen = FruUtil.decodeLength(self.data[index]) + self.productManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productManufacturer:%s" % self.productManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.productName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productName:%s" % self.productName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productPartModelName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productPartModelName:%s" % self.productPartModelName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productVersion = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productVersion:%s" % self.productVersion) + + templen = FruUtil.decodeLength(self.data[index]) + self.productSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productSerialNumber:%s" % self.productSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.productAssetTag = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productAssetTag:%s" % self.productAssetTag) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if self.data[index] != chr(0xc1) and index < self.size - 1: + templen = FruUtil.decodeLength(self.data[index]) + if templen == 0: + break + tmpval = self.data[index + 1: index + templen + 1] + d_print("decode boardextra%d:%s" % (i, tmpval)) + setattr(self, valtmp, tmpval) + index += templen + 1 + else: + break + + @property + def productVersion(self): + return self._productVersion + + @productVersion.setter + def productVersion(self, name): + self._productVersion = name + + @property + def areaversion(self): + self._areaversion = self.COMMON_HEAD_VERSION + return self._areaversion + + @areaversion.setter + def areaversion(self, name): + self._areaversion = name + + @property + def language(self): + self._language = 25 + return self._language + + @property + def productManufacturer(self): + return self._productManufacturer + + @productManufacturer.setter + def productManufacturer(self, name): + self._productManufacturer = name + + @property + def productName(self): + return self._productName + + @productName.setter + def productName(self, name): + self._productName = name + + @property + def productPartModelName(self): + return self._productPartModelName + + @productPartModelName.setter + def productPartModelName(self, name): + self._productPartModelName = name + + @property + def productSerialNumber(self): + return self._productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, name): + self._productSerialNumber = name + + @property + def productAssetTag(self): + return self._productAssetTag + + @productAssetTag.setter + def productAssetTag(self, name): + self._productAssetTag = name + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, name): + self._FRUFileID = name + + def recalcute(self): + d_print("product version:%x" % ord(self.areaversion)) + d_print("product length:%d" % self.size) + d_print("product language:%x" % self.language) + self.data = chr(ord(self.areaversion)) + \ + chr(self.size // 8) + chr(self.language) + + typelength = FruUtil.getTypeLength(self.productManufacturer) + self.data += chr(typelength) + self.data += self.productManufacturer + + self.data += chr(FruUtil.getTypeLength(self.productName)) + self.data += self.productName + + self.data += chr(FruUtil.getTypeLength(self.productPartModelName)) + self.data += self.productPartModelName + + self.data += chr(FruUtil.getTypeLength(self.productVersion)) + self.data += self.productVersion + + self.data += chr(FruUtil.getTypeLength(self.productSerialNumber)) + self.data += self.productSerialNumber + + self.data += chr(FruUtil.getTypeLength(self.productAssetTag)) + if self.productAssetTag is not None: + self.data += self.productAssetTag + + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea productextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + d_print("self.data:%d" % len(self.data)) + d_print("self.size:%d" % self.size) + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + +class MultiRecordArea(BaseArea): + pass + + +class Field(object): + + def __init__(self, fieldType="ASCII", fieldData=""): + self.fieldData = fieldData + self.fieldType = fieldType + + @property + def data(self): + return self._data + + @property + def fieldType(self): + return self._fieldType + + @property + def fieldData(self): + return self._fieldData + + +class ipmifru(BaseArea): + _BoardInfoArea = None + _ProductInfoArea = None + _InternalUseArea = None + _ChassisInfoArea = None + _multiRecordArea = None + _productinfoAreaOffset = BaseArea.INITVALUE + _boardInfoAreaOffset = BaseArea.INITVALUE + _internalUserAreaOffset = BaseArea.INITVALUE + _chassicInfoAreaOffset = BaseArea.INITVALUE + _multiRecordAreaOffset = BaseArea.INITVALUE + _bindata = None + _bodybin = None + _version = BaseArea.COMMON_HEAD_VERSION + _zeroCheckSum = None + _frusize = 256 + + def __str__(self): + tmpstr = "" + if self.boardInfoArea.isPresent: + tmpstr += "\nboardinfoarea: \n" + tmpstr += self.boardInfoArea.__str__() + if self.productInfoArea.isPresent: + tmpstr += "\nproductinfoarea: \n" + tmpstr += self.productInfoArea.__str__() + return tmpstr + + def decodeBin(self, eeprom): + commonHead = eeprom[0:8] + d_print("decode version %x" % ord(commonHead[0])) + if ord(self.COMMON_HEAD_VERSION) != ord(commonHead[0]): + raise FruException("HEAD VERSION error,not Fru format!", -10) + if FruUtil.checksum(commonHead[0:7]) != ord(commonHead[7]): + strtemp = "check header checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(commonHead[0:7]), ord(commonHead[7])) + raise FruException(strtemp, -3) + if ord(commonHead[1]) != ord(self.INITVALUE): + d_print("Internal Use Area is present") + self.internalUseArea = InternalUseArea( + name="Internal Use Area", size=self.SUGGESTED_SIZE_INTERNAL_USE_AREA) + self.internalUseArea.isPresent = True + self.internalUserAreaOffset = ord(commonHead[1]) + self.internalUseArea.data = eeprom[self.internalUserAreaOffset * 8: ( + self.internalUserAreaOffset * 8 + self.internalUseArea.size)] + if ord(commonHead[2]) != ord(self.INITVALUE): + d_print("Chassis Info Area is present") + self.chassisInfoArea = ChassisInfoArea( + name="Chassis Info Area", size=self.SUGGESTED_SIZE_CHASSIS_INFO_AREA) + self.chassisInfoArea.isPresent = True + self.chassicInfoAreaOffset = ord(commonHead[2]) + self.chassisInfoArea.data = eeprom[self.chassicInfoAreaOffset * 8: ( + self.chassicInfoAreaOffset * 8 + self.chassisInfoArea.size)] + if ord(commonHead[3]) != ord(self.INITVALUE): + self.boardInfoArea = BoardInfoArea( + name="Board Info Area", size=self.SUGGESTED_SIZE_BOARD_INFO_AREA) + self.boardInfoArea.isPresent = True + self.boardInfoAreaOffset = ord(commonHead[3]) + self.boardInfoArea.size = ord( + eeprom[self.boardInfoAreaOffset * 8 + 1]) * 8 + d_print("Board Info Area is present size:%d" % + (self.boardInfoArea.size)) + self.boardInfoArea.data = eeprom[self.boardInfoAreaOffset * 8: ( + self.boardInfoAreaOffset * 8 + self.boardInfoArea.size)] + if FruUtil.checksum(self.boardInfoArea.data[:-1]) != ord(self.boardInfoArea.data[-1:]): + strtmp = "check boardInfoArea checksum error[cal:%02x data:%02x]" % \ + (FruUtil.checksum( + self.boardInfoArea.data[:-1]), ord(self.boardInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.boardInfoArea.decodedata() + if ord(commonHead[4]) != ord(self.INITVALUE): + d_print("Product Info Area is present") + self.productInfoArea = ProductInfoArea( + name="Product Info Area ", size=self.SUGGESTED_SIZE_PRODUCT_INFO_AREA) + self.productInfoArea.isPresent = True + self.productinfoAreaOffset = ord(commonHead[4]) + d_print("length offset value: %02x" % + ord(eeprom[self.productinfoAreaOffset * 8 + 1])) + self.productInfoArea.size = ord( + eeprom[self.productinfoAreaOffset * 8 + 1]) * 8 + d_print("Product Info Area is present size:%d" % + (self.productInfoArea.size)) + + self.productInfoArea.data = eeprom[self.productinfoAreaOffset * 8: ( + self.productinfoAreaOffset * 8 + self.productInfoArea.size)] + if FruUtil.checksum(self.productInfoArea.data[:-1]) != ord(self.productInfoArea.data[-1:]): + strtmp = "check productInfoArea checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(self.productInfoArea.data[:-1]), ord(self.productInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.productInfoArea.decodedata() + if ord(commonHead[5]) != ord(self.INITVALUE): + self.multiRecordArea = MultiRecordArea( + name="MultiRecord record Area ") + d_print("MultiRecord record present") + self.multiRecordArea.isPresent = True + self.multiRecordAreaOffset = ord(commonHead[5]) + self.multiRecordArea.data = eeprom[self.multiRecordAreaOffset * 8: ( + self.multiRecordAreaOffset * 8 + self.multiRecordArea.size)] + + def initDefault(self): + self.version = self.COMMON_HEAD_VERSION + self.internalUserAreaOffset = self.INITVALUE + self.chassicInfoAreaOffset = self.INITVALUE + self.boardInfoAreaOffset = self.INITVALUE + self.productinfoAreaOffset = self.INITVALUE + self.multiRecordAreaOffset = self.INITVALUE + self.PAD = self.INITVALUE + self.zeroCheckSum = self.INITVALUE + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + self.productInfoArea = None + self.internalUseArea = None + self.boardInfoArea = None + self.chassisInfoArea = None + self.multiRecordArea = None + # self.recalcute() + + @property + def version(self): + return self._version + + @version.setter + def version(self, name): + self._version = name + + @property + def internalUserAreaOffset(self): + return self._internalUserAreaOffset + + @internalUserAreaOffset.setter + def internalUserAreaOffset(self, obj): + self._internalUserAreaOffset = obj + + @property + def chassicInfoAreaOffset(self): + return self._chassicInfoAreaOffset + + @chassicInfoAreaOffset.setter + def chassicInfoAreaOffset(self, obj): + self._chassicInfoAreaOffset = obj + + @property + def productinfoAreaOffset(self): + return self._productinfoAreaOffset + + @productinfoAreaOffset.setter + def productinfoAreaOffset(self, obj): + self._productinfoAreaOffset = obj + + @property + def boardInfoAreaOffset(self): + return self._boardInfoAreaOffset + + @boardInfoAreaOffset.setter + def boardInfoAreaOffset(self, obj): + self._boardInfoAreaOffset = obj + + @property + def multiRecordAreaOffset(self): + return self._multiRecordAreaOffset + + @multiRecordAreaOffset.setter + def multiRecordAreaOffset(self, obj): + self._multiRecordAreaOffset = obj + + @property + def zeroCheckSum(self): + return self._zeroCheckSum + + @zeroCheckSum.setter + def zeroCheckSum(self, obj): + self._zeroCheckSum = obj + + @property + def productInfoArea(self): + return self._ProductInfoArea + + @productInfoArea.setter + def productInfoArea(self, obj): + self._ProductInfoArea = obj + + @property + def internalUseArea(self): + return self._InternalUseArea + + @internalUseArea.setter + def internalUseArea(self, obj): + self.internalUseArea = obj + + @property + def boardInfoArea(self): + return self._BoardInfoArea + + @boardInfoArea.setter + def boardInfoArea(self, obj): + self._BoardInfoArea = obj + + @property + def chassisInfoArea(self): + return self._ChassisInfoArea + + @chassisInfoArea.setter + def chassisInfoArea(self, obj): + self._ChassisInfoArea = obj + + @property + def multiRecordArea(self): + return self._multiRecordArea + + @multiRecordArea.setter + def multiRecordArea(self, obj): + self._multiRecordArea = obj + + @property + def bindata(self): + return self._bindata + + @bindata.setter + def bindata(self, obj): + self._bindata = obj + + @property + def bodybin(self): + return self._bodybin + + @bodybin.setter + def bodybin(self, obj): + self._bodybin = obj + + def recalcuteCommonHead(self): + self.bindata = "" + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + d_print("common Header %d" % self.offset) + d_print("fru eeprom size %d" % self._frusize) + if self.internalUseArea is not None and self.internalUseArea.isPresent: + self.internalUserAreaOffset = self.offset // 8 + self.offset += self.internalUseArea.size + d_print("internalUseArea is present offset:%d" % self.offset) + + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + self.chassicInfoAreaOffset = self.offset // 8 + self.offset += self.chassisInfoArea.size + d_print("chassisInfoArea is present offset:%d" % self.offset) + + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + self.boardInfoAreaOffset = self.offset // 8 + self.offset += self.boardInfoArea.size + d_print("boardInfoArea is present offset:%d" % self.offset) + d_print("boardInfoArea is present size:%d" % + self.boardInfoArea.size) + + if self.productInfoArea is not None and self.productInfoArea.isPresent: + self.productinfoAreaOffset = self.offset // 8 + self.offset += self.productInfoArea.size + d_print("productInfoArea is present offset:%d" % self.offset) + + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + self.multiRecordAreaOffset = self.offset // 8 + d_print("multiRecordArea is present offset:%d" % self.offset) + + if self.internalUserAreaOffset == self.INITVALUE: + self.internalUserAreaOffset = 0 + if self.productinfoAreaOffset == self.INITVALUE: + self.productinfoAreaOffset = 0 + if self.chassicInfoAreaOffset == self.INITVALUE: + self.chassicInfoAreaOffset = 0 + if self.boardInfoAreaOffset == self.INITVALUE: + self.boardInfoAreaOffset = 0 + if self.multiRecordAreaOffset == self.INITVALUE: + self.multiRecordAreaOffset = 0 + + self.zeroCheckSum = (0x100 - ord(self.version) - self.internalUserAreaOffset - self.chassicInfoAreaOffset - self.productinfoAreaOffset + - self.boardInfoAreaOffset - self.multiRecordAreaOffset) & 0xff + d_print("zerochecksum:%x" % self.zeroCheckSum) + self.data = "" + self.data += chr(self.version[0]) + chr(self.internalUserAreaOffset) + chr(self.chassicInfoAreaOffset) + chr( + self.boardInfoAreaOffset) + chr(self.productinfoAreaOffset) + chr(self.multiRecordAreaOffset) + chr(self.INITVALUE[0]) + chr(self.zeroCheckSum) + + self.bindata = self.data + self.bodybin + totallen = len(self.bindata) + d_print("totallen %d" % totallen) + if (totallen < self._frusize): + self.bindata = self.bindata.ljust(self._frusize, chr(self.INITVALUE[0])) + else: + raise FruException('bin data more than %d' % self._frusize, -2) + + def recalcutebin(self): + self.bodybin = "" + if self.internalUseArea is not None and self.internalUseArea.isPresent: + d_print("internalUseArea present") + self.bodybin += self.internalUseArea.data + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + d_print("chassisInfoArea present") + self.bodybin += self.chassisInfoArea.data + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + d_print("boardInfoArea present") + self.boardInfoArea.recalcute() + self.bodybin += self.boardInfoArea.data + if self.productInfoArea is not None and self.productInfoArea.isPresent: + d_print("productInfoAreapresent") + self.productInfoArea.recalcute() + self.bodybin += self.productInfoArea.data + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + d_print("multiRecordArea present") + self.bodybin += self.productInfoArea.data + + def recalcute(self, fru_eeprom_size=256): + self._frusize = fru_eeprom_size + self.recalcutebin() + self.recalcuteCommonHead() diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/installer.conf b/device/tencent/x86_64-tencent_tcs8400-r0/installer.conf new file mode 100755 index 000000000000..5e62742c11bf --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/installer.conf @@ -0,0 +1 @@ +CONSOLE_SPEED=115200 diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/led_proc_init.soc b/device/tencent/x86_64-tencent_tcs8400-r0/led_proc_init.soc new file mode 100755 index 000000000000..2f79a8febf86 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/led_proc_init.soc @@ -0,0 +1,6 @@ + +led auto on + +led start + +linkscan SwPortBitMap=all diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/monitor.py b/device/tencent/x86_64-tencent_tcs8400-r0/monitor.py new file mode 100755 index 000000000000..acaf9b4a8c65 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/monitor.py @@ -0,0 +1,431 @@ +#!/usr/bin/python3 +# * onboard temperature sensors +# * FAN trays +# * PSU +# +import os +import xml.etree.ElementTree as ET +import glob +from fru import ipmifru +from decimal import Decimal + + +MAILBOX_DIR = "/sys/bus/i2c/devices/" +BOARD_ID_PATH = "/sys/module/ruijie_common/parameters/dfd_my_type" + +CONFIG_NAME = "dev.xml" + +def byteTostr(val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + +def typeTostr(val): + if isinstance(val, bytes): + strtmp = byteTostr(val) + return strtmp + return val + + +def get_board_id(): + if not os.path.exists(BOARD_ID_PATH): + return "NA" + with open(BOARD_ID_PATH) as fd: + id_str = fd.read().strip() + return "0x%x" % (int(id_str, 10)) + + +def dev_file_read(path, offset, read_len): + retval = "ERR" + val_list = [] + msg = "" + ret = "" + fd = -1 + + if not os.path.exists(path): + return False, "%s %s not found" % (retval, path) + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, read_len) + for item in ret: + val_list.append(item) + except Exception as e: + msg = str(e) + return False, "%s %s" % (retval, msg) + finally: + if fd > 0: + os.close(fd) + return True, val_list + + +def getPMCreg(location): + retval = 'ERR' + if (not os.path.isfile(location)): + return "%s %s notfound"% (retval , location) + try: + with open(location, 'r') as fd: + retval = fd.read() + except Exception as error: + return "ERR %s" % str(error) + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + return retval + + +# Get a mailbox register +def get_pmc_register(reg_name): + retval = 'ERR' + mb_reg_file = reg_name + filepath = glob.glob(mb_reg_file) + if(len(filepath) == 0): + return "%s %s notfound"% (retval , mb_reg_file) + mb_reg_file = filepath[0] + if (not os.path.isfile(mb_reg_file)): + #print mb_reg_file, 'not found !' + return "%s %s notfound"% (retval , mb_reg_file) + try: + with open(mb_reg_file, 'rb') as fd: + retval = fd.read() + retval = typeTostr(retval) + except Exception as error: + retval = "%s %s read failed, msg: %s" % (retval, mb_reg_file, str(error)) + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + return retval + + +class checktype(): + def __init__(self, test1): + self.test1 = test1 + + @staticmethod + def check(name,location, bit, value, tips , err1): + psu_status = int(get_pmc_register(location),16) + val = (psu_status & (1<< bit)) >> bit + if (val != value): + err1["errmsg"] = tips + err1["code"] = -1 + return -1 + else: + err1["errmsg"] = "none" + err1["code"] = 0 + return 0 + + @staticmethod + def getValue(location, bit , type, coefficient = 1, addend = 0): + try: + value_t = get_pmc_register(location) + if value_t.startswith("ERR") : + return value_t + if (type == 1): + return float('%.1f' % ((float(value_t)/1000) + addend)) + elif (type == 2): + return float('%.1f' % (float(value_t)/100)) + elif (type == 3): + psu_status = int(value_t,16) + return (psu_status & (1<< bit)) >> bit + elif (type == 4): + return int(value_t,10) + elif (type == 5): + return float('%.1f' % (float(value_t)/1000/1000)) + elif (type == 6): + return Decimal(float(value_t)*coefficient/1000).quantize(Decimal('0.000')) + else: + return value_t + except Exception as e: + value_t = "ERR %s" % str(e) + return value_t + + #######temp + @staticmethod + def getTemp(self, name, location , ret_t): + ret2 = self.getValue(location + "temp1_input" ," " ,1); + ret3 = self.getValue(location + "temp1_max" ," ", 1); + ret4 = self.getValue(location + "temp1_max_hyst" ," ", 1); + ret_t["temp1_input"] = ret2 + ret_t["temp1_max"] = ret3 + ret_t["temp1_max_hyst"] = ret4 + + @staticmethod + def getLM75(name, location, result): + c1=checktype + r1={} + c1.getTemp(c1, name, location, r1) + result[name] = r1 + + ##########fanFRU + @staticmethod + def decodeBinByValue(retval): + fru = ipmifru() + fru.decodeBin(retval) + return fru + + @staticmethod + def printbinvalue(b): + index = 0 + print(" ",) + for width in range(16): + print("%02x " % width,) + print("") + for i in range(0, len(b)): + if index % 16 == 0: + print(" ") + print(" %02x " % i,) + print("%02x " % ord(b[i]),) + index += 1 + print("") + + @staticmethod + def getfruValue(prob_t, root, val): + try: + ret, binval_bytes = dev_file_read(val, 0, 256) + if ret == False: + return binval_bytes + binval = byteTostr(binval_bytes) + fanpro = {} + ret = checktype.decodeBinByValue(binval) + fanpro['fan_type'] = ret.productInfoArea.productName + fanpro['hw_version'] = ret.productInfoArea.productVersion + fanpro['sn'] = ret.productInfoArea.productSerialNumber + fanpro['fanid'] = ret.productInfoArea.productextra2 + fan_display_name_dict = status.getDecodValue(root, "fan_display_name") + fan_name = fanpro['fan_type'].strip() + if len(fan_display_name_dict) == 0: + return fanpro + if fan_name not in fan_display_name_dict.keys(): + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s'% ("ERR fan name: %s not support" % fan_name) + else: + fanpro['fan_type'] = fan_display_name_dict[fan_name] + return fanpro + except Exception as error: + return "ERR " + str(error) + + @staticmethod + def getslotfruValue(val): + try: + binval = checktype.getValue(val, 0 , 0) + if binval.startswith("ERR"): + return binval + slotpro = {} + ret = checktype.decodeBinByValue(binval) + slotpro['slot_type'] = ret.boardInfoArea.boardProductName + slotpro['hw_version'] = ret.boardInfoArea.boardextra1 + slotpro['sn'] = ret.boardInfoArea.boardSerialNumber + return slotpro + except Exception as error: + return "ERR " + str(error) + + @staticmethod + def getpsufruValue(prob_t, root, val): + try: + psu_match = False + binval = checktype.getValue(val, 0 , 0) + if binval.startswith("ERR"): + return binval + psupro = {} + ret = checktype.decodeBinByValue(binval) + psupro['type1'] = ret.productInfoArea.productPartModelName + psupro['sn'] = ret.productInfoArea.productSerialNumber + psupro['hw_version'] = ret.productInfoArea.productVersion + psu_dict = status.getDecodValue(root, "psutype") + psupro['type1'] = psupro['type1'].strip() + if len(psu_dict) == 0: + return psupro + for psu_name in psu_dict.keys(): + if psu_name in psupro['type1']: + psupro['type1'] = psu_dict[psu_name] + psu_match = True + break + if psu_match is not True: + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s'% ("ERR psu name: %s not support" % psupro['type1']) + return psupro + except Exception as error: + return "ERR " + str(error) + +class status(): + def __init__(self, productname): + self.productname = productname + + @staticmethod + def getETroot(filename): + tree = ET.parse(filename) + root = tree.getroot() + return root; + + @staticmethod + def getDecodValue(collection, decode): + decodes = collection.find('decode') + testdecode = decodes.find(decode) + test={} + if testdecode is None: + return test + for neighbor in testdecode.iter('code'): + test[neighbor.attrib["key"]]=neighbor.attrib["value"] + return test + + @staticmethod + def getfileValue(location): + return checktype.getValue(location," "," ") + + @staticmethod + def getETValue(a, filename, tagname): + root = status.getETroot(filename) + for neighbor in root.iter(tagname): + prob_t = {} + prob_t = neighbor.attrib + prob_t['errcode']= 0 + prob_t['errmsg'] = '' + for pros in neighbor.iter("property"): + ret = dict(list(neighbor.attrib.items()) + list(pros.attrib.items())) + if ret.get('e2type') == 'fru' and ret.get("name") == "fru": + fruval = checktype.getfruValue(prob_t, root, ret["location"]) + if isinstance(fruval, str) and fruval.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= fruval + break + else: + prob_t.update(fruval) + continue + + if ret.get("name") == "psu" and ret.get('e2type') == 'fru': + psuval = checktype.getpsufruValue(prob_t, root, ret["location"]) + if isinstance(psuval, str) and psuval.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= psuval + break + else: + prob_t.update(psuval) + continue + + if ret.get("gettype") == "config": + prob_t[ret["name"]] = ret["value"] + continue + + if ('type' not in ret.keys()): + val = "0"; + else: + val = ret["type"] + if ('bit' not in ret.keys()): + bit = "0"; + else: + bit = ret["bit"] + if ('coefficient' not in ret.keys()): + coefficient = 1; + else: + coefficient = float(ret["coefficient"]) + if ('addend' not in ret.keys()): + addend = 0; + else: + addend = float(ret["addend"]) + + s = checktype.getValue(ret["location"], int(bit),int(val), coefficient, addend) + if isinstance(s, str) and s.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= s + break + if ('default' in ret.keys()): + rt = status.getDecodValue(root,ret['decode']) + prob_t['errmsg']= rt[str(s)] + if str(s) != ret["default"]: + prob_t['errcode']= -1 + break + else: + if ('decode' in ret.keys()): + rt = status.getDecodValue(root,ret['decode']) + if(ret['decode'] == "psutype" and s.replace("\x00","").rstrip() not in rt.keys()): + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s' % ("ERR psu name: %s not support" % (s.replace("\x00","").rstrip())) + else: + s = rt[str(s).replace("\x00","").rstrip()] + name = ret["name"] + prob_t[name]=str(s) + a.append(prob_t) + + @staticmethod + def getCPUValue(a, filename, tagname): + root = status.getETroot(filename) + for neighbor in root.iter(tagname): + location = neighbor.attrib["location"] + L=[] + for dirpath, dirnames, filenames in os.walk(location): + for file in filenames : + if file.endswith("input"): + L.append(os.path.join(dirpath, file)) + L =sorted(L,reverse=False) + for i in range(len(L)): + prob_t = {} + prob_t["name"] = getPMCreg("%s/temp%d_label"%(location,i+1)) + prob_t["temp"] = float(getPMCreg("%s/temp%d_input"%(location,i+1)))/1000 + prob_t["alarm"] = float(getPMCreg("%s/temp%d_crit_alarm"%(location,i+1)))/1000 + prob_t["crit"] = float(getPMCreg("%s/temp%d_crit"%(location,i+1)))/1000 + prob_t["max"] = float(getPMCreg("%s/temp%d_max"%(location,i+1)))/1000 + a.append(prob_t) + + @staticmethod + def getFileName(): + fpath = os.path.dirname(os.path.realpath(__file__)) + board_id = get_board_id() + dev_id_xml = fpath + "/" + "dev_%s.xml" % board_id + if os.path.exists(dev_id_xml): + return dev_id_xml + return fpath + "/"+ CONFIG_NAME + + @staticmethod + def getFan(ret): + _filename = status.getFileName() + _tagname = "fan" + status.getvalue(ret, _filename, _tagname) + + + @staticmethod + def checkFan(ret): + _filename = status.getFileName() + # _filename = "/usr/local/bin/" + status.getFileName() + _tagname = "fan" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getTemp(ret): + _filename = status.getFileName() + #_filename = "/usr/local/bin/" + status.getFileName() + _tagname = "temp" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getPsu(ret): + _filename = status.getFileName() + # _filename = "/usr/local/bin/" + status.getFileName() + _tagname = "psu" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getcputemp(ret): + _filename = status.getFileName() + _tagname = "cpus" + status.getCPUValue(ret, _filename, _tagname) + + @staticmethod + def getDcdc(ret): + _filename = status.getFileName() + _tagname = "dcdc" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getmactemp(ret): + _filename = status.getFileName() + _tagname = "mactemp" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getmacpower(ret): + _filename = status.getFileName() + _tagname = "macpower" + status.getETValue(ret, _filename, _tagname) diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/platform_asic b/device/tencent/x86_64-tencent_tcs8400-r0/platform_asic new file mode 100755 index 000000000000..960467652765 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/platform_asic @@ -0,0 +1 @@ +broadcom diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/platform_env.conf b/device/tencent/x86_64-tencent_tcs8400-r0/platform_env.conf new file mode 100644 index 000000000000..74e9293b382e --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/platform_env.conf @@ -0,0 +1,2 @@ +SYNCD_SHM_SIZE=1g +is_ltsw_chip=1 \ No newline at end of file diff --git a/device/tencent/x86_64-tencent_tcs8400-r0/prbs.cint b/device/tencent/x86_64-tencent_tcs8400-r0/prbs.cint new file mode 100755 index 000000000000..dbc0d93094f6 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs8400-r0/prbs.cint @@ -0,0 +1,17 @@ +void set_port_prbs(int unit_port, int enable){ + int status; + bcm_port_control_set(0, unit_port, bcmPortControlPrbsPolynomial, 6); + bcm_port_control_set(0, unit_port, bcmPortControlPrbsRxEnable, 0); + bcm_port_control_set(0, unit_port, bcmPortControlPrbsTxEnable, 0); + if(enable == 1){ + bcm_port_control_set(0, unit_port, bcmPortControlPrbsRxEnable, 1); + bcm_port_control_set(0, unit_port, bcmPortControlPrbsTxEnable, 1); + bcm_port_control_get(0, unit_port, bcmPortControlPrbsRxStatus, &status); + } +} + +int get_port_prbs_result(int unit_port){ + int status; + bcm_port_control_get(0, unit_port, bcmPortControlPrbsRxStatus, &status); + return status; +} \ No newline at end of file diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/TCS9400-128CC.yml b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/TCS9400-128CC.yml new file mode 100755 index 000000000000..4f5d6c2c2188 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/TCS9400-128CC.yml @@ -0,0 +1,1783 @@ +# +# BCM56990 128x200g port configuration. +# +# configuration yaml file +# device: +# : +#
: +# ? +# : +# : +# ... +# : +# : +# : +# : +# ... +# : +# +# $Copyright: (c) 2019 Broadcom. +# Broadcom Proprietary and Confidential. All rights reserved.$ +# + +--- +device: + 0: + PORT_CONFIG: + PORT_SYSTEM_PROFILE_OPERMODE_PIPEUNIQUE: 1 + PC_PM_CORE: + ? + PC_PM_ID: 1 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x51043627 + TX_POLARITY_FLIP: 0xB6 + RX_LANE_MAP: 0x51406273 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 2 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x62370514 + TX_POLARITY_FLIP: 0x49 + RX_LANE_MAP: 0x15042637 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 3 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x37260451 + TX_POLARITY_FLIP: 0xE9 + RX_LANE_MAP: 0x73624501 + RX_POLARITY_FLIP: 0xAF + + ? + PC_PM_ID: 4 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x40517326 + TX_POLARITY_FLIP: 0x16 + RX_LANE_MAP: 0x04153276 + RX_POLARITY_FLIP: 0x50 + + ? + PC_PM_ID: 5 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x05724361 + TX_POLARITY_FLIP: 0x23 + RX_LANE_MAP: 0x27143605 + RX_POLARITY_FLIP: 0xED + + ? + PC_PM_ID: 6 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43602517 + TX_POLARITY_FLIP: 0x62 + RX_LANE_MAP: 0x05361247 + RX_POLARITY_FLIP: 0x36 + + ? + PC_PM_ID: 7 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25714063 + TX_POLARITY_FLIP: 0xEA + RX_LANE_MAP: 0x27143605 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 8 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43607125 + TX_POLARITY_FLIP: 0xE9 + RX_LANE_MAP: 0x05361247 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 9 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x42605371 + TX_POLARITY_FLIP: 0xBB + RX_LANE_MAP: 0x34561027 + RX_POLARITY_FLIP: 0x8E + + ? + PC_PM_ID: 10 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x52713064 + TX_POLARITY_FLIP: 0xA9 + RX_LANE_MAP: 0x36054712 + RX_POLARITY_FLIP: 0x22 + + ? + PC_PM_ID: 11 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x21753064 + TX_POLARITY_FLIP: 0x6C + RX_LANE_MAP: 0x27413605 + RX_POLARITY_FLIP: 0xBB + + ? + PC_PM_ID: 12 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x52714360 + TX_POLARITY_FLIP: 0xBB + RX_LANE_MAP: 0x27153604 + RX_POLARITY_FLIP: 0xAA + + ? + PC_PM_ID: 13 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x71526430 + TX_POLARITY_FLIP: 0x53 + RX_LANE_MAP: 0x15273046 + RX_POLARITY_FLIP: 0x7B + + ? + PC_PM_ID: 14 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x70156423 + TX_POLARITY_FLIP: 0x17 + RX_LANE_MAP: 0x12573046 + RX_POLARITY_FLIP: 0x41 + ? + PC_PM_ID: 15 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64307521 + TX_POLARITY_FLIP: 0x22 + RX_LANE_MAP: 0x30462517 + RX_POLARITY_FLIP: 0x65 + + ? + PC_PM_ID: 16 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x71436520 + TX_POLARITY_FLIP: 0x53 + RX_LANE_MAP: 0x05362417 + RX_POLARITY_FLIP: 0x77 + + ? + PC_PM_ID: 17 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16340725 + TX_POLARITY_FLIP: 0x22 + RX_LANE_MAP: 0x50734162 + RX_POLARITY_FLIP: 0xBB + + ? + PC_PM_ID: 18 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16347520 + TX_POLARITY_FLIP: 0xA3 + RX_LANE_MAP: 0x30574162 + RX_POLARITY_FLIP: 0x6A + + ? + PC_PM_ID: 19 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16340725 + TX_POLARITY_FLIP: 0xBB + RX_LANE_MAP: 0x50634172 + RX_POLARITY_FLIP: 0x22 + + ? + PC_PM_ID: 20 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64317520 + TX_POLARITY_FLIP: 0x22 + RX_LANE_MAP: 0x53264071 + RX_POLARITY_FLIP: 0xAA + + ? + PC_PM_ID: 21 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x34162507 + TX_POLARITY_FLIP: 0x55 + RX_LANE_MAP: 0x72416350 + RX_POLARITY_FLIP: 0x55 + + ? + PC_PM_ID: 22 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x61437520 + TX_POLARITY_FLIP: 0x7F + RX_LANE_MAP: 0x12473056 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 23 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25071436 + TX_POLARITY_FLIP: 0x7D + RX_LANE_MAP: 0x72416350 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 24 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64712035 + TX_POLARITY_FLIP: 0x1B + RX_LANE_MAP: 0x47215630 + RX_POLARITY_FLIP: 0x33 + + ? + PC_PM_ID: 25 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x70251436 + TX_POLARITY_FLIP: 0xFE + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 26 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16347052 + TX_POLARITY_FLIP: 0xF4 + RX_LANE_MAP: 0x63507421 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 27 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x70251436 + TX_POLARITY_FLIP: 0xEA + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0xFC + + ? + PC_PM_ID: 28 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x26041573 + TX_POLARITY_FLIP: 0xC1 + RX_LANE_MAP: 0x63507412 + RX_POLARITY_FLIP: 0x12 + + ? + PC_PM_ID: 29 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x15047362 + TX_POLARITY_FLIP: 0x19 + RX_LANE_MAP: 0x40516723 + RX_POLARITY_FLIP: 0x50 + + ? + PC_PM_ID: 30 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x62735104 + TX_POLARITY_FLIP: 0xE9 + RX_LANE_MAP: 0x37261054 + RX_POLARITY_FLIP: 0xAF + + ? + PC_PM_ID: 31 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x37625041 + TX_POLARITY_FLIP: 0x49 + RX_LANE_MAP: 0x40516273 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 32 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x04516372 + TX_POLARITY_FLIP: 0xB6 + RX_LANE_MAP: 0x04152637 + RX_POLARITY_FLIP: 0x9A + ? + PC_PM_ID: 33 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x40157362 + TX_POLARITY_FLIP: 0xBE + RX_LANE_MAP: 0x51407362 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 34 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x73264051 + TX_POLARITY_FLIP: 0x41 + RX_LANE_MAP: 0x15043726 + RX_POLARITY_FLIP: 0x9A + + ? + PC_PM_ID: 35 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x26374051 + TX_POLARITY_FLIP: 0xE6 + RX_LANE_MAP: 0x62734501 + RX_POLARITY_FLIP: 0xAF + + ? + PC_PM_ID: 36 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x51406237 + TX_POLARITY_FLIP: 0x16 + RX_LANE_MAP: 0x15043276 + RX_POLARITY_FLIP: 0x50 + + ? + PC_PM_ID: 37 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x40621537 + TX_POLARITY_FLIP: 0xAE + RX_LANE_MAP: 0x05362147 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 38 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25701634 + TX_POLARITY_FLIP: 0xE7 + RX_LANE_MAP: 0x27143605 + RX_POLARITY_FLIP: 0xFC + + ? + PC_PM_ID: 39 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43617025 + TX_POLARITY_FLIP: 0x68 + RX_LANE_MAP: 0x05361247 + RX_POLARITY_FLIP: 0x12 + + ? + PC_PM_ID: 40 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x25701634 + TX_POLARITY_FLIP: 0xA6 + RX_LANE_MAP: 0x27143605 + RX_POLARITY_FLIP: 0xED + + ? + PC_PM_ID: 41 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64310725 + TX_POLARITY_FLIP: 0x3A + RX_LANE_MAP: 0x30562147 + RX_POLARITY_FLIP: 0x33 + + ? + PC_PM_ID: 42 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x20576413 + TX_POLARITY_FLIP: 0xD2 + RX_LANE_MAP: 0x50634172 + RX_POLARITY_FLIP: 0xBF + + ? + PC_PM_ID: 43 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x16340725 + TX_POLARITY_FLIP: 0xBB + RX_LANE_MAP: 0x12473056 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 44 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64317520 + TX_POLARITY_FLIP: 0x93 + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0xAA + + ? + PC_PM_ID: 45 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x31642075 + TX_POLARITY_FLIP: 0x77 + RX_LANE_MAP: 0x26534710 + RX_POLARITY_FLIP: 0x53 + + ? + PC_PM_ID: 46 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x34162507 + TX_POLARITY_FLIP: 0x11 + RX_LANE_MAP: 0x63504721 + RX_POLARITY_FLIP: 0x7B + + ? + PC_PM_ID: 47 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x34162075 + TX_POLARITY_FLIP: 0x53 + RX_LANE_MAP: 0x57304621 + RX_POLARITY_FLIP: 0x63 + + ? + PC_PM_ID: 48 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x34162507 + TX_POLARITY_FLIP: 0x77 + RX_LANE_MAP: 0x74503621 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 49 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43715260 + TX_POLARITY_FLIP: 0xAA + RX_LANE_MAP: 0x36051724 + RX_POLARITY_FLIP: 0x22 + + ? + PC_PM_ID: 50 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x30642175 + TX_POLARITY_FLIP: 0x77 + RX_LANE_MAP: 0x46305712 + RX_POLARITY_FLIP: 0x63 + + ? + PC_PM_ID: 51 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x23641570 + TX_POLARITY_FLIP: 0x2B + RX_LANE_MAP: 0x46305712 + RX_POLARITY_FLIP: 0xEB + + ? + PC_PM_ID: 52 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x43602175 + TX_POLARITY_FLIP: 0xA3 + RX_LANE_MAP: 0x46302715 + RX_POLARITY_FLIP: 0x12 + + ? + PC_PM_ID: 53 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x60437152 + TX_POLARITY_FLIP: 0x11 + RX_LANE_MAP: 0x05362147 + RX_POLARITY_FLIP: 0x53 + + ? + PC_PM_ID: 54 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64307521 + TX_POLARITY_FLIP: 0x6C + RX_LANE_MAP: 0x12473056 + RX_POLARITY_FLIP: 0x11 + + ? + PC_PM_ID: 55 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x64307521 + TX_POLARITY_FLIP: 0x39 + RX_LANE_MAP: 0x05364127 + RX_POLARITY_FLIP: 0x7B + + ? + PC_PM_ID: 56 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x60437152 + TX_POLARITY_FLIP: 0x11 + RX_LANE_MAP: 0x37042651 + RX_POLARITY_FLIP: 0x56 + + ? + PC_PM_ID: 57 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x06347152 + TX_POLARITY_FLIP: 0xE6 + RX_LANE_MAP: 0x63507421 + RX_POLARITY_FLIP: 0x12 + + ? + PC_PM_ID: 58 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x71254360 + TX_POLARITY_FLIP: 0xE7 + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0xED + + ? + PC_PM_ID: 59 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x06342571 + TX_POLARITY_FLIP: 0xFD + RX_LANE_MAP: 0x63507421 + RX_POLARITY_FLIP: 0x36 + + ? + PC_PM_ID: 60 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x72054163 + TX_POLARITY_FLIP: 0xDB + RX_LANE_MAP: 0x41725063 + RX_POLARITY_FLIP: 0x74 + + ? + PC_PM_ID: 61 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x41507362 + TX_POLARITY_FLIP: 0x99 + RX_LANE_MAP: 0x15047632 + RX_POLARITY_FLIP: 0x50 + + ? + PC_PM_ID: 62 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x36275104 + TX_POLARITY_FLIP: 0x69 + RX_LANE_MAP: 0x62730145 + RX_POLARITY_FLIP: 0xAF + + ? + PC_PM_ID: 63 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x37260415 + TX_POLARITY_FLIP: 0x55 + RX_LANE_MAP: 0x51402367 + RX_POLARITY_FLIP: 0x93 + + ? + PC_PM_ID: 64 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x04513726 + TX_POLARITY_FLIP: 0xBE + RX_LANE_MAP: 0x15046723 + RX_POLARITY_FLIP: 0x93 + + ? + PC_PM_ID: 65 + CORE_INDEX: 0 + : + TX_LANE_MAP_AUTO: 0 + RX_LANE_MAP_AUTO: 0 + TX_POLARITY_FLIP_AUTO: 0 + RX_POLARITY_FLIP_AUTO: 0 + TX_LANE_MAP: 0x3012 + TX_POLARITY_FLIP: 0 + RX_LANE_MAP: 0x3012 + RX_POLARITY_FLIP: 0 +... + +--- +device: + 0: + PC_PORT_PHYS_MAP: + ? + PORT_ID: 0 + : + PC_PHYS_PORT_ID: 0 + ? + PORT_ID: 33 + : + PC_PHYS_PORT_ID: 259 + ? + PORT_ID: 67 + : + PC_PHYS_PORT_ID: 260 + ? + PORT_ID: 101 + : + PC_PHYS_PORT_ID: 261 + ? + PORT_ID: 135 + : + PC_PHYS_PORT_ID: 262 + ? + PORT_ID: 169 + : + PC_PHYS_PORT_ID: 263 + ? + PORT_ID: 203 + : + PC_PHYS_PORT_ID: 264 + ? + PORT_ID: 237 + : + PC_PHYS_PORT_ID: 265 + ? + PORT_ID: 271 + : + PC_PHYS_PORT_ID: 266 + ? + PORT_ID: 1 + : + PC_PHYS_PORT_ID: 1 + ? + PORT_ID: 3 + : + PC_PHYS_PORT_ID: 3 + ? + PORT_ID: 5 + : + PC_PHYS_PORT_ID: 5 + ? + PORT_ID: 7 + : + PC_PHYS_PORT_ID: 7 + ? + PORT_ID: 9 + : + PC_PHYS_PORT_ID: 9 + ? + PORT_ID: 11 + : + PC_PHYS_PORT_ID: 11 + ? + PORT_ID: 13 + : + PC_PHYS_PORT_ID: 13 + ? + PORT_ID: 15 + : + PC_PHYS_PORT_ID: 15 + ? + PORT_ID: 17 + : + PC_PHYS_PORT_ID: 17 + ? + PORT_ID: 19 + : + PC_PHYS_PORT_ID: 19 + ? + PORT_ID: 21 + : + PC_PHYS_PORT_ID: 21 + ? + PORT_ID: 23 + : + PC_PHYS_PORT_ID: 23 + ? + PORT_ID: 25 + : + PC_PHYS_PORT_ID: 25 + ? + PORT_ID: 27 + : + PC_PHYS_PORT_ID: 27 + ? + PORT_ID: 29 + : + PC_PHYS_PORT_ID: 29 + ? + PORT_ID: 31 + : + PC_PHYS_PORT_ID: 31 + ? + PORT_ID: 34 + : + PC_PHYS_PORT_ID: 33 + ? + PORT_ID: 36 + : + PC_PHYS_PORT_ID: 35 + ? + PORT_ID: 38 + : + PC_PHYS_PORT_ID: 37 + ? + PORT_ID: 40 + : + PC_PHYS_PORT_ID: 39 + ? + PORT_ID: 42 + : + PC_PHYS_PORT_ID: 41 + ? + PORT_ID: 44 + : + PC_PHYS_PORT_ID: 43 + ? + PORT_ID: 46 + : + PC_PHYS_PORT_ID: 45 + ? + PORT_ID: 48 + : + PC_PHYS_PORT_ID: 47 + ? + PORT_ID: 51 + : + PC_PHYS_PORT_ID: 49 + ? + PORT_ID: 53 + : + PC_PHYS_PORT_ID: 51 + ? + PORT_ID: 55 + : + PC_PHYS_PORT_ID: 53 + ? + PORT_ID: 57 + : + PC_PHYS_PORT_ID: 55 + ? + PORT_ID: 59 + : + PC_PHYS_PORT_ID: 57 + ? + PORT_ID: 61 + : + PC_PHYS_PORT_ID: 59 + ? + PORT_ID: 63 + : + PC_PHYS_PORT_ID: 61 + ? + PORT_ID: 65 + : + PC_PHYS_PORT_ID: 63 + ? + PORT_ID: 68 + : + PC_PHYS_PORT_ID: 65 + ? + PORT_ID: 70 + : + PC_PHYS_PORT_ID: 67 + ? + PORT_ID: 72 + : + PC_PHYS_PORT_ID: 69 + ? + PORT_ID: 74 + : + PC_PHYS_PORT_ID: 71 + ? + PORT_ID: 76 + : + PC_PHYS_PORT_ID: 73 + ? + PORT_ID: 78 + : + PC_PHYS_PORT_ID: 75 + ? + PORT_ID: 80 + : + PC_PHYS_PORT_ID: 77 + ? + PORT_ID: 82 + : + PC_PHYS_PORT_ID: 79 + ? + PORT_ID: 85 + : + PC_PHYS_PORT_ID: 81 + ? + PORT_ID: 87 + : + PC_PHYS_PORT_ID: 83 + ? + PORT_ID: 89 + : + PC_PHYS_PORT_ID: 85 + ? + PORT_ID: 91 + : + PC_PHYS_PORT_ID: 87 + ? + PORT_ID: 93 + : + PC_PHYS_PORT_ID: 89 + ? + PORT_ID: 95 + : + PC_PHYS_PORT_ID: 91 + ? + PORT_ID: 97 + : + PC_PHYS_PORT_ID: 93 + ? + PORT_ID: 99 + : + PC_PHYS_PORT_ID: 95 + ? + PORT_ID: 102 + : + PC_PHYS_PORT_ID: 97 + ? + PORT_ID: 104 + : + PC_PHYS_PORT_ID: 99 + ? + PORT_ID: 106 + : + PC_PHYS_PORT_ID: 101 + ? + PORT_ID: 108 + : + PC_PHYS_PORT_ID: 103 + ? + PORT_ID: 110 + : + PC_PHYS_PORT_ID: 105 + ? + PORT_ID: 112 + : + PC_PHYS_PORT_ID: 107 + ? + PORT_ID: 114 + : + PC_PHYS_PORT_ID: 109 + ? + PORT_ID: 116 + : + PC_PHYS_PORT_ID: 111 + ? + PORT_ID: 119 + : + PC_PHYS_PORT_ID: 113 + ? + PORT_ID: 121 + : + PC_PHYS_PORT_ID: 115 + ? + PORT_ID: 123 + : + PC_PHYS_PORT_ID: 117 + ? + PORT_ID: 125 + : + PC_PHYS_PORT_ID: 119 + ? + PORT_ID: 127 + : + PC_PHYS_PORT_ID: 121 + ? + PORT_ID: 129 + : + PC_PHYS_PORT_ID: 123 + ? + PORT_ID: 131 + : + PC_PHYS_PORT_ID: 125 + ? + PORT_ID: 133 + : + PC_PHYS_PORT_ID: 127 + ? + PORT_ID: 136 + : + PC_PHYS_PORT_ID: 129 + ? + PORT_ID: 138 + : + PC_PHYS_PORT_ID: 131 + ? + PORT_ID: 140 + : + PC_PHYS_PORT_ID: 133 + ? + PORT_ID: 142 + : + PC_PHYS_PORT_ID: 135 + ? + PORT_ID: 144 + : + PC_PHYS_PORT_ID: 137 + ? + PORT_ID: 146 + : + PC_PHYS_PORT_ID: 139 + ? + PORT_ID: 148 + : + PC_PHYS_PORT_ID: 141 + ? + PORT_ID: 150 + : + PC_PHYS_PORT_ID: 143 + ? + PORT_ID: 153 + : + PC_PHYS_PORT_ID: 145 + ? + PORT_ID: 155 + : + PC_PHYS_PORT_ID: 147 + ? + PORT_ID: 157 + : + PC_PHYS_PORT_ID: 149 + ? + PORT_ID: 159 + : + PC_PHYS_PORT_ID: 151 + ? + PORT_ID: 161 + : + PC_PHYS_PORT_ID: 153 + ? + PORT_ID: 163 + : + PC_PHYS_PORT_ID: 155 + ? + PORT_ID: 165 + : + PC_PHYS_PORT_ID: 157 + ? + PORT_ID: 167 + : + PC_PHYS_PORT_ID: 159 + ? + PORT_ID: 170 + : + PC_PHYS_PORT_ID: 161 + ? + PORT_ID: 172 + : + PC_PHYS_PORT_ID: 163 + ? + PORT_ID: 174 + : + PC_PHYS_PORT_ID: 165 + ? + PORT_ID: 176 + : + PC_PHYS_PORT_ID: 167 + ? + PORT_ID: 178 + : + PC_PHYS_PORT_ID: 169 + ? + PORT_ID: 180 + : + PC_PHYS_PORT_ID: 171 + ? + PORT_ID: 182 + : + PC_PHYS_PORT_ID: 173 + ? + PORT_ID: 184 + : + PC_PHYS_PORT_ID: 175 + ? + PORT_ID: 187 + : + PC_PHYS_PORT_ID: 177 + ? + PORT_ID: 189 + : + PC_PHYS_PORT_ID: 179 + ? + PORT_ID: 191 + : + PC_PHYS_PORT_ID: 181 + ? + PORT_ID: 193 + : + PC_PHYS_PORT_ID: 183 + ? + PORT_ID: 195 + : + PC_PHYS_PORT_ID: 185 + ? + PORT_ID: 197 + : + PC_PHYS_PORT_ID: 187 + ? + PORT_ID: 199 + : + PC_PHYS_PORT_ID: 189 + ? + PORT_ID: 201 + : + PC_PHYS_PORT_ID: 191 + ? + PORT_ID: 204 + : + PC_PHYS_PORT_ID: 193 + ? + PORT_ID: 206 + : + PC_PHYS_PORT_ID: 195 + ? + PORT_ID: 208 + : + PC_PHYS_PORT_ID: 197 + ? + PORT_ID: 210 + : + PC_PHYS_PORT_ID: 199 + ? + PORT_ID: 212 + : + PC_PHYS_PORT_ID: 201 + ? + PORT_ID: 214 + : + PC_PHYS_PORT_ID: 203 + ? + PORT_ID: 216 + : + PC_PHYS_PORT_ID: 205 + ? + PORT_ID: 218 + : + PC_PHYS_PORT_ID: 207 + ? + PORT_ID: 221 + : + PC_PHYS_PORT_ID: 209 + ? + PORT_ID: 223 + : + PC_PHYS_PORT_ID: 211 + ? + PORT_ID: 225 + : + PC_PHYS_PORT_ID: 213 + ? + PORT_ID: 227 + : + PC_PHYS_PORT_ID: 215 + ? + PORT_ID: 229 + : + PC_PHYS_PORT_ID: 217 + ? + PORT_ID: 231 + : + PC_PHYS_PORT_ID: 219 + ? + PORT_ID: 233 + : + PC_PHYS_PORT_ID: 221 + ? + PORT_ID: 235 + : + PC_PHYS_PORT_ID: 223 + ? + PORT_ID: 238 + : + PC_PHYS_PORT_ID: 225 + ? + PORT_ID: 240 + : + PC_PHYS_PORT_ID: 227 + ? + PORT_ID: 242 + : + PC_PHYS_PORT_ID: 229 + ? + PORT_ID: 244 + : + PC_PHYS_PORT_ID: 231 + ? + PORT_ID: 246 + : + PC_PHYS_PORT_ID: 233 + ? + PORT_ID: 248 + : + PC_PHYS_PORT_ID: 235 + ? + PORT_ID: 250 + : + PC_PHYS_PORT_ID: 237 + ? + PORT_ID: 252 + : + PC_PHYS_PORT_ID: 239 + ? + PORT_ID: 255 + : + PC_PHYS_PORT_ID: 241 + ? + PORT_ID: 257 + : + PC_PHYS_PORT_ID: 243 + ? + PORT_ID: 259 + : + PC_PHYS_PORT_ID: 245 + ? + PORT_ID: 261 + : + PC_PHYS_PORT_ID: 247 + ? + PORT_ID: 263 + : + PC_PHYS_PORT_ID: 249 + ? + PORT_ID: 265 + : + PC_PHYS_PORT_ID: 251 + ? + PORT_ID: 267 + : + PC_PHYS_PORT_ID: 253 + ? + PORT_ID: 269 + : + PC_PHYS_PORT_ID: 255 +... + +--- +device: + 0: + PC_PORT: + ? + PORT_ID: [0] + : + ENABLE: 0 + SPEED: 10000 + NUM_LANES: 1 + ? + PORT_ID: [1, 3, 5, 7, 9, 11, 13, 15, + 17, 19, 21, 23, 25, 27, 29, 31, + 34, 36, 38, 40, 42, 44, 46, 48, + 51, 53, 55, 57, 59, 61, 63, 65, + 68, 70, 72, 74, 76, 78, 80, 82, + 85, 87, 89, 91, 93, 95, 97, 99, + 102, 104, 106, 108, 110, 112, 114, 116, + 119, 121, 123, 125, 127, 129, 131, 133, + 136, 138, 140, 142, 144, 146, 148, 150, + 153, 155, 157, 159, 161, 163, 165, 167, + 170, 172, 174, 176, 178, 180, 182, 184, + 187, 189, 191, 193, 195, 197, 199, 201, + 204, 206, 208, 210, 212, 214, 216, 218, + 221, 223, 225, 227, 229, 231, 233, 235, + 238, 240, 242, 244, 246, 248, 250, 252, + 255, 257, 259, 261, 263, 265, 267, 269] + : + ENABLE: 0 + SPEED: 200000 + NUM_LANES: 4 + FEC_MODE: PC_FEC_RS544_2XN + MAX_FRAME_SIZE: 9416 + LINK_TRAINING: 0 +... + +--- +device: + 0: + TM_SCHEDULER_CONFIG: + NUM_MC_Q: NUM_MC_Q_4 +... + +--- +device: + 0: + PC_PMD_FIRMWARE: + ? + PORT_ID: [1, 3, 5, 7, 9, 11, 13, 15, + 17, 19, 21, 23, 25, 27, 29, 31, + 34, 36, 38, 40, 42, 44, 46, 48, + 51, 53, 55, 57, 59, 61, 63, 65, + 68, 70, 72, 74, 76, 78, 80, 82, + 85, 87, 89, 91, 93, 95, 97, 99, + 102, 104, 106, 108, 110, 112, 114, 116, + 119, 121, 123, 125, 127, 129, 131, 133, + 136, 138, 140, 142, 144, 146, 148, 150, + 153, 155, 157, 159, 161, 163, 165, 167, + 170, 172, 174, 176, 178, 180, 182, 184, + 187, 189, 191, 193, 195, 197, 199, 201, + 204, 206, 208, 210, 212, 214, 216, 218, + 221, 223, 225, 227, 229, 231, 233, 235, + 238, 240, 242, 244, 246, 248, 250, 252, + 255, 257, 259, 261, 263, 265, 267, 269] + : + MEDIUM_TYPE_AUTO: 0 + MEDIUM_TYPE: PC_PHY_MEDIUM_COPPER +... + +--- +device: + 0: + FP_CONFIG: + FP_ING_OPERMODE: GLOBAL_PIPE_AWARE +... + +--- +bcm_device: + 0: + global: + bcm_tunnel_term_compatible_mode: 1 + vlan_flooding_l2mc_num_reserved: 2048 + l3_alpm_template: 1 + l3_alpm2_bnk_threshold: 100 + uft_mode: 1 + l3_enable: 1 + l2_hitbit_enable: 0 + pktio_mode: 1 + riot_overlay_l3_intf_mem_size: 4096 + riot_overlay_l3_egress_mem_size: 8192 + l3_ecmp_member_first_lkup_mem_size: 8192 +... + +--- +bcm_device: + 0: + port: + "*": + encap_mode: IEEE + dport_map_enable: 1 + 85: + dport_map_port: 1 + 87: + dport_map_port: 2 + 93: + dport_map_port: 3 + 95: + dport_map_port: 4 + 97: + dport_map_port: 5 + 99: + dport_map_port: 6 + 89: + dport_map_port: 7 + 91: + dport_map_port: 8 + 42: + dport_map_port: 9 + 44: + dport_map_port: 10 + 38: + dport_map_port: 11 + 40: + dport_map_port: 12 + 46: + dport_map_port: 13 + 48: + dport_map_port: 14 + 34: + dport_map_port: 15 + 36: + dport_map_port: 16 + 233: + dport_map_port: 17 + 235: + dport_map_port: 18 + 221: + dport_map_port: 19 + 223: + dport_map_port: 20 + 229: + dport_map_port: 21 + 231: + dport_map_port: 22 + 225: + dport_map_port: 23 + 227: + dport_map_port: 24 + 174: + dport_map_port: 25 + 176: + dport_map_port: 26 + 182: + dport_map_port: 27 + 184: + dport_map_port: 28 + 170: + dport_map_port: 29 + 172: + dport_map_port: 30 + 178: + dport_map_port: 31 + 180: + dport_map_port: 32 + 9: + dport_map_port: 33 + 11: + dport_map_port: 34 + 13: + dport_map_port: 35 + 15: + dport_map_port: 36 + 21: + dport_map_port: 37 + 23: + dport_map_port: 38 + 29: + dport_map_port: 39 + 31: + dport_map_port: 40 + 106: + dport_map_port: 41 + 108: + dport_map_port: 42 + 114: + dport_map_port: 43 + 116: + dport_map_port: 44 + 119: + dport_map_port: 45 + 121: + dport_map_port: 46 + 123: + dport_map_port: 47 + 125: + dport_map_port: 48 + 144: + dport_map_port: 49 + 146: + dport_map_port: 50 + 148: + dport_map_port: 51 + 150: + dport_map_port: 52 + 153: + dport_map_port: 53 + 155: + dport_map_port: 54 + 161: + dport_map_port: 55 + 163: + dport_map_port: 56 + 238: + dport_map_port: 57 + 240: + dport_map_port: 58 + 246: + dport_map_port: 59 + 248: + dport_map_port: 60 + 255: + dport_map_port: 61 + 257: + dport_map_port: 62 + 259: + dport_map_port: 63 + 261: + dport_map_port: 64 + 5: + dport_map_port: 65 + 7: + dport_map_port: 66 + 1: + dport_map_port: 67 + 3: + dport_map_port: 68 + 17: + dport_map_port: 69 + 19: + dport_map_port: 70 + 25: + dport_map_port: 71 + 27: + dport_map_port: 72 + 102: + dport_map_port: 73 + 104: + dport_map_port: 74 + 110: + dport_map_port: 75 + 112: + dport_map_port: 76 + 131: + dport_map_port: 77 + 133: + dport_map_port: 78 + 127: + dport_map_port: 79 + 129: + dport_map_port: 80 + 140: + dport_map_port: 81 + 142: + dport_map_port: 82 + 136: + dport_map_port: 83 + 138: + dport_map_port: 84 + 157: + dport_map_port: 85 + 159: + dport_map_port: 86 + 165: + dport_map_port: 87 + 167: + dport_map_port: 88 + 242: + dport_map_port: 89 + 244: + dport_map_port: 90 + 250: + dport_map_port: 91 + 252: + dport_map_port: 92 + 267: + dport_map_port: 93 + 269: + dport_map_port: 94 + 263: + dport_map_port: 95 + 265: + dport_map_port: 96 + 68: + dport_map_port: 97 + 70: + dport_map_port: 98 + 76: + dport_map_port: 99 + 78: + dport_map_port: 100 + 72: + dport_map_port: 101 + 74: + dport_map_port: 102 + 80: + dport_map_port: 103 + 82: + dport_map_port: 104 + 59: + dport_map_port: 105 + 61: + dport_map_port: 106 + 55: + dport_map_port: 107 + 57: + dport_map_port: 108 + 63: + dport_map_port: 109 + 65: + dport_map_port: 110 + 51: + dport_map_port: 111 + 53: + dport_map_port: 112 + 216: + dport_map_port: 113 + 218: + dport_map_port: 114 + 204: + dport_map_port: 115 + 206: + dport_map_port: 116 + 212: + dport_map_port: 117 + 214: + dport_map_port: 118 + 208: + dport_map_port: 119 + 210: + dport_map_port: 120 + 187: + dport_map_port: 121 + 189: + dport_map_port: 122 + 195: + dport_map_port: 123 + 197: + dport_map_port: 124 + 191: + dport_map_port: 125 + 193: + dport_map_port: 126 + 199: + dport_map_port: 127 + 201: + dport_map_port: 128 +... diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/port_config.ini b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/port_config.ini new file mode 100755 index 000000000000..e1ec63f3cc53 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/port_config.ini @@ -0,0 +1,128 @@ +# name lanes alias index speed +Ethernet1 81,82,83,84 Eth200GE0/1 1 200000 +Ethernet2 83,84,85,86 Eth200GE0/2 2 200000 +Ethernet3 89,90,91,92 Eth200GE0/3 3 200000 +Ethernet4 91,92,93,94 Eth200GE0/4 4 200000 +Ethernet5 93,94,95,96 Eth200GE0/5 5 200000 +Ethernet6 95,96,97,98 Eth200GE0/6 6 200000 +Ethernet7 85,86,87,88 Eth200GE0/7 7 200000 +Ethernet8 87,88,89,90 Eth200GE0/8 8 200000 +Ethernet9 41,42,43,44 Eth200GE0/9 9 200000 +Ethernet10 43,44,45,46 Eth200GE0/10 10 200000 +Ethernet11 37,38,39,40 Eth200GE0/11 11 200000 +Ethernet12 39,40,41,42 Eth200GE0/12 12 200000 +Ethernet13 45,46,47,48 Eth200GE0/13 13 200000 +Ethernet14 47,48,49,50 Eth200GE0/14 14 200000 +Ethernet15 33,34,35,36 Eth200GE0/15 15 200000 +Ethernet16 35,36,37,38 Eth200GE0/16 16 200000 +Ethernet17 221,222,223,224 Eth200GE0/17 17 200000 +Ethernet18 223,224,225,226 Eth200GE0/18 18 200000 +Ethernet19 209,210,211,212 Eth200GE0/19 19 200000 +Ethernet20 211,212,213,214 Eth200GE0/20 20 200000 +Ethernet21 217,218,219,220 Eth200GE0/21 21 200000 +Ethernet22 219,220,221,222 Eth200GE0/22 22 200000 +Ethernet23 213,214,215,216 Eth200GE0/23 23 200000 +Ethernet24 215,216,217,218 Eth200GE0/24 24 200000 +Ethernet25 165,166,167,168 Eth200GE0/25 25 200000 +Ethernet26 167,168,169,170 Eth200GE0/26 26 200000 +Ethernet27 173,174,175,176 Eth200GE0/27 27 200000 +Ethernet28 175,176,177,178 Eth200GE0/28 28 200000 +Ethernet29 161,162,163,164 Eth200GE0/29 29 200000 +Ethernet30 163,164,165,166 Eth200GE0/30 30 200000 +Ethernet31 169,170,171,172 Eth200GE0/31 31 200000 +Ethernet32 171,172,173,174 Eth200GE0/32 32 200000 +Ethernet33 9,10,11,12 Eth200GE0/33 33 200000 +Ethernet34 11,12,13,14 Eth200GE0/34 34 200000 +Ethernet35 13,14,15,16 Eth200GE0/35 35 200000 +Ethernet36 15,16,17,18 Eth200GE0/36 36 200000 +Ethernet37 21,22,23,24 Eth200GE0/37 37 200000 +Ethernet38 23,24,25,26 Eth200GE0/38 38 200000 +Ethernet39 29,30,31,32 Eth200GE0/39 39 200000 +Ethernet40 31,32,33,34 Eth200GE0/40 40 200000 +Ethernet41 101,102,103,104 Eth200GE0/41 41 200000 +Ethernet42 103,104,105,106 Eth200GE0/42 42 200000 +Ethernet43 109,110,111,112 Eth200GE0/43 43 200000 +Ethernet44 111,112,113,114 Eth200GE0/44 44 200000 +Ethernet45 113,114,115,116 Eth200GE0/45 45 200000 +Ethernet46 115,116,117,118 Eth200GE0/46 46 200000 +Ethernet47 117,118,119,120 Eth200GE0/47 47 200000 +Ethernet48 119,120,121,122 Eth200GE0/48 48 200000 +Ethernet49 137,138,139,140 Eth200GE0/49 49 200000 +Ethernet50 139,140,141,142 Eth200GE0/50 50 200000 +Ethernet51 141,142,143,144 Eth200GE0/51 51 200000 +Ethernet52 143,144,145,146 Eth200GE0/52 52 200000 +Ethernet53 145,146,147,148 Eth200GE0/53 53 200000 +Ethernet54 147,148,149,150 Eth200GE0/54 54 200000 +Ethernet55 153,154,155,156 Eth200GE0/55 55 200000 +Ethernet56 155,156,157,158 Eth200GE0/56 56 200000 +Ethernet57 225,226,227,228 Eth200GE0/57 57 200000 +Ethernet58 227,228,229,230 Eth200GE0/58 58 200000 +Ethernet59 233,234,235,236 Eth200GE0/59 59 200000 +Ethernet60 235,236,237,238 Eth200GE0/60 60 200000 +Ethernet61 241,242,243,244 Eth200GE0/61 61 200000 +Ethernet62 243,244,245,246 Eth200GE0/62 62 200000 +Ethernet63 245,246,247,248 Eth200GE0/63 63 200000 +Ethernet64 247,248,249,250 Eth200GE0/64 64 200000 +Ethernet65 5,6,7,8 Eth200GE0/65 65 200000 +Ethernet66 7,8,9,10 Eth200GE0/66 66 200000 +Ethernet67 1,2,3,4 Eth200GE0/67 67 200000 +Ethernet68 3,4,5,6 Eth200GE0/68 68 200000 +Ethernet69 17,18,19,20 Eth200GE0/69 69 200000 +Ethernet70 19,20,21,22 Eth200GE0/70 70 200000 +Ethernet71 25,26,27,28 Eth200GE0/71 71 200000 +Ethernet72 27,28,29,30 Eth200GE0/72 72 200000 +Ethernet73 97,98,99,100 Eth200GE0/73 73 200000 +Ethernet74 99,100,101,102 Eth200GE0/74 74 200000 +Ethernet75 105,106,107,108 Eth200GE0/75 75 200000 +Ethernet76 107,108,109,110 Eth200GE0/76 76 200000 +Ethernet77 125,126,127,128 Eth200GE0/77 77 200000 +Ethernet78 127,128,129,130 Eth200GE0/78 78 200000 +Ethernet79 121,122,123,124 Eth200GE0/79 79 200000 +Ethernet80 123,124,125,126 Eth200GE0/80 80 200000 +Ethernet81 133,134,135,136 Eth200GE0/81 81 200000 +Ethernet82 135,136,137,138 Eth200GE0/82 82 200000 +Ethernet83 129,130,131,132 Eth200GE0/83 83 200000 +Ethernet84 131,132,133,134 Eth200GE0/84 84 200000 +Ethernet85 149,150,151,152 Eth200GE0/85 85 200000 +Ethernet86 151,152,153,154 Eth200GE0/86 86 200000 +Ethernet87 157,158,159,160 Eth200GE0/87 87 200000 +Ethernet88 159,160,161,162 Eth200GE0/88 88 200000 +Ethernet89 229,230,231,232 Eth200GE0/89 89 200000 +Ethernet90 231,232,233,234 Eth200GE0/90 90 200000 +Ethernet91 237,238,239,240 Eth200GE0/91 91 200000 +Ethernet92 239,240,241,242 Eth200GE0/92 92 200000 +Ethernet93 253,254,255,256 Eth200GE0/93 93 200000 +Ethernet94 255,256,257,258 Eth200GE0/94 94 200000 +Ethernet95 249,250,251,252 Eth200GE0/95 95 200000 +Ethernet96 251,252,253,254 Eth200GE0/96 96 200000 +Ethernet97 65,66,67,68 Eth200GE0/97 97 200000 +Ethernet98 67,68,69,70 Eth200GE0/98 98 200000 +Ethernet99 73,74,75,76 Eth200GE0/99 99 200000 +Ethernet100 75,76,77,78 Eth200GE0/100 100 200000 +Ethernet101 69,70,71,72 Eth200GE0/101 101 200000 +Ethernet102 71,72,73,74 Eth200GE0/102 102 200000 +Ethernet103 77,78,79,80 Eth200GE0/103 103 200000 +Ethernet104 79,80,81,82 Eth200GE0/104 104 200000 +Ethernet105 57,58,59,60 Eth200GE0/105 105 200000 +Ethernet106 59,60,61,62 Eth200GE0/106 106 200000 +Ethernet107 53,54,55,56 Eth200GE0/107 107 200000 +Ethernet108 55,56,57,58 Eth200GE0/108 108 200000 +Ethernet109 61,62,63,64 Eth200GE0/109 109 200000 +Ethernet110 63,64,65,66 Eth200GE0/110 110 200000 +Ethernet111 49,50,51,52 Eth200GE0/111 111 200000 +Ethernet112 51,52,53,54 Eth200GE0/112 112 200000 +Ethernet113 205,206,207,208 Eth200GE0/113 113 200000 +Ethernet114 207,208,209,210 Eth200GE0/114 114 200000 +Ethernet115 193,194,195,196 Eth200GE0/115 115 200000 +Ethernet116 195,196,197,198 Eth200GE0/116 116 200000 +Ethernet117 201,202,203,204 Eth200GE0/117 117 200000 +Ethernet118 203,204,205,206 Eth200GE0/118 118 200000 +Ethernet119 197,198,199,200 Eth200GE0/119 119 200000 +Ethernet120 199,200,201,202 Eth200GE0/120 120 200000 +Ethernet121 177,178,179,180 Eth200GE0/121 121 200000 +Ethernet122 179,180,181,182 Eth200GE0/122 122 200000 +Ethernet123 185,186,187,188 Eth200GE0/123 123 200000 +Ethernet124 187,188,189,190 Eth200GE0/124 124 200000 +Ethernet125 181,182,183,184 Eth200GE0/125 125 200000 +Ethernet126 183,184,185,186 Eth200GE0/126 126 200000 +Ethernet127 189,190,191,192 Eth200GE0/127 127 200000 diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/sai.profile b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/sai.profile new file mode 100755 index 000000000000..a4c4be63faf2 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/TCS9400-128CC/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/TCS9400-128CC.yml diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/config_db.TCS9400-128CC.json b/device/tencent/x86_64-tencent_tcs9400-r0/config_db.TCS9400-128CC.json new file mode 100755 index 000000000000..f2e9673954b7 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/config_db.TCS9400-128CC.json @@ -0,0 +1,1028 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hwsku": "TCS9400-128CC", + "platform": "x86_64-tencent_tcs9400-r0", + "mac": "c0:b8:e6:ff:89:9a", + "hostname": "sonic" + } + }, + "PORT": { + "Ethernet1": { + "lanes": "81,82,83,84", + "alias": "Eth200GE0/1", + "index": "1", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet2": { + "lanes": "83,84,85,86", + "alias": "Eth200GE0/2", + "index": "2", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet3": { + "lanes": "89,90,91,92", + "alias": "Eth200GE0/3", + "index": "3", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet4": { + "lanes": "91,92,93,94", + "alias": "Eth200GE0/4", + "index": "4", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet5": { + "lanes": "93,94,95,96", + "alias": "Eth200GE0/5", + "index": "5", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet6": { + "lanes": "95,96,97,98", + "alias": "Eth200GE0/6", + "index": "6", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet7": { + "lanes": "85,86,87,88", + "alias": "Eth200GE0/7", + "index": "7", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet8": { + "lanes": "87,88,89,90", + "alias": "Eth200GE0/8", + "index": "8", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet9": { + "lanes": "41,42,43,44", + "alias": "Eth200GE0/9", + "index": "9", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet10": { + "lanes": "43,44,45,46", + "alias": "Eth200GE0/10", + "index": "10", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet11": { + "lanes": "37,38,39,40", + "alias": "Eth200GE0/11", + "index": "11", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet12": { + "lanes": "39,40,41,42", + "alias": "Eth200GE0/12", + "index": "12", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet13": { + "lanes": "45,46,47,48", + "alias": "Eth200GE0/13", + "index": "13", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet14": { + "lanes": "47,48,49,50", + "alias": "Eth200GE0/14", + "index": "14", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet15": { + "lanes": "33,34,35,36", + "alias": "Eth200GE0/15", + "index": "15", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet16": { + "lanes": "35,36,37,38", + "alias": "Eth200GE0/16", + "index": "16", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet17": { + "lanes": "221,222,223,224", + "alias": "Eth200GE0/17", + "index": "17", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet18": { + "lanes": "223,224,225,226", + "alias": "Eth200GE0/18", + "index": "18", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet19": { + "lanes": "209,210,211,212", + "alias": "Eth200GE0/19", + "index": "19", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet20": { + "lanes": "211,212,213,214", + "alias": "Eth200GE0/20", + "index": "20", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet21": { + "lanes": "217,218,219,220", + "alias": "Eth200GE0/21", + "index": "21", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet22": { + "lanes": "219,220,221,222", + "alias": "Eth200GE0/22", + "index": "22", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet23": { + "lanes": "213,214,215,216", + "alias": "Eth200GE0/23", + "index": "23", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet24": { + "lanes": "215,216,217,218", + "alias": "Eth200GE0/24", + "index": "24", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet25": { + "lanes": "165,166,167,168", + "alias": "Eth200GE0/25", + "index": "25", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet26": { + "lanes": "167,168,169,170", + "alias": "Eth200GE0/26", + "index": "26", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet27": { + "lanes": "173,174,175,176", + "alias": "Eth200GE0/27", + "index": "27", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet28": { + "lanes": "175,176,177,178", + "alias": "Eth200GE0/28", + "index": "28", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet29": { + "lanes": "161,162,163,164", + "alias": "Eth200GE0/29", + "index": "29", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet30": { + "lanes": "163,164,165,166", + "alias": "Eth200GE0/30", + "index": "30", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet31": { + "lanes": "169,170,171,172", + "alias": "Eth200GE0/31", + "index": "31", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet32": { + "lanes": "171,172,173,174", + "alias": "Eth200GE0/32", + "index": "32", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet33": { + "lanes": "9,10,11,12", + "alias": "Eth200GE0/33", + "index": "33", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet34": { + "lanes": "11,12,13,14", + "alias": "Eth200GE0/34", + "index": "34", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet35": { + "lanes": "13,14,15,16", + "alias": "Eth200GE0/35", + "index": "35", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet36": { + "lanes": "15,16,17,18", + "alias": "Eth200GE0/36", + "index": "36", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet37": { + "lanes": "21,22,23,24", + "alias": "Eth200GE0/37", + "index": "37", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet38": { + "lanes": "23,24,25,26", + "alias": "Eth200GE0/38", + "index": "38", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet39": { + "lanes": "29,30,31,32", + "alias": "Eth200GE0/39", + "index": "39", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet40": { + "lanes": "31,32,33,34", + "alias": "Eth200GE0/40", + "index": "40", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet41": { + "lanes": "101,102,103,104", + "alias": "Eth200GE0/41", + "index": "41", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet42": { + "lanes": "103,104,105,106", + "alias": "Eth200GE0/42", + "index": "42", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet43": { + "lanes": "109,110,111,112", + "alias": "Eth200GE0/43", + "index": "43", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet44": { + "lanes": "111,112,113,114", + "alias": "Eth200GE0/44", + "index": "44", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet45": { + "lanes": "113,114,115,116", + "alias": "Eth200GE0/45", + "index": "45", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet46": { + "lanes": "115,116,117,118", + "alias": "Eth200GE0/46", + "index": "46", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet47": { + "lanes": "117,118,119,120", + "alias": "Eth200GE0/47", + "index": "47", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet48": { + "lanes": "119,120,121,122", + "alias": "Eth200GE0/48", + "index": "48", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet49": { + "lanes": "137,138,139,140", + "alias": "Eth200GE0/49", + "index": "49", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet50": { + "lanes": "139,140,141,142", + "alias": "Eth200GE0/50", + "index": "50", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet51": { + "lanes": "141,142,143,144", + "alias": "Eth200GE0/51", + "index": "51", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet52": { + "lanes": "143,144,145,146", + "alias": "Eth200GE0/52", + "index": "52", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet53": { + "lanes": "145,146,147,148", + "alias": "Eth200GE0/53", + "index": "53", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet54": { + "lanes": "147,148,149,150", + "alias": "Eth200GE0/54", + "index": "54", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet55": { + "lanes": "153,154,155,156", + "alias": "Eth200GE0/55", + "index": "55", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet56": { + "lanes": "155,156,157,158", + "alias": "Eth200GE0/56", + "index": "56", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet57": { + "lanes": "225,226,227,228", + "alias": "Eth200GE0/57", + "index": "57", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet58": { + "lanes": "227,228,229,230", + "alias": "Eth200GE0/58", + "index": "58", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet59": { + "lanes": "233,234,235,236", + "alias": "Eth200GE0/59", + "index": "59", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet60": { + "lanes": "235,236,237,238", + "alias": "Eth200GE0/60", + "index": "60", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet61": { + "lanes": "241,242,243,244", + "alias": "Eth200GE0/61", + "index": "61", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet62": { + "lanes": "243,244,245,246", + "alias": "Eth200GE0/62", + "index": "62", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet63": { + "lanes": "245,246,247,248", + "alias": "Eth200GE0/63", + "index": "63", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet64": { + "lanes": "247,248,249,250", + "alias": "Eth200GE0/64", + "index": "64", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet65": { + "lanes": "5,6,7,8", + "alias": "Eth200GE0/65", + "index": "65", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet66": { + "lanes": "7,8,9,10", + "alias": "Eth200GE0/66", + "index": "66", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet67": { + "lanes": "1,2,3,4", + "alias": "Eth200GE0/67", + "index": "67", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet68": { + "lanes": "3,4,5,6", + "alias": "Eth200GE0/68", + "index": "68", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet69": { + "lanes": "17,18,19,20", + "alias": "Eth200GE0/69", + "index": "69", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet70": { + "lanes": "19,20,21,22", + "alias": "Eth200GE0/70", + "index": "70", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet71": { + "lanes": "25,26,27,28", + "alias": "Eth200GE0/71", + "index": "71", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet72": { + "lanes": "27,28,29,30", + "alias": "Eth200GE0/72", + "index": "72", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet73": { + "lanes": "97,98,99,100", + "alias": "Eth200GE0/73", + "index": "73", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet74": { + "lanes": "99,100,101,102", + "alias": "Eth200GE0/74", + "index": "74", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet75": { + "lanes": "105,106,107,108", + "alias": "Eth200GE0/75", + "index": "75", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet76": { + "lanes": "107,108,109,110", + "alias": "Eth200GE0/76", + "index": "76", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet77": { + "lanes": "125,126,127,128", + "alias": "Eth200GE0/77", + "index": "77", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet78": { + "lanes": "127,128,129,130", + "alias": "Eth200GE0/78", + "index": "78", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet79": { + "lanes": "121,122,123,124", + "alias": "Eth200GE0/79", + "index": "79", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet80": { + "lanes": "123,124,125,126", + "alias": "Eth200GE0/80", + "index": "80", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet81": { + "lanes": "133,134,135,136", + "alias": "Eth200GE0/81", + "index": "81", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet82": { + "lanes": "135,136,137,138", + "alias": "Eth200GE0/82", + "index": "82", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet83": { + "lanes": "129,130,131,132", + "alias": "Eth200GE0/83", + "index": "83", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet84": { + "lanes": "131,132,133,134", + "alias": "Eth200GE0/84", + "index": "84", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet85": { + "lanes": "149,150,151,152", + "alias": "Eth200GE0/85", + "index": "85", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet86": { + "lanes": "151,152,153,154", + "alias": "Eth200GE0/86", + "index": "86", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet87": { + "lanes": "157,158,159,160", + "alias": "Eth200GE0/87", + "index": "87", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet88": { + "lanes": "159,160,161,162", + "alias": "Eth200GE0/88", + "index": "88", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet89": { + "lanes": "229,230,231,232", + "alias": "Eth200GE0/89", + "index": "89", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet90": { + "lanes": "231,232,233,234", + "alias": "Eth200GE0/90", + "index": "90", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet91": { + "lanes": "237,238,239,240", + "alias": "Eth200GE0/91", + "index": "91", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet92": { + "lanes": "239,240,241,242", + "alias": "Eth200GE0/92", + "index": "92", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet93": { + "lanes": "253,254,255,256", + "alias": "Eth200GE0/93", + "index": "93", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet94": { + "lanes": "255,256,257,258", + "alias": "Eth200GE0/94", + "index": "94", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet95": { + "lanes": "249,250,251,252", + "alias": "Eth200GE0/95", + "index": "95", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet96": { + "lanes": "251,252,253,254", + "alias": "Eth200GE0/96", + "index": "96", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet97": { + "lanes": "65,66,67,68", + "alias": "Eth200GE0/97", + "index": "97", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet98": { + "lanes": "67,68,69,70", + "alias": "Eth200GE0/98", + "index": "98", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet99": { + "lanes": "73,74,75,76", + "alias": "Eth200GE0/99", + "index": "99", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet100": { + "lanes": "75,76,77,78", + "alias": "Eth200GE0/100", + "index": "100", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet101": { + "lanes": "69,70,71,72", + "alias": "Eth200GE0/101", + "index": "101", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet102": { + "lanes": "71,72,73,74", + "alias": "Eth200GE0/102", + "index": "102", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet103": { + "lanes": "77,78,79,80", + "alias": "Eth200GE0/103", + "index": "103", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet104": { + "lanes": "79,80,81,82", + "alias": "Eth200GE0/104", + "index": "104", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet105": { + "lanes": "57,58,59,60", + "alias": "Eth200GE0/105", + "index": "105", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet106": { + "lanes": "59,60,61,62", + "alias": "Eth200GE0/106", + "index": "106", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet107": { + "lanes": "53,54,55,56", + "alias": "Eth200GE0/107", + "index": "107", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet108": { + "lanes": "55,56,57,58", + "alias": "Eth200GE0/108", + "index": "108", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet109": { + "lanes": "61,62,63,64", + "alias": "Eth200GE0/109", + "index": "109", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet110": { + "lanes": "63,64,65,66", + "alias": "Eth200GE0/110", + "index": "110", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet111": { + "lanes": "49,50,51,52", + "alias": "Eth200GE0/111", + "index": "111", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet112": { + "lanes": "51,52,53,54", + "alias": "Eth200GE0/112", + "index": "112", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet113": { + "lanes": "205,206,207,208", + "alias": "Eth200GE0/113", + "index": "113", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet114": { + "lanes": "207,208,209,210", + "alias": "Eth200GE0/114", + "index": "114", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet115": { + "lanes": "193,194,195,196", + "alias": "Eth200GE0/115", + "index": "115", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet116": { + "lanes": "195,196,197,198", + "alias": "Eth200GE0/116", + "index": "116", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet117": { + "lanes": "201,202,203,204", + "alias": "Eth200GE0/117", + "index": "117", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet118": { + "lanes": "203,204,205,206", + "alias": "Eth200GE0/118", + "index": "118", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet119": { + "lanes": "197,198,199,200", + "alias": "Eth200GE0/119", + "index": "119", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet120": { + "lanes": "199,200,201,202", + "alias": "Eth200GE0/120", + "index": "120", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet121": { + "lanes": "177,178,179,180", + "alias": "Eth200GE0/121", + "index": "121", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet122": { + "lanes": "179,180,181,182", + "alias": "Eth200GE0/122", + "index": "122", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet123": { + "lanes": "185,186,187,188", + "alias": "Eth200GE0/123", + "index": "123", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet124": { + "lanes": "187,188,189,190", + "alias": "Eth200GE0/124", + "index": "124", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet125": { + "lanes": "181,182,183,184", + "alias": "Eth200GE0/125", + "index": "125", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet126": { + "lanes": "183,184,185,186", + "alias": "Eth200GE0/126", + "index": "126", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + }, + "Ethernet127": { + "lanes": "189,190,191,192", + "alias": "Eth200GE0/127", + "index": "127", + "speed": "200000", + "admin_status": "up", + "mtu": "9100" + } + } +} diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/custom_led.bin b/device/tencent/x86_64-tencent_tcs9400-r0/custom_led.bin new file mode 100755 index 0000000000000000000000000000000000000000..3c68fea140d246d285fb7c7021971cc1d186709f GIT binary patch literal 636 zcmY+AYeWy84rij@BMnk3)iQCfqu0Hr zC2P`lLC9B@E-~0HiL#pXi1@(GB}kQj5~` zv?5E;ElVBsw1`bB)}1oXu_zoRTCzTp(X`i)*C-|}C1@;73db_>jGk2L5_QE~6>H6k zx6;E&dCjsyOAP+?%-a8!id$8!ZkJ(+v8=kLH>mQ|f*gxqvZMDKbIH%KN3Rd7(iZ`j zITTRVbRDZvH&{)2g4Lpzgv}}-hpQXpo43s8lFicW^ZO!^f3!}@qg>)VG=)0~W86~^ z^GBy}Z$V%5lb(31ExsL!WUAqeaj&sxU@W0`*~8P~muu1^6N5u?umaZNqLC&x;$a=@ zS%{T<3Rz4sxmXzI4MAQqMu=Cu<_0&p%^kYA&MkUKWg63&!EEL-pKLaEi(d^mCs< G9`OhMcEK0` literal 0 HcmV?d00001 diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/default_sku b/device/tencent/x86_64-tencent_tcs9400-r0/default_sku new file mode 100755 index 000000000000..2ef40b6e379b --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/default_sku @@ -0,0 +1 @@ +TCS9400-128CC t1 diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/dev.xml b/device/tencent/x86_64-tencent_tcs9400-r0/dev.xml new file mode 100755 index 000000000000..7b1f77ffa396 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/dev.xml @@ -0,0 +1,572 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/dev_0x407c.xml b/device/tencent/x86_64-tencent_tcs9400-r0/dev_0x407c.xml new file mode 100755 index 000000000000..ca1661ea5092 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/dev_0x407c.xml @@ -0,0 +1,572 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/fru.py b/device/tencent/x86_64-tencent_tcs9400-r0/fru.py new file mode 100755 index 000000000000..2ccfba01dea2 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/fru.py @@ -0,0 +1,953 @@ +#!/usr/bin/python3 +import collections +from bitarray import bitarray +from datetime import datetime, timedelta + + +__DEBUG__ = "N" + + +class FruException(Exception): + def __init__(self, message='fruerror', code=-100): + err = 'errcode: {0} message:{1}'.format(code, message) + Exception.__init__(self, err) + self.code = code + self.message = message + + +def e_print(err): + print("ERROR: " + err) + + +def d_print(debug_info): + if(__DEBUG__ == "Y"): + print(debug_info) + + +class FruUtil(): + @staticmethod + def decodeLength(value): + a = bitarray(8) + a.setall(True) + a[0:1] = 0 + a[1:2] = 0 + x = ord(a.tobytes()) + return x & ord(value) + + @staticmethod + def minToData(): + starttime = datetime(1996, 1, 1, 0, 0, 0) + endtime = datetime.now() + seconds = (endtime - starttime).total_seconds() + mins = seconds // 60 + m = int(round(mins)) + return m + + @staticmethod + def getTimeFormat(): + return datetime.now().strftime('%Y-%m-%d') + + @staticmethod + def getTypeLength(value): + if value is None or len(value) == 0: + return 0 + a = bitarray(8) + a.setall(False) + a[0:1] = 1 + a[1:2] = 1 + x = ord(a.tobytes()) + return x | len(value) + + @staticmethod + def checksum(b): + result = 0 + for i in range(len(b)): + result += ord(b[i]) + return (0x100 - (result & 0xff)) & 0xff + + +class BaseArea(object): + SUGGESTED_SIZE_COMMON_HEADER = 8 + SUGGESTED_SIZE_INTERNAL_USE_AREA = 72 + SUGGESTED_SIZE_CHASSIS_INFO_AREA = 32 + SUGGESTED_SIZE_BOARD_INFO_AREA = 80 + SUGGESTED_SIZE_PRODUCT_INFO_AREA = 80 + + INITVALUE = b'\x00' + resultvalue = INITVALUE * 256 + COMMON_HEAD_VERSION = b'\x01' + __childList = None + + def __init__(self, name="", size=0, offset=0): + self.__childList = [] + self._offset = offset + self.name = name + self._size = size + self._isPresent = False + self._data = b'\x00' * size + self.__dataoffset = 0 + + @property + def childList(self): + return self.__childList + + @childList.setter + def childList(self, value): + self.__childList = value + + @property + def offset(self): + return self._offset + + @offset.setter + def offset(self, value): + self._offset = value + + @property + def size(self): + return self._size + + @size.setter + def size(self, value): + self._size = value + + @property + def data(self): + return self._data + + @data.setter + def data(self, value): + self._data = value + + @property + def isPresent(self): + return self._isPresent + + @isPresent.setter + def isPresent(self, value): + self._isPresent = value + + +class InternalUseArea(BaseArea): + pass + + +class ChassisInfoArea(BaseArea): + pass + + +class BoardInfoArea(BaseArea): + _boardTime = None + _fields = None + _mfg_date = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "mfg_date : %s \n" \ + "boardManufacturer : %s \n" \ + "boardProductName : %s \n" \ + "boardSerialNumber : %s \n" \ + "boardPartNumber : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.boardversion), self.size, + self.language, self.getMfgRealData(), + self.boardManufacturer, self.boardProductName, + self.boardSerialNumber, self.boardPartNumber, + self.fruFileId) + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "boardextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["boardversion"] = ord(self.boardversion) + dic["boardlength"] = self.size + dic["boardlanguage"] = self.language + dic["boardmfg_date"] = self.getMfgRealData() + dic["boardManufacturer"] = self.boardManufacturer + dic["boardProductName"] = self.boardProductName + dic["boardSerialNumber"] = self.boardSerialNumber + dic["boardPartNumber"] = self.boardPartNumber + dic["boardfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] + index += 1 + d_print("decode length :%d class size:%d" % + ((ord(self.data[index]) * 8), self.size)) + index += 2 + + timetmp = self.data[index: index + 3] + self.mfg_date = ord(timetmp[0]) | ( + ord(timetmp[1]) << 8) | (ord(timetmp[2]) << 16) + d_print("decode getMfgRealData :%s" % self.getMfgRealData()) + index += 3 + + templen = FruUtil.decodeLength(self.data[index]) + self.boardManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardManufacturer:%s" % self.boardManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardProductName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardProductName:%s" % self.boardProductName) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardSerialNumber:%s" % self.boardSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardPartNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardPartNumber:%s" % self.boardPartNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if self.data[index] != chr(0xc1): + templen = FruUtil.decodeLength(self.data[index]) + tmpval = self.data[index + 1: index + templen + 1] + setattr(self, valtmp, tmpval) + index += templen + 1 + d_print("decode boardextra%d:%s" % (i, tmpval)) + else: + break + return + + def recalcute(self): + d_print("boardInfoArea version:%x" % ord(self.boardversion)) + d_print("boardInfoArea length:%d" % self.size) + d_print("boardInfoArea language:%x" % self.language) + self.mfg_date = FruUtil.minToData() + d_print("boardInfoArea mfg_date:%x" % self.mfg_date) + + self.data = chr(ord(self.boardversion)) + \ + chr(self.size // 8) + chr(self.language) + + self.data += chr(self.mfg_date & 0xFF) + self.data += chr((self.mfg_date >> 8) & 0xFF) + self.data += chr((self.mfg_date >> 16) & 0xFF) + + d_print("boardInfoArea boardManufacturer:%s" % self.boardManufacturer) + typelength = FruUtil.getTypeLength(self.boardManufacturer) + self.data += chr(typelength) + self.data += self.boardManufacturer + + d_print("boardInfoArea boardProductName:%s" % self.boardProductName) + self.data += chr(FruUtil.getTypeLength(self.boardProductName)) + self.data += self.boardProductName + + d_print("boardInfoArea boardSerialNumber:%s" % self.boardSerialNumber) + self.data += chr(FruUtil.getTypeLength(self.boardSerialNumber)) + self.data += self.boardSerialNumber + + d_print("boardInfoArea boardPartNumber:%s" % self.boardPartNumber) + self.data += chr(FruUtil.getTypeLength(self.boardPartNumber)) + self.data += self.boardPartNumber + + d_print("boardInfoArea fruFileId:%s" % self.fruFileId) + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea boardextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + d_print("self data:%d" % len(self.data)) + d_print("self size:%d" % self.size) + d_print("adjust size:%d" % (self.size - len(self.data) - 1)) + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + + # checksum + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + def getMfgRealData(self): + starttime = datetime(1996, 1, 1, 0, 0, 0) + mactime = starttime + timedelta(minutes=self.mfg_date) + return mactime + + @property + def language(self): + self._language = 25 + return self._language + + @property + def mfg_date(self): + return self._mfg_date + + @mfg_date.setter + def mfg_date(self, val): + self._mfg_date = val + + @property + def boardversion(self): + self._boardversion = self.COMMON_HEAD_VERSION + return self._boardversion + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, val): + self._FRUFileID = val + + @property + def boardPartNumber(self): + return self._boardPartNumber + + @boardPartNumber.setter + def boardPartNumber(self, val): + self._boardPartNumber = val + + @property + def boardSerialNumber(self): + return self._boardSerialNumber + + @boardSerialNumber.setter + def boardSerialNumber(self, val): + self._boardSerialNumber = val + + @property + def boardProductName(self): + return self._boradProductName + + @boardProductName.setter + def boardProductName(self, val): + self._boradProductName = val + + @property + def boardManufacturer(self): + return self._boardManufacturer + + @boardManufacturer.setter + def boardManufacturer(self, val): + self._boardManufacturer = val + + @property + def boardTime(self): + return self._boardTime + + @boardTime.setter + def boardTime(self, val): + self._boardTime = val + + @property + def fields(self): + return self._fields + + @fields.setter + def fields(self, val): + self._fields = val + + +class ProductInfoArea(BaseArea): + _productManufacturer = None + _productAssetTag = None + _FRUFileID = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "productManufacturer : %s \n" \ + "productName : %s \n" \ + "productPartModelName: %s \n" \ + "productVersion : %s \n" \ + "productSerialNumber : %s \n" \ + "productAssetTag : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.areaversion), self.size, + self.language, self.productManufacturer, + self.productName, self.productPartModelName, + self.productVersion, self.productSerialNumber, + self.productAssetTag, self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "productextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["productversion"] = ord(self.areaversion) + dic["productlength"] = self.size + dic["productlanguage"] = self.language + dic["productManufacturer"] = self.productManufacturer + dic["productName"] = self.productName + dic["productPartModelName"] = self.productPartModelName + dic["productVersion"] = int(self.productVersion, 16) + dic["productSerialNumber"] = self.productSerialNumber + dic["productAssetTag"] = self.productAssetTag + dic["productfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] # 0 + index += 1 + d_print("decode length %d" % (ord(self.data[index]) * 8)) + d_print("class size %d" % self.size) + index += 2 + + templen = FruUtil.decodeLength(self.data[index]) + self.productManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productManufacturer:%s" % self.productManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.productName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productName:%s" % self.productName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productPartModelName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productPartModelName:%s" % self.productPartModelName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productVersion = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productVersion:%s" % self.productVersion) + + templen = FruUtil.decodeLength(self.data[index]) + self.productSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productSerialNumber:%s" % self.productSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.productAssetTag = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productAssetTag:%s" % self.productAssetTag) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if self.data[index] != chr(0xc1) and index < self.size - 1: + templen = FruUtil.decodeLength(self.data[index]) + if templen == 0: + break + tmpval = self.data[index + 1: index + templen + 1] + d_print("decode boardextra%d:%s" % (i, tmpval)) + setattr(self, valtmp, tmpval) + index += templen + 1 + else: + break + + @property + def productVersion(self): + return self._productVersion + + @productVersion.setter + def productVersion(self, name): + self._productVersion = name + + @property + def areaversion(self): + self._areaversion = self.COMMON_HEAD_VERSION + return self._areaversion + + @areaversion.setter + def areaversion(self, name): + self._areaversion = name + + @property + def language(self): + self._language = 25 + return self._language + + @property + def productManufacturer(self): + return self._productManufacturer + + @productManufacturer.setter + def productManufacturer(self, name): + self._productManufacturer = name + + @property + def productName(self): + return self._productName + + @productName.setter + def productName(self, name): + self._productName = name + + @property + def productPartModelName(self): + return self._productPartModelName + + @productPartModelName.setter + def productPartModelName(self, name): + self._productPartModelName = name + + @property + def productSerialNumber(self): + return self._productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, name): + self._productSerialNumber = name + + @property + def productAssetTag(self): + return self._productAssetTag + + @productAssetTag.setter + def productAssetTag(self, name): + self._productAssetTag = name + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, name): + self._FRUFileID = name + + def recalcute(self): + d_print("product version:%x" % ord(self.areaversion)) + d_print("product length:%d" % self.size) + d_print("product language:%x" % self.language) + self.data = chr(ord(self.areaversion)) + \ + chr(self.size // 8) + chr(self.language) + + typelength = FruUtil.getTypeLength(self.productManufacturer) + self.data += chr(typelength) + self.data += self.productManufacturer + + self.data += chr(FruUtil.getTypeLength(self.productName)) + self.data += self.productName + + self.data += chr(FruUtil.getTypeLength(self.productPartModelName)) + self.data += self.productPartModelName + + self.data += chr(FruUtil.getTypeLength(self.productVersion)) + self.data += self.productVersion + + self.data += chr(FruUtil.getTypeLength(self.productSerialNumber)) + self.data += self.productSerialNumber + + self.data += chr(FruUtil.getTypeLength(self.productAssetTag)) + if self.productAssetTag is not None: + self.data += self.productAssetTag + + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea productextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + d_print("self.data:%d" % len(self.data)) + d_print("self.size:%d" % self.size) + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + +class MultiRecordArea(BaseArea): + pass + + +class Field(object): + + def __init__(self, fieldType="ASCII", fieldData=""): + self.fieldData = fieldData + self.fieldType = fieldType + + @property + def data(self): + return self._data + + @property + def fieldType(self): + return self._fieldType + + @property + def fieldData(self): + return self._fieldData + + +class ipmifru(BaseArea): + _BoardInfoArea = None + _ProductInfoArea = None + _InternalUseArea = None + _ChassisInfoArea = None + _multiRecordArea = None + _productinfoAreaOffset = BaseArea.INITVALUE + _boardInfoAreaOffset = BaseArea.INITVALUE + _internalUserAreaOffset = BaseArea.INITVALUE + _chassicInfoAreaOffset = BaseArea.INITVALUE + _multiRecordAreaOffset = BaseArea.INITVALUE + _bindata = None + _bodybin = None + _version = BaseArea.COMMON_HEAD_VERSION + _zeroCheckSum = None + _frusize = 256 + + def __str__(self): + tmpstr = "" + if self.boardInfoArea.isPresent: + tmpstr += "\nboardinfoarea: \n" + tmpstr += self.boardInfoArea.__str__() + if self.productInfoArea.isPresent: + tmpstr += "\nproductinfoarea: \n" + tmpstr += self.productInfoArea.__str__() + return tmpstr + + def decodeBin(self, eeprom): + commonHead = eeprom[0:8] + d_print("decode version %x" % ord(commonHead[0])) + if ord(self.COMMON_HEAD_VERSION) != ord(commonHead[0]): + raise FruException("HEAD VERSION error,not Fru format!", -10) + if FruUtil.checksum(commonHead[0:7]) != ord(commonHead[7]): + strtemp = "check header checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(commonHead[0:7]), ord(commonHead[7])) + raise FruException(strtemp, -3) + if ord(commonHead[1]) != ord(self.INITVALUE): + d_print("Internal Use Area is present") + self.internalUseArea = InternalUseArea( + name="Internal Use Area", size=self.SUGGESTED_SIZE_INTERNAL_USE_AREA) + self.internalUseArea.isPresent = True + self.internalUserAreaOffset = ord(commonHead[1]) + self.internalUseArea.data = eeprom[self.internalUserAreaOffset * 8: ( + self.internalUserAreaOffset * 8 + self.internalUseArea.size)] + if ord(commonHead[2]) != ord(self.INITVALUE): + d_print("Chassis Info Area is present") + self.chassisInfoArea = ChassisInfoArea( + name="Chassis Info Area", size=self.SUGGESTED_SIZE_CHASSIS_INFO_AREA) + self.chassisInfoArea.isPresent = True + self.chassicInfoAreaOffset = ord(commonHead[2]) + self.chassisInfoArea.data = eeprom[self.chassicInfoAreaOffset * 8: ( + self.chassicInfoAreaOffset * 8 + self.chassisInfoArea.size)] + if ord(commonHead[3]) != ord(self.INITVALUE): + self.boardInfoArea = BoardInfoArea( + name="Board Info Area", size=self.SUGGESTED_SIZE_BOARD_INFO_AREA) + self.boardInfoArea.isPresent = True + self.boardInfoAreaOffset = ord(commonHead[3]) + self.boardInfoArea.size = ord( + eeprom[self.boardInfoAreaOffset * 8 + 1]) * 8 + d_print("Board Info Area is present size:%d" % + (self.boardInfoArea.size)) + self.boardInfoArea.data = eeprom[self.boardInfoAreaOffset * 8: ( + self.boardInfoAreaOffset * 8 + self.boardInfoArea.size)] + if FruUtil.checksum(self.boardInfoArea.data[:-1]) != ord(self.boardInfoArea.data[-1:]): + strtmp = "check boardInfoArea checksum error[cal:%02x data:%02x]" % \ + (FruUtil.checksum( + self.boardInfoArea.data[:-1]), ord(self.boardInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.boardInfoArea.decodedata() + if ord(commonHead[4]) != ord(self.INITVALUE): + d_print("Product Info Area is present") + self.productInfoArea = ProductInfoArea( + name="Product Info Area ", size=self.SUGGESTED_SIZE_PRODUCT_INFO_AREA) + self.productInfoArea.isPresent = True + self.productinfoAreaOffset = ord(commonHead[4]) + d_print("length offset value: %02x" % + ord(eeprom[self.productinfoAreaOffset * 8 + 1])) + self.productInfoArea.size = ord( + eeprom[self.productinfoAreaOffset * 8 + 1]) * 8 + d_print("Product Info Area is present size:%d" % + (self.productInfoArea.size)) + + self.productInfoArea.data = eeprom[self.productinfoAreaOffset * 8: ( + self.productinfoAreaOffset * 8 + self.productInfoArea.size)] + if FruUtil.checksum(self.productInfoArea.data[:-1]) != ord(self.productInfoArea.data[-1:]): + strtmp = "check productInfoArea checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(self.productInfoArea.data[:-1]), ord(self.productInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.productInfoArea.decodedata() + if ord(commonHead[5]) != ord(self.INITVALUE): + self.multiRecordArea = MultiRecordArea( + name="MultiRecord record Area ") + d_print("MultiRecord record present") + self.multiRecordArea.isPresent = True + self.multiRecordAreaOffset = ord(commonHead[5]) + self.multiRecordArea.data = eeprom[self.multiRecordAreaOffset * 8: ( + self.multiRecordAreaOffset * 8 + self.multiRecordArea.size)] + + def initDefault(self): + self.version = self.COMMON_HEAD_VERSION + self.internalUserAreaOffset = self.INITVALUE + self.chassicInfoAreaOffset = self.INITVALUE + self.boardInfoAreaOffset = self.INITVALUE + self.productinfoAreaOffset = self.INITVALUE + self.multiRecordAreaOffset = self.INITVALUE + self.PAD = self.INITVALUE + self.zeroCheckSum = self.INITVALUE + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + self.productInfoArea = None + self.internalUseArea = None + self.boardInfoArea = None + self.chassisInfoArea = None + self.multiRecordArea = None + # self.recalcute() + + @property + def version(self): + return self._version + + @version.setter + def version(self, name): + self._version = name + + @property + def internalUserAreaOffset(self): + return self._internalUserAreaOffset + + @internalUserAreaOffset.setter + def internalUserAreaOffset(self, obj): + self._internalUserAreaOffset = obj + + @property + def chassicInfoAreaOffset(self): + return self._chassicInfoAreaOffset + + @chassicInfoAreaOffset.setter + def chassicInfoAreaOffset(self, obj): + self._chassicInfoAreaOffset = obj + + @property + def productinfoAreaOffset(self): + return self._productinfoAreaOffset + + @productinfoAreaOffset.setter + def productinfoAreaOffset(self, obj): + self._productinfoAreaOffset = obj + + @property + def boardInfoAreaOffset(self): + return self._boardInfoAreaOffset + + @boardInfoAreaOffset.setter + def boardInfoAreaOffset(self, obj): + self._boardInfoAreaOffset = obj + + @property + def multiRecordAreaOffset(self): + return self._multiRecordAreaOffset + + @multiRecordAreaOffset.setter + def multiRecordAreaOffset(self, obj): + self._multiRecordAreaOffset = obj + + @property + def zeroCheckSum(self): + return self._zeroCheckSum + + @zeroCheckSum.setter + def zeroCheckSum(self, obj): + self._zeroCheckSum = obj + + @property + def productInfoArea(self): + return self._ProductInfoArea + + @productInfoArea.setter + def productInfoArea(self, obj): + self._ProductInfoArea = obj + + @property + def internalUseArea(self): + return self._InternalUseArea + + @internalUseArea.setter + def internalUseArea(self, obj): + self.internalUseArea = obj + + @property + def boardInfoArea(self): + return self._BoardInfoArea + + @boardInfoArea.setter + def boardInfoArea(self, obj): + self._BoardInfoArea = obj + + @property + def chassisInfoArea(self): + return self._ChassisInfoArea + + @chassisInfoArea.setter + def chassisInfoArea(self, obj): + self._ChassisInfoArea = obj + + @property + def multiRecordArea(self): + return self._multiRecordArea + + @multiRecordArea.setter + def multiRecordArea(self, obj): + self._multiRecordArea = obj + + @property + def bindata(self): + return self._bindata + + @bindata.setter + def bindata(self, obj): + self._bindata = obj + + @property + def bodybin(self): + return self._bodybin + + @bodybin.setter + def bodybin(self, obj): + self._bodybin = obj + + def recalcuteCommonHead(self): + self.bindata = "" + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + d_print("common Header %d" % self.offset) + d_print("fru eeprom size %d" % self._frusize) + if self.internalUseArea is not None and self.internalUseArea.isPresent: + self.internalUserAreaOffset = self.offset // 8 + self.offset += self.internalUseArea.size + d_print("internalUseArea is present offset:%d" % self.offset) + + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + self.chassicInfoAreaOffset = self.offset // 8 + self.offset += self.chassisInfoArea.size + d_print("chassisInfoArea is present offset:%d" % self.offset) + + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + self.boardInfoAreaOffset = self.offset // 8 + self.offset += self.boardInfoArea.size + d_print("boardInfoArea is present offset:%d" % self.offset) + d_print("boardInfoArea is present size:%d" % + self.boardInfoArea.size) + + if self.productInfoArea is not None and self.productInfoArea.isPresent: + self.productinfoAreaOffset = self.offset // 8 + self.offset += self.productInfoArea.size + d_print("productInfoArea is present offset:%d" % self.offset) + + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + self.multiRecordAreaOffset = self.offset // 8 + d_print("multiRecordArea is present offset:%d" % self.offset) + + if self.internalUserAreaOffset == self.INITVALUE: + self.internalUserAreaOffset = 0 + if self.productinfoAreaOffset == self.INITVALUE: + self.productinfoAreaOffset = 0 + if self.chassicInfoAreaOffset == self.INITVALUE: + self.chassicInfoAreaOffset = 0 + if self.boardInfoAreaOffset == self.INITVALUE: + self.boardInfoAreaOffset = 0 + if self.multiRecordAreaOffset == self.INITVALUE: + self.multiRecordAreaOffset = 0 + + self.zeroCheckSum = (0x100 - ord(self.version) - self.internalUserAreaOffset - self.chassicInfoAreaOffset - self.productinfoAreaOffset + - self.boardInfoAreaOffset - self.multiRecordAreaOffset) & 0xff + d_print("zerochecksum:%x" % self.zeroCheckSum) + self.data = "" + self.data += chr(self.version[0]) + chr(self.internalUserAreaOffset) + chr(self.chassicInfoAreaOffset) + chr( + self.boardInfoAreaOffset) + chr(self.productinfoAreaOffset) + chr(self.multiRecordAreaOffset) + chr(self.INITVALUE[0]) + chr(self.zeroCheckSum) + + self.bindata = self.data + self.bodybin + totallen = len(self.bindata) + d_print("totallen %d" % totallen) + if (totallen < self._frusize): + self.bindata = self.bindata.ljust(self._frusize, chr(self.INITVALUE[0])) + else: + raise FruException('bin data more than %d' % self._frusize, -2) + + def recalcutebin(self): + self.bodybin = "" + if self.internalUseArea is not None and self.internalUseArea.isPresent: + d_print("internalUseArea present") + self.bodybin += self.internalUseArea.data + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + d_print("chassisInfoArea present") + self.bodybin += self.chassisInfoArea.data + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + d_print("boardInfoArea present") + self.boardInfoArea.recalcute() + self.bodybin += self.boardInfoArea.data + if self.productInfoArea is not None and self.productInfoArea.isPresent: + d_print("productInfoAreapresent") + self.productInfoArea.recalcute() + self.bodybin += self.productInfoArea.data + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + d_print("multiRecordArea present") + self.bodybin += self.productInfoArea.data + + def recalcute(self, fru_eeprom_size=256): + self._frusize = fru_eeprom_size + self.recalcutebin() + self.recalcuteCommonHead() diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/installer.conf b/device/tencent/x86_64-tencent_tcs9400-r0/installer.conf new file mode 100755 index 000000000000..5e62742c11bf --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/installer.conf @@ -0,0 +1 @@ +CONSOLE_SPEED=115200 diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/led_proc_init.soc b/device/tencent/x86_64-tencent_tcs9400-r0/led_proc_init.soc new file mode 100755 index 000000000000..2f79a8febf86 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/led_proc_init.soc @@ -0,0 +1,6 @@ + +led auto on + +led start + +linkscan SwPortBitMap=all diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/monitor.py b/device/tencent/x86_64-tencent_tcs9400-r0/monitor.py new file mode 100755 index 000000000000..acaf9b4a8c65 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/monitor.py @@ -0,0 +1,431 @@ +#!/usr/bin/python3 +# * onboard temperature sensors +# * FAN trays +# * PSU +# +import os +import xml.etree.ElementTree as ET +import glob +from fru import ipmifru +from decimal import Decimal + + +MAILBOX_DIR = "/sys/bus/i2c/devices/" +BOARD_ID_PATH = "/sys/module/ruijie_common/parameters/dfd_my_type" + +CONFIG_NAME = "dev.xml" + +def byteTostr(val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + +def typeTostr(val): + if isinstance(val, bytes): + strtmp = byteTostr(val) + return strtmp + return val + + +def get_board_id(): + if not os.path.exists(BOARD_ID_PATH): + return "NA" + with open(BOARD_ID_PATH) as fd: + id_str = fd.read().strip() + return "0x%x" % (int(id_str, 10)) + + +def dev_file_read(path, offset, read_len): + retval = "ERR" + val_list = [] + msg = "" + ret = "" + fd = -1 + + if not os.path.exists(path): + return False, "%s %s not found" % (retval, path) + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, read_len) + for item in ret: + val_list.append(item) + except Exception as e: + msg = str(e) + return False, "%s %s" % (retval, msg) + finally: + if fd > 0: + os.close(fd) + return True, val_list + + +def getPMCreg(location): + retval = 'ERR' + if (not os.path.isfile(location)): + return "%s %s notfound"% (retval , location) + try: + with open(location, 'r') as fd: + retval = fd.read() + except Exception as error: + return "ERR %s" % str(error) + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + return retval + + +# Get a mailbox register +def get_pmc_register(reg_name): + retval = 'ERR' + mb_reg_file = reg_name + filepath = glob.glob(mb_reg_file) + if(len(filepath) == 0): + return "%s %s notfound"% (retval , mb_reg_file) + mb_reg_file = filepath[0] + if (not os.path.isfile(mb_reg_file)): + #print mb_reg_file, 'not found !' + return "%s %s notfound"% (retval , mb_reg_file) + try: + with open(mb_reg_file, 'rb') as fd: + retval = fd.read() + retval = typeTostr(retval) + except Exception as error: + retval = "%s %s read failed, msg: %s" % (retval, mb_reg_file, str(error)) + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + return retval + + +class checktype(): + def __init__(self, test1): + self.test1 = test1 + + @staticmethod + def check(name,location, bit, value, tips , err1): + psu_status = int(get_pmc_register(location),16) + val = (psu_status & (1<< bit)) >> bit + if (val != value): + err1["errmsg"] = tips + err1["code"] = -1 + return -1 + else: + err1["errmsg"] = "none" + err1["code"] = 0 + return 0 + + @staticmethod + def getValue(location, bit , type, coefficient = 1, addend = 0): + try: + value_t = get_pmc_register(location) + if value_t.startswith("ERR") : + return value_t + if (type == 1): + return float('%.1f' % ((float(value_t)/1000) + addend)) + elif (type == 2): + return float('%.1f' % (float(value_t)/100)) + elif (type == 3): + psu_status = int(value_t,16) + return (psu_status & (1<< bit)) >> bit + elif (type == 4): + return int(value_t,10) + elif (type == 5): + return float('%.1f' % (float(value_t)/1000/1000)) + elif (type == 6): + return Decimal(float(value_t)*coefficient/1000).quantize(Decimal('0.000')) + else: + return value_t + except Exception as e: + value_t = "ERR %s" % str(e) + return value_t + + #######temp + @staticmethod + def getTemp(self, name, location , ret_t): + ret2 = self.getValue(location + "temp1_input" ," " ,1); + ret3 = self.getValue(location + "temp1_max" ," ", 1); + ret4 = self.getValue(location + "temp1_max_hyst" ," ", 1); + ret_t["temp1_input"] = ret2 + ret_t["temp1_max"] = ret3 + ret_t["temp1_max_hyst"] = ret4 + + @staticmethod + def getLM75(name, location, result): + c1=checktype + r1={} + c1.getTemp(c1, name, location, r1) + result[name] = r1 + + ##########fanFRU + @staticmethod + def decodeBinByValue(retval): + fru = ipmifru() + fru.decodeBin(retval) + return fru + + @staticmethod + def printbinvalue(b): + index = 0 + print(" ",) + for width in range(16): + print("%02x " % width,) + print("") + for i in range(0, len(b)): + if index % 16 == 0: + print(" ") + print(" %02x " % i,) + print("%02x " % ord(b[i]),) + index += 1 + print("") + + @staticmethod + def getfruValue(prob_t, root, val): + try: + ret, binval_bytes = dev_file_read(val, 0, 256) + if ret == False: + return binval_bytes + binval = byteTostr(binval_bytes) + fanpro = {} + ret = checktype.decodeBinByValue(binval) + fanpro['fan_type'] = ret.productInfoArea.productName + fanpro['hw_version'] = ret.productInfoArea.productVersion + fanpro['sn'] = ret.productInfoArea.productSerialNumber + fanpro['fanid'] = ret.productInfoArea.productextra2 + fan_display_name_dict = status.getDecodValue(root, "fan_display_name") + fan_name = fanpro['fan_type'].strip() + if len(fan_display_name_dict) == 0: + return fanpro + if fan_name not in fan_display_name_dict.keys(): + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s'% ("ERR fan name: %s not support" % fan_name) + else: + fanpro['fan_type'] = fan_display_name_dict[fan_name] + return fanpro + except Exception as error: + return "ERR " + str(error) + + @staticmethod + def getslotfruValue(val): + try: + binval = checktype.getValue(val, 0 , 0) + if binval.startswith("ERR"): + return binval + slotpro = {} + ret = checktype.decodeBinByValue(binval) + slotpro['slot_type'] = ret.boardInfoArea.boardProductName + slotpro['hw_version'] = ret.boardInfoArea.boardextra1 + slotpro['sn'] = ret.boardInfoArea.boardSerialNumber + return slotpro + except Exception as error: + return "ERR " + str(error) + + @staticmethod + def getpsufruValue(prob_t, root, val): + try: + psu_match = False + binval = checktype.getValue(val, 0 , 0) + if binval.startswith("ERR"): + return binval + psupro = {} + ret = checktype.decodeBinByValue(binval) + psupro['type1'] = ret.productInfoArea.productPartModelName + psupro['sn'] = ret.productInfoArea.productSerialNumber + psupro['hw_version'] = ret.productInfoArea.productVersion + psu_dict = status.getDecodValue(root, "psutype") + psupro['type1'] = psupro['type1'].strip() + if len(psu_dict) == 0: + return psupro + for psu_name in psu_dict.keys(): + if psu_name in psupro['type1']: + psupro['type1'] = psu_dict[psu_name] + psu_match = True + break + if psu_match is not True: + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s'% ("ERR psu name: %s not support" % psupro['type1']) + return psupro + except Exception as error: + return "ERR " + str(error) + +class status(): + def __init__(self, productname): + self.productname = productname + + @staticmethod + def getETroot(filename): + tree = ET.parse(filename) + root = tree.getroot() + return root; + + @staticmethod + def getDecodValue(collection, decode): + decodes = collection.find('decode') + testdecode = decodes.find(decode) + test={} + if testdecode is None: + return test + for neighbor in testdecode.iter('code'): + test[neighbor.attrib["key"]]=neighbor.attrib["value"] + return test + + @staticmethod + def getfileValue(location): + return checktype.getValue(location," "," ") + + @staticmethod + def getETValue(a, filename, tagname): + root = status.getETroot(filename) + for neighbor in root.iter(tagname): + prob_t = {} + prob_t = neighbor.attrib + prob_t['errcode']= 0 + prob_t['errmsg'] = '' + for pros in neighbor.iter("property"): + ret = dict(list(neighbor.attrib.items()) + list(pros.attrib.items())) + if ret.get('e2type') == 'fru' and ret.get("name") == "fru": + fruval = checktype.getfruValue(prob_t, root, ret["location"]) + if isinstance(fruval, str) and fruval.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= fruval + break + else: + prob_t.update(fruval) + continue + + if ret.get("name") == "psu" and ret.get('e2type') == 'fru': + psuval = checktype.getpsufruValue(prob_t, root, ret["location"]) + if isinstance(psuval, str) and psuval.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= psuval + break + else: + prob_t.update(psuval) + continue + + if ret.get("gettype") == "config": + prob_t[ret["name"]] = ret["value"] + continue + + if ('type' not in ret.keys()): + val = "0"; + else: + val = ret["type"] + if ('bit' not in ret.keys()): + bit = "0"; + else: + bit = ret["bit"] + if ('coefficient' not in ret.keys()): + coefficient = 1; + else: + coefficient = float(ret["coefficient"]) + if ('addend' not in ret.keys()): + addend = 0; + else: + addend = float(ret["addend"]) + + s = checktype.getValue(ret["location"], int(bit),int(val), coefficient, addend) + if isinstance(s, str) and s.startswith("ERR"): + prob_t['errcode']= -1 + prob_t['errmsg']= s + break + if ('default' in ret.keys()): + rt = status.getDecodValue(root,ret['decode']) + prob_t['errmsg']= rt[str(s)] + if str(s) != ret["default"]: + prob_t['errcode']= -1 + break + else: + if ('decode' in ret.keys()): + rt = status.getDecodValue(root,ret['decode']) + if(ret['decode'] == "psutype" and s.replace("\x00","").rstrip() not in rt.keys()): + prob_t['errcode']= -1 + prob_t['errmsg'] = '%s' % ("ERR psu name: %s not support" % (s.replace("\x00","").rstrip())) + else: + s = rt[str(s).replace("\x00","").rstrip()] + name = ret["name"] + prob_t[name]=str(s) + a.append(prob_t) + + @staticmethod + def getCPUValue(a, filename, tagname): + root = status.getETroot(filename) + for neighbor in root.iter(tagname): + location = neighbor.attrib["location"] + L=[] + for dirpath, dirnames, filenames in os.walk(location): + for file in filenames : + if file.endswith("input"): + L.append(os.path.join(dirpath, file)) + L =sorted(L,reverse=False) + for i in range(len(L)): + prob_t = {} + prob_t["name"] = getPMCreg("%s/temp%d_label"%(location,i+1)) + prob_t["temp"] = float(getPMCreg("%s/temp%d_input"%(location,i+1)))/1000 + prob_t["alarm"] = float(getPMCreg("%s/temp%d_crit_alarm"%(location,i+1)))/1000 + prob_t["crit"] = float(getPMCreg("%s/temp%d_crit"%(location,i+1)))/1000 + prob_t["max"] = float(getPMCreg("%s/temp%d_max"%(location,i+1)))/1000 + a.append(prob_t) + + @staticmethod + def getFileName(): + fpath = os.path.dirname(os.path.realpath(__file__)) + board_id = get_board_id() + dev_id_xml = fpath + "/" + "dev_%s.xml" % board_id + if os.path.exists(dev_id_xml): + return dev_id_xml + return fpath + "/"+ CONFIG_NAME + + @staticmethod + def getFan(ret): + _filename = status.getFileName() + _tagname = "fan" + status.getvalue(ret, _filename, _tagname) + + + @staticmethod + def checkFan(ret): + _filename = status.getFileName() + # _filename = "/usr/local/bin/" + status.getFileName() + _tagname = "fan" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getTemp(ret): + _filename = status.getFileName() + #_filename = "/usr/local/bin/" + status.getFileName() + _tagname = "temp" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getPsu(ret): + _filename = status.getFileName() + # _filename = "/usr/local/bin/" + status.getFileName() + _tagname = "psu" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getcputemp(ret): + _filename = status.getFileName() + _tagname = "cpus" + status.getCPUValue(ret, _filename, _tagname) + + @staticmethod + def getDcdc(ret): + _filename = status.getFileName() + _tagname = "dcdc" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getmactemp(ret): + _filename = status.getFileName() + _tagname = "mactemp" + status.getETValue(ret, _filename, _tagname) + + @staticmethod + def getmacpower(ret): + _filename = status.getFileName() + _tagname = "macpower" + status.getETValue(ret, _filename, _tagname) diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/platform_asic b/device/tencent/x86_64-tencent_tcs9400-r0/platform_asic new file mode 100755 index 000000000000..960467652765 --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/platform_asic @@ -0,0 +1 @@ +broadcom diff --git a/device/tencent/x86_64-tencent_tcs9400-r0/platform_env.conf b/device/tencent/x86_64-tencent_tcs9400-r0/platform_env.conf new file mode 100644 index 000000000000..74e9293b382e --- /dev/null +++ b/device/tencent/x86_64-tencent_tcs9400-r0/platform_env.conf @@ -0,0 +1,2 @@ +SYNCD_SHM_SIZE=1g +is_ltsw_chip=1 \ No newline at end of file diff --git a/platform/broadcom/one-image.mk b/platform/broadcom/one-image.mk old mode 100644 new mode 100755 index 59a3259c9929..6c668ee6894d --- a/platform/broadcom/one-image.mk +++ b/platform/broadcom/one-image.mk @@ -81,7 +81,9 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ $(RAGILE_RA_B6910_64C_PLATFORM_MODULE) \ $(RAGILE_RA_B6510_32C_PLATFORM_MODULE) \ $(RAGILE_RA_B6920_4S_PLATFORM_MODULE) \ - $(NOKIA_IXR7250_PLATFORM_MODULE) + $(NOKIA_IXR7250_PLATFORM_MODULE) \ + $(TENCENT_TCS8400_PLATFORM_MODULE) \ + $(TENCENT_TCS9400_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_LAZY_BUILD_INSTALLS = $(BRCM_OPENNSL_KERNEL) $(BRCM_DNX_OPENNSL_KERNEL) ifeq ($(INSTALL_DEBUG_TOOLS),y) $(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES) diff --git a/platform/broadcom/platform-modules-tencent.dep b/platform/broadcom/platform-modules-tencent.dep new file mode 100644 index 000000000000..02106ee3901f --- /dev/null +++ b/platform/broadcom/platform-modules-tencent.dep @@ -0,0 +1,8 @@ +MPATH := $($(TENCENT_TCS8400_PLATFORM_MODULE)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/platform-modules-tencent.mk platform/broadcom/platform-modules-tencent.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(MPATH)) + +$(TENCENT_TCS8400_PLATFORM_MODULE)_CACHE_MODE := GIT_CONTENT_SHA +$(TENCENT_TCS8400_PLATFORM_MODULE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(TENCENT_TCS8400_PLATFORM_MODULE)_DEP_FILES := $(DEP_FILES) diff --git a/platform/broadcom/platform-modules-tencent.mk b/platform/broadcom/platform-modules-tencent.mk new file mode 100644 index 000000000000..1cbe17737d2c --- /dev/null +++ b/platform/broadcom/platform-modules-tencent.mk @@ -0,0 +1,18 @@ +# Tencent platform modules +TENCENT_TCS8400_PLATFORM_MODULE_VERSION = 1.0 +export TENCENT_TCS8400_PLATFORM_MODULE_VERSION + +TENCENT_TCS8400_PLATFORM_MODULE = platform-modules-ruijie-tcs8400_$(TENCENT_TCS8400_PLATFORM_MODULE_VERSION)_amd64.deb +$(TENCENT_TCS8400_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-tencent +$(TENCENT_TCS8400_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) +$(TENCENT_TCS8400_PLATFORM_MODULE)_PLATFORM = x86_64-tencent_tcs8400-r0 +SONIC_DPKG_DEBS += $(TENCENT_TCS8400_PLATFORM_MODULE) +SONIC_STRETCH_DEBS += $(TENCENT_TCS8400_PLATFORM_MODULE) + +## TCS9400 +TENCENT_TCS9400_PLATFORM_MODULE_VERSION = 1.0 +export TENCENT_TCS9400_PLATFORM_MODULE_VERSION + +TENCENT_TCS9400_PLATFORM_MODULE = platform-modules-ruijie-tcs9400_$(TENCENT_TCS9400_PLATFORM_MODULE_VERSION)_amd64.deb +$(TENCENT_TCS9400_PLATFORM_MODULE)_PLATFORM = x86_64-tencent_tcs9400-r0 +$(eval $(call add_extra_package,$(TENCENT_TCS8400_PLATFORM_MODULE),$(TENCENT_TCS9400_PLATFORM_MODULE))) diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk old mode 100644 new mode 100755 index d946d04cc1d8..28d1cf1a4df5 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -15,6 +15,7 @@ include $(PLATFORM_PATH)/platform-modules-juniper.mk #include $(PLATFORM_PATH)/platform-modules-brcm-xlr-gts.mk #include $(PLATFORM_PATH)/platform-modules-ruijie.mk #include $(PLATFORM_PATH)/platform-modules-ragile.mk +#include $(PLATFORM_PATH)/platform-modules-tencent.mk include $(PLATFORM_PATH)/docker-syncd-brcm.mk include $(PLATFORM_PATH)/docker-syncd-brcm-rpc.mk include $(PLATFORM_PATH)/docker-saiserver-brcm.mk diff --git a/platform/broadcom/sonic-platform-modules-tencent/LICENSE b/platform/broadcom/sonic-platform-modules-tencent/LICENSE new file mode 100755 index 000000000000..5571f1244579 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/LICENSE @@ -0,0 +1,15 @@ +Copyright (C) 2016 Microsoft, Inc +Copyright (C) 2022 Ruijie Network Corporation +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/Makefile new file mode 100755 index 000000000000..97d777b0d3e5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/Makefile @@ -0,0 +1,37 @@ +PWD = $(shell pwd) +CC ?=gcc +INSTALL_MOD_DIR ?=extra +KVERSION ?= $(shell uname -r) +KERNEL_SRC ?= /lib/modules/$(KVERSION) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUB_BUILD_DIR = $(PWD)/build +DIR_KERNEL_SRC = $(PWD)/modules +SCRIPT_DIR = $(PWD)/script +SERVICE_DIR = $(PWD)/service +BLACK_DRIVER_CONF_DIR = $(PWD)/modprobe_conf + +modules_build_dir = $(DIR_KERNEL_SRC)/build + +INSTALL_MODULE_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_SERVICE_DIR = $(SUB_BUILD_DIR)/lib/systemd/system +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3/dist-packages +INSTALL_BLACK_DRIVER = $(SUB_BUILD_DIR)/etc/modprobe.d + +all: + $(MAKE) -C $(DIR_KERNEL_SRC) + @if [ ! -d ${INSTALL_MODULE_DIR} ]; then mkdir -p ${INSTALL_MODULE_DIR} ;fi + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + @if [ ! -d ${INSTALL_SERVICE_DIR} ]; then mkdir -p ${INSTALL_SERVICE_DIR} ;fi + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/lib/ ]; then cp -r $(PWD)/lib/* ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/sonic_platform/ ]; then cp -rf $(PWD)/sonic_platform ${INSTALL_LIB_DIR} ;fi + cp -r $(modules_build_dir)/*.ko $(INSTALL_MODULE_DIR) + cp -r $(SCRIPT_DIR)/* $(INSTALL_SCRIPT_DIR) + cp -r $(SERVICE_DIR)/* $(INSTALL_SERVICE_DIR) + @if [ -d $(INSTALL_SCRIPT_DIR) ]; then chmod +x $(INSTALL_SCRIPT_DIR)/* ;fi + @if [ ! -d ${INSTALL_BLACK_DRIVER} ]; then mkdir -p ${INSTALL_BLACK_DRIVER} ;fi + cp -r $(BLACK_DRIVER_CONF_DIR)/* $(INSTALL_BLACK_DRIVER) +clean: + rm -rf $(SUB_BUILD_DIR) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/hysteresis.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/hysteresis.py new file mode 100755 index 000000000000..7a1daf0eb8b8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/hysteresis.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +import os +import syslog +import copy + +from plat_hal.baseutil import baseutil + +HYST_DEBUG_FILE = "/etc/.hysteresis_debug_flag" + +HYSTERROR = 1 +HYSTDEBUG = 2 + +debuglevel = 0 + +def hyst_debug(s): + if HYSTDEBUG & debuglevel: + syslog.openlog("FANCONTROL-HYST", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + +def hyst_error(s): + if HYSTERROR & debuglevel: + syslog.openlog("FANCONTROL-HYST", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + +class hysteresis(object): + __config = None + __hyst_config = None + + def __init__(self): + self.__config = baseutil.get_monitor_config() + self.__hyst_config = copy.deepcopy(self.__config.get("hyst", {})) + # init check + errcnt = 0 + errmsg = "" + self.debug_init() + for temp_hyst_conf in self.__hyst_config.values(): + if temp_hyst_conf["flag"] == 0: + continue + for i in range(temp_hyst_conf["temp_min"], temp_hyst_conf["temp_max"] + 1): + if i not in temp_hyst_conf["rising"]: + errcnt -= 1 + msg = "%s hyst config error, temp value %d not in rising curve;" % (temp_hyst_conf["name"], i) + hyst_error(msg) + errmsg += msg + if i not in temp_hyst_conf["descending"]: + errcnt -= 1 + msg = "%s hyst config error, temp value %d not in descending curve;" %(temp_hyst_conf["name"], i) + hyst_error(msg) + errmsg += msg + if errcnt < 0: + raise KeyError(errmsg) + + def debug_init(self): + global debuglevel + if os.path.exists(HYST_DEBUG_FILE): + debuglevel = debuglevel | HYSTDEBUG | HYSTERROR + else: + debuglevel = debuglevel & ~(HYSTDEBUG | HYSTERROR) + + def get_temp_hyst_conf(self, temp_name): + temp_hyst_conf = self.__hyst_config.get(temp_name) + return temp_hyst_conf + + def get_temp_update(self, hyst_para, current_temp): + temp = hyst_para["value"] + if temp is None: + return None + temp.append(current_temp) + del temp[0] + return temp + + def duty_to_pwm(self, duty): + pwm = int(round(float(duty) * 255 / 100)) + return pwm + + def pwm_to_duty(self, pwm): + duty = int(round(float(pwm) * 100 / 255)) + return duty + + def calc_hyst_val(self, temp_name, temp_list): + + temp_hyst_conf = self.get_temp_hyst_conf(temp_name) + hyst_min = temp_hyst_conf["hyst_min"] + hyst_max = temp_hyst_conf["hyst_max"] + temp_min = temp_hyst_conf["temp_min"] + temp_max = temp_hyst_conf["temp_max"] + rising = temp_hyst_conf["rising"] + descending = temp_hyst_conf["descending"] + last_hyst_value = temp_hyst_conf["last_hyst_value"] + current_temp = temp_list[1] + last_temp = temp_list[0] + + hyst_debug("calc_hyst_val, temp_name: %s, current_temp: %s, last_temp: %s, last_hyst_value: %s" % + (temp_name, current_temp, last_temp, last_hyst_value)) + + if current_temp < temp_min: + hyst_debug("%s current_temp %s less than temp_min %s, set min hyst value: %s" % + (temp_name, current_temp, temp_min, hyst_min)) + return hyst_min + + if current_temp > temp_max: + hyst_debug("%s current_temp %s more than temp_max %s, set max hyst value: %s" % + (temp_name, current_temp, temp_max, hyst_max)) + return hyst_max + + if last_temp is None: # first time + hyst_value = rising[current_temp] + hyst_debug("last_temp is None, it's first hysteresis, using rising hyst value: %s" % hyst_value) + return hyst_value + + if current_temp == last_temp: # temp unchanging + hyst_debug("current_temp equal last_temp, keep last hyst value: %s" % last_hyst_value) + return last_hyst_value + + if current_temp > last_temp: + calc_hyst_value = rising[current_temp] + if calc_hyst_value < last_hyst_value: + hyst_value = last_hyst_value + else: + hyst_value = calc_hyst_value + hyst_debug("temp rising, last_hyst_value: %s, calc_hyst_value: %s, set hyst value: %s" % + (last_hyst_value, calc_hyst_value, hyst_value)) + return hyst_value + + calc_hyst_value = descending[current_temp] + if calc_hyst_value > last_hyst_value: + hyst_value = last_hyst_value + else: + hyst_value = calc_hyst_value + hyst_debug("temp descending, last_hyst_value: %s, calc_hyst_value: %s, set hyst value: %s" % + (last_hyst_value, calc_hyst_value, hyst_value)) + return hyst_value + + def cacl(self, temp_name, current_temp): + self.debug_init() + try: + temp_hyst_conf = self.get_temp_hyst_conf(temp_name) + if temp_hyst_conf is None: + hyst_debug("get %s hysteresis config failed" % temp_name) + return None + + flag = temp_hyst_conf["flag"] + if flag != 1: + hyst_debug("%s hysteresis flag == 0, skip" % temp_name) + return None + + temp = self.get_temp_update(temp_hyst_conf, current_temp) + if temp is None: + hyst_debug("get %s update failed" % temp_name) + return None + + value = self.calc_hyst_val(temp_name, temp) + + temp_hyst_conf["last_hyst_value"] = value + + type = temp_hyst_conf["type"] + if type == "duty": + pwm = self.duty_to_pwm(value) + else: + pwm = value + + hyst_debug("temp_name: %s, current_temp: %s, set pwm 0x%x" % (temp_name, current_temp, pwm)) + return pwm + except Exception as e: + hyst_error("temp_name: %s calc hysteresis pwm error, msg: %s" % (temp_name, str(e))) + return None + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/openloop.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/openloop.py new file mode 100755 index 000000000000..6876145fd586 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/openloop.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +import os +import syslog + +from plat_hal.baseutil import baseutil + +OPENLOOP_DEBUG_FILE = "/etc/.openloop_debug_flag" + +OPENLOOPERROR = 1 +OPENLOOPDEBUG = 2 + +debuglevel = 0 + + +def openloop_debug(s): + if OPENLOOPDEBUG & debuglevel: + syslog.openlog("FANCONTROL-OPENLOOP", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def openloop_error(s): + if OPENLOOPERROR & debuglevel: + syslog.openlog("FANCONTROL-OPENLOOP", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +class openloop(object): + __config = None + __openloop_config = None + + def __init__(self): + self.__config = baseutil.get_monitor_config() + self.__openloop_config = self.__config["openloop"] + + def debug_init(self): + global debuglevel + if os.path.exists(OPENLOOP_DEBUG_FILE): + debuglevel = debuglevel | OPENLOOPDEBUG | OPENLOOPERROR + else: + debuglevel = debuglevel & ~(OPENLOOPDEBUG | OPENLOOPERROR) + + def get_para(self, type): + para = self.__openloop_config.get(type) + return para + + def linear_cacl(self, temp): + self.debug_init() + openloop_para = self.get_para("linear") + if openloop_para is None: + openloop_debug("linear openloop: get para failed") + return None + + K = openloop_para["K"] + tin_min = openloop_para["tin_min"] + pwm_min = openloop_para["pwm_min"] + pwm_max = openloop_para["pwm_max"] + flag = openloop_para["flag"] + + if flag != 1: + openloop_debug("linear openloop: flag == 0") + return None + + if temp <= tin_min: + openloop_debug("linear openloop: temp = %d less than tin_min[%d]" % (temp, tin_min)) + return pwm_min + + pwm = int(pwm_min + (temp - tin_min) * K) + openloop_debug("linear openloop: cacl_pwm = 0x%x" % pwm) + + pwm = min(pwm, pwm_max) + pwm = max(pwm, pwm_min) + openloop_debug("linear openloop: temp = %d, pwm = 0x%x" % (temp, pwm)) + return pwm + + def curve_cacl(self, temp): + self.debug_init() + openloop_para = self.get_para("curve") + if openloop_para is None: + openloop_debug("curve openloop: get para failed") + return None + + a = openloop_para["a"] + b = openloop_para["b"] + c = openloop_para["c"] + tin_min = openloop_para["tin_min"] + pwm_min = openloop_para["pwm_min"] + pwm_max = openloop_para["pwm_max"] + flag = openloop_para["flag"] + + if flag != 1: + openloop_debug("curve openloop: flag == 0") + return None + + if temp <= tin_min: + openloop_debug("curve openloop: temp = %d less than tin_min[%d]" % (temp, tin_min)) + return pwm_min + + pwm = int(a * temp * temp + b * temp + c) + openloop_debug("curve openloop: cacl_pwm = 0x%x" % pwm) + + pwm = min(pwm, pwm_max) + pwm = max(pwm, pwm_min) + openloop_debug("curve openloop: temp = %d, pwm = 0x%x" % (temp, pwm)) + return pwm diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/pid.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/pid.py new file mode 100755 index 000000000000..b2cffc5b5210 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/algorithm/pid.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +import os +import syslog +import copy + +from plat_hal.baseutil import baseutil + +PID_DEBUG_FILE = "/etc/.pid_debug_flag" + +PIDERROR = 1 +PIDDEBUG = 2 + +debuglevel = 0 + + +def pid_debug(s): + if PIDDEBUG & debuglevel: + syslog.openlog("FANCONTROL-PID", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def pid_error(s): + if PIDERROR & debuglevel: + syslog.openlog("FANCONTROL-PID", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +class pid(object): + __config = None + __pid_config = None + + def __init__(self): + self.__config = baseutil.get_monitor_config() + self.__pid_config = copy.deepcopy(self.__config["pid"]) + + def debug_init(self): + global debuglevel + if os.path.exists(PID_DEBUG_FILE): + debuglevel = debuglevel | PIDDEBUG | PIDERROR + else: + debuglevel = debuglevel & ~(PIDDEBUG | PIDERROR) + + def get_para(self, name): + para = self.__pid_config.get(name) + return para + + def get_temp_update(self, pid_para, current_temp): + temp = pid_para["value"] + if temp is None: + return None + temp.append(current_temp) + del temp[0] + return temp + + def cacl(self, last_pwm, name, current_temp): + delta_pwm = 0 + self.debug_init() + pid_debug("last_pwm = %d" % last_pwm) + + pid_para = self.get_para(name) + if pid_para is None: + pid_debug("get %s pid para failed" % name) + return None + + temp = self.get_temp_update(pid_para, current_temp) + if temp is None: + pid_debug("get %s update failed" % name) + return None + + type = pid_para["type"] + Kp = pid_para["Kp"] + Ki = pid_para["Ki"] + Kd = pid_para["Kd"] + target = pid_para["target"] + pwm_min = pid_para["pwm_min"] + pwm_max = pid_para["pwm_max"] + flag = pid_para["flag"] + + if flag != 1: + pid_debug("%s pid flag == 0" % name) + return None + + if type == "duty": + current_pwm = round(last_pwm * 100 / 255) + else: + current_pwm = last_pwm + + if (temp[2] is None): + tmp_pwm = current_pwm + elif ((temp[0] is None) or (temp[1] is None)): + delta_pwm = Ki * (temp[2] - target) + tmp_pwm = current_pwm + delta_pwm + else: + delta_pwm = Kp * (temp[2] - temp[1]) + Ki * (temp[2] - target) + Kd * (temp[2] - 2 * temp[1] + temp[0]) + tmp_pwm = current_pwm + delta_pwm + + pid_debug("delta_pwm = %d" % delta_pwm) + if type == "duty": + pwm = round(tmp_pwm * 255 / 100) + else: + pwm = int(tmp_pwm) + + pwm = min(pwm, pwm_max) + pwm = max(pwm, pwm_min) + pid_debug("last_pwm = 0x%x, pwm = 0x%x" % (last_pwm, pwm)) + return pwm diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/fru.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/fru.py new file mode 100755 index 000000000000..2ccfba01dea2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/fru.py @@ -0,0 +1,953 @@ +#!/usr/bin/python3 +import collections +from bitarray import bitarray +from datetime import datetime, timedelta + + +__DEBUG__ = "N" + + +class FruException(Exception): + def __init__(self, message='fruerror', code=-100): + err = 'errcode: {0} message:{1}'.format(code, message) + Exception.__init__(self, err) + self.code = code + self.message = message + + +def e_print(err): + print("ERROR: " + err) + + +def d_print(debug_info): + if(__DEBUG__ == "Y"): + print(debug_info) + + +class FruUtil(): + @staticmethod + def decodeLength(value): + a = bitarray(8) + a.setall(True) + a[0:1] = 0 + a[1:2] = 0 + x = ord(a.tobytes()) + return x & ord(value) + + @staticmethod + def minToData(): + starttime = datetime(1996, 1, 1, 0, 0, 0) + endtime = datetime.now() + seconds = (endtime - starttime).total_seconds() + mins = seconds // 60 + m = int(round(mins)) + return m + + @staticmethod + def getTimeFormat(): + return datetime.now().strftime('%Y-%m-%d') + + @staticmethod + def getTypeLength(value): + if value is None or len(value) == 0: + return 0 + a = bitarray(8) + a.setall(False) + a[0:1] = 1 + a[1:2] = 1 + x = ord(a.tobytes()) + return x | len(value) + + @staticmethod + def checksum(b): + result = 0 + for i in range(len(b)): + result += ord(b[i]) + return (0x100 - (result & 0xff)) & 0xff + + +class BaseArea(object): + SUGGESTED_SIZE_COMMON_HEADER = 8 + SUGGESTED_SIZE_INTERNAL_USE_AREA = 72 + SUGGESTED_SIZE_CHASSIS_INFO_AREA = 32 + SUGGESTED_SIZE_BOARD_INFO_AREA = 80 + SUGGESTED_SIZE_PRODUCT_INFO_AREA = 80 + + INITVALUE = b'\x00' + resultvalue = INITVALUE * 256 + COMMON_HEAD_VERSION = b'\x01' + __childList = None + + def __init__(self, name="", size=0, offset=0): + self.__childList = [] + self._offset = offset + self.name = name + self._size = size + self._isPresent = False + self._data = b'\x00' * size + self.__dataoffset = 0 + + @property + def childList(self): + return self.__childList + + @childList.setter + def childList(self, value): + self.__childList = value + + @property + def offset(self): + return self._offset + + @offset.setter + def offset(self, value): + self._offset = value + + @property + def size(self): + return self._size + + @size.setter + def size(self, value): + self._size = value + + @property + def data(self): + return self._data + + @data.setter + def data(self, value): + self._data = value + + @property + def isPresent(self): + return self._isPresent + + @isPresent.setter + def isPresent(self, value): + self._isPresent = value + + +class InternalUseArea(BaseArea): + pass + + +class ChassisInfoArea(BaseArea): + pass + + +class BoardInfoArea(BaseArea): + _boardTime = None + _fields = None + _mfg_date = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "mfg_date : %s \n" \ + "boardManufacturer : %s \n" \ + "boardProductName : %s \n" \ + "boardSerialNumber : %s \n" \ + "boardPartNumber : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.boardversion), self.size, + self.language, self.getMfgRealData(), + self.boardManufacturer, self.boardProductName, + self.boardSerialNumber, self.boardPartNumber, + self.fruFileId) + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "boardextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["boardversion"] = ord(self.boardversion) + dic["boardlength"] = self.size + dic["boardlanguage"] = self.language + dic["boardmfg_date"] = self.getMfgRealData() + dic["boardManufacturer"] = self.boardManufacturer + dic["boardProductName"] = self.boardProductName + dic["boardSerialNumber"] = self.boardSerialNumber + dic["boardPartNumber"] = self.boardPartNumber + dic["boardfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] + index += 1 + d_print("decode length :%d class size:%d" % + ((ord(self.data[index]) * 8), self.size)) + index += 2 + + timetmp = self.data[index: index + 3] + self.mfg_date = ord(timetmp[0]) | ( + ord(timetmp[1]) << 8) | (ord(timetmp[2]) << 16) + d_print("decode getMfgRealData :%s" % self.getMfgRealData()) + index += 3 + + templen = FruUtil.decodeLength(self.data[index]) + self.boardManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardManufacturer:%s" % self.boardManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardProductName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardProductName:%s" % self.boardProductName) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardSerialNumber:%s" % self.boardSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.boardPartNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode boardPartNumber:%s" % self.boardPartNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if self.data[index] != chr(0xc1): + templen = FruUtil.decodeLength(self.data[index]) + tmpval = self.data[index + 1: index + templen + 1] + setattr(self, valtmp, tmpval) + index += templen + 1 + d_print("decode boardextra%d:%s" % (i, tmpval)) + else: + break + return + + def recalcute(self): + d_print("boardInfoArea version:%x" % ord(self.boardversion)) + d_print("boardInfoArea length:%d" % self.size) + d_print("boardInfoArea language:%x" % self.language) + self.mfg_date = FruUtil.minToData() + d_print("boardInfoArea mfg_date:%x" % self.mfg_date) + + self.data = chr(ord(self.boardversion)) + \ + chr(self.size // 8) + chr(self.language) + + self.data += chr(self.mfg_date & 0xFF) + self.data += chr((self.mfg_date >> 8) & 0xFF) + self.data += chr((self.mfg_date >> 16) & 0xFF) + + d_print("boardInfoArea boardManufacturer:%s" % self.boardManufacturer) + typelength = FruUtil.getTypeLength(self.boardManufacturer) + self.data += chr(typelength) + self.data += self.boardManufacturer + + d_print("boardInfoArea boardProductName:%s" % self.boardProductName) + self.data += chr(FruUtil.getTypeLength(self.boardProductName)) + self.data += self.boardProductName + + d_print("boardInfoArea boardSerialNumber:%s" % self.boardSerialNumber) + self.data += chr(FruUtil.getTypeLength(self.boardSerialNumber)) + self.data += self.boardSerialNumber + + d_print("boardInfoArea boardPartNumber:%s" % self.boardPartNumber) + self.data += chr(FruUtil.getTypeLength(self.boardPartNumber)) + self.data += self.boardPartNumber + + d_print("boardInfoArea fruFileId:%s" % self.fruFileId) + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "boardextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea boardextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + d_print("self data:%d" % len(self.data)) + d_print("self size:%d" % self.size) + d_print("adjust size:%d" % (self.size - len(self.data) - 1)) + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + + # checksum + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + def getMfgRealData(self): + starttime = datetime(1996, 1, 1, 0, 0, 0) + mactime = starttime + timedelta(minutes=self.mfg_date) + return mactime + + @property + def language(self): + self._language = 25 + return self._language + + @property + def mfg_date(self): + return self._mfg_date + + @mfg_date.setter + def mfg_date(self, val): + self._mfg_date = val + + @property + def boardversion(self): + self._boardversion = self.COMMON_HEAD_VERSION + return self._boardversion + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, val): + self._FRUFileID = val + + @property + def boardPartNumber(self): + return self._boardPartNumber + + @boardPartNumber.setter + def boardPartNumber(self, val): + self._boardPartNumber = val + + @property + def boardSerialNumber(self): + return self._boardSerialNumber + + @boardSerialNumber.setter + def boardSerialNumber(self, val): + self._boardSerialNumber = val + + @property + def boardProductName(self): + return self._boradProductName + + @boardProductName.setter + def boardProductName(self, val): + self._boradProductName = val + + @property + def boardManufacturer(self): + return self._boardManufacturer + + @boardManufacturer.setter + def boardManufacturer(self, val): + self._boardManufacturer = val + + @property + def boardTime(self): + return self._boardTime + + @boardTime.setter + def boardTime(self, val): + self._boardTime = val + + @property + def fields(self): + return self._fields + + @fields.setter + def fields(self, val): + self._fields = val + + +class ProductInfoArea(BaseArea): + _productManufacturer = None + _productAssetTag = None + _FRUFileID = None + + def __str__(self): + formatstr = "version : %x\n" \ + "length : %d \n" \ + "language : %x \n" \ + "productManufacturer : %s \n" \ + "productName : %s \n" \ + "productPartModelName: %s \n" \ + "productVersion : %s \n" \ + "productSerialNumber : %s \n" \ + "productAssetTag : %s \n" \ + "fruFileId : %s \n" + + tmpstr = formatstr % (ord(self.areaversion), self.size, + self.language, self.productManufacturer, + self.productName, self.productPartModelName, + self.productVersion, self.productSerialNumber, + self.productAssetTag, self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + tmpstr += "productextra%d : %s \n" % (i, valtmpval) + else: + break + + return tmpstr + + def todict(self): + dic = collections.OrderedDict() + dic["productversion"] = ord(self.areaversion) + dic["productlength"] = self.size + dic["productlanguage"] = self.language + dic["productManufacturer"] = self.productManufacturer + dic["productName"] = self.productName + dic["productPartModelName"] = self.productPartModelName + dic["productVersion"] = int(self.productVersion, 16) + dic["productSerialNumber"] = self.productSerialNumber + dic["productAssetTag"] = self.productAssetTag + dic["productfruFileId"] = self.fruFileId + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + dic[valtmp] = valtmpval + else: + break + return dic + + def decodedata(self): + index = 0 + self.areaversion = self.data[index] # 0 + index += 1 + d_print("decode length %d" % (ord(self.data[index]) * 8)) + d_print("class size %d" % self.size) + index += 2 + + templen = FruUtil.decodeLength(self.data[index]) + self.productManufacturer = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productManufacturer:%s" % self.productManufacturer) + + templen = FruUtil.decodeLength(self.data[index]) + self.productName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productName:%s" % self.productName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productPartModelName = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productPartModelName:%s" % self.productPartModelName) + + templen = FruUtil.decodeLength(self.data[index]) + self.productVersion = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productVersion:%s" % self.productVersion) + + templen = FruUtil.decodeLength(self.data[index]) + self.productSerialNumber = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productSerialNumber:%s" % self.productSerialNumber) + + templen = FruUtil.decodeLength(self.data[index]) + self.productAssetTag = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode productAssetTag:%s" % self.productAssetTag) + + templen = FruUtil.decodeLength(self.data[index]) + self.fruFileId = self.data[index + 1: index + templen + 1] + index += templen + 1 + d_print("decode fruFileId:%s" % self.fruFileId) + + for i in range(1, 11): + valtmp = "productextra%d" % i + if self.data[index] != chr(0xc1) and index < self.size - 1: + templen = FruUtil.decodeLength(self.data[index]) + if templen == 0: + break + tmpval = self.data[index + 1: index + templen + 1] + d_print("decode boardextra%d:%s" % (i, tmpval)) + setattr(self, valtmp, tmpval) + index += templen + 1 + else: + break + + @property + def productVersion(self): + return self._productVersion + + @productVersion.setter + def productVersion(self, name): + self._productVersion = name + + @property + def areaversion(self): + self._areaversion = self.COMMON_HEAD_VERSION + return self._areaversion + + @areaversion.setter + def areaversion(self, name): + self._areaversion = name + + @property + def language(self): + self._language = 25 + return self._language + + @property + def productManufacturer(self): + return self._productManufacturer + + @productManufacturer.setter + def productManufacturer(self, name): + self._productManufacturer = name + + @property + def productName(self): + return self._productName + + @productName.setter + def productName(self, name): + self._productName = name + + @property + def productPartModelName(self): + return self._productPartModelName + + @productPartModelName.setter + def productPartModelName(self, name): + self._productPartModelName = name + + @property + def productSerialNumber(self): + return self._productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, name): + self._productSerialNumber = name + + @property + def productAssetTag(self): + return self._productAssetTag + + @productAssetTag.setter + def productAssetTag(self, name): + self._productAssetTag = name + + @property + def fruFileId(self): + return self._FRUFileID + + @fruFileId.setter + def fruFileId(self, name): + self._FRUFileID = name + + def recalcute(self): + d_print("product version:%x" % ord(self.areaversion)) + d_print("product length:%d" % self.size) + d_print("product language:%x" % self.language) + self.data = chr(ord(self.areaversion)) + \ + chr(self.size // 8) + chr(self.language) + + typelength = FruUtil.getTypeLength(self.productManufacturer) + self.data += chr(typelength) + self.data += self.productManufacturer + + self.data += chr(FruUtil.getTypeLength(self.productName)) + self.data += self.productName + + self.data += chr(FruUtil.getTypeLength(self.productPartModelName)) + self.data += self.productPartModelName + + self.data += chr(FruUtil.getTypeLength(self.productVersion)) + self.data += self.productVersion + + self.data += chr(FruUtil.getTypeLength(self.productSerialNumber)) + self.data += self.productSerialNumber + + self.data += chr(FruUtil.getTypeLength(self.productAssetTag)) + if self.productAssetTag is not None: + self.data += self.productAssetTag + + self.data += chr(FruUtil.getTypeLength(self.fruFileId)) + self.data += self.fruFileId + + for i in range(1, 11): + valtmp = "productextra%d" % i + if hasattr(self, valtmp): + valtmpval = getattr(self, valtmp) + d_print("boardInfoArea productextra%d:%s" % (i, valtmpval)) + self.data += chr(FruUtil.getTypeLength(valtmpval)) + if valtmpval is None: + pass + else: + self.data += valtmpval + else: + break + + self.data += chr(0xc1) + if len(self.data) > (self.size - 1): + incr = (len(self.data) - self.size) // 8 + 1 + self.size += incr * 8 + d_print("self.data:%d" % len(self.data)) + d_print("self.size:%d" % self.size) + + self.data = self.data[0:1] + chr(self.size // 8) + self.data[2:] + self.data = self.data.ljust((self.size - 1), chr(self.INITVALUE[0])) + checksum = FruUtil.checksum(self.data) + d_print("board info checksum:%x" % checksum) + self.data += chr(checksum) + + +class MultiRecordArea(BaseArea): + pass + + +class Field(object): + + def __init__(self, fieldType="ASCII", fieldData=""): + self.fieldData = fieldData + self.fieldType = fieldType + + @property + def data(self): + return self._data + + @property + def fieldType(self): + return self._fieldType + + @property + def fieldData(self): + return self._fieldData + + +class ipmifru(BaseArea): + _BoardInfoArea = None + _ProductInfoArea = None + _InternalUseArea = None + _ChassisInfoArea = None + _multiRecordArea = None + _productinfoAreaOffset = BaseArea.INITVALUE + _boardInfoAreaOffset = BaseArea.INITVALUE + _internalUserAreaOffset = BaseArea.INITVALUE + _chassicInfoAreaOffset = BaseArea.INITVALUE + _multiRecordAreaOffset = BaseArea.INITVALUE + _bindata = None + _bodybin = None + _version = BaseArea.COMMON_HEAD_VERSION + _zeroCheckSum = None + _frusize = 256 + + def __str__(self): + tmpstr = "" + if self.boardInfoArea.isPresent: + tmpstr += "\nboardinfoarea: \n" + tmpstr += self.boardInfoArea.__str__() + if self.productInfoArea.isPresent: + tmpstr += "\nproductinfoarea: \n" + tmpstr += self.productInfoArea.__str__() + return tmpstr + + def decodeBin(self, eeprom): + commonHead = eeprom[0:8] + d_print("decode version %x" % ord(commonHead[0])) + if ord(self.COMMON_HEAD_VERSION) != ord(commonHead[0]): + raise FruException("HEAD VERSION error,not Fru format!", -10) + if FruUtil.checksum(commonHead[0:7]) != ord(commonHead[7]): + strtemp = "check header checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(commonHead[0:7]), ord(commonHead[7])) + raise FruException(strtemp, -3) + if ord(commonHead[1]) != ord(self.INITVALUE): + d_print("Internal Use Area is present") + self.internalUseArea = InternalUseArea( + name="Internal Use Area", size=self.SUGGESTED_SIZE_INTERNAL_USE_AREA) + self.internalUseArea.isPresent = True + self.internalUserAreaOffset = ord(commonHead[1]) + self.internalUseArea.data = eeprom[self.internalUserAreaOffset * 8: ( + self.internalUserAreaOffset * 8 + self.internalUseArea.size)] + if ord(commonHead[2]) != ord(self.INITVALUE): + d_print("Chassis Info Area is present") + self.chassisInfoArea = ChassisInfoArea( + name="Chassis Info Area", size=self.SUGGESTED_SIZE_CHASSIS_INFO_AREA) + self.chassisInfoArea.isPresent = True + self.chassicInfoAreaOffset = ord(commonHead[2]) + self.chassisInfoArea.data = eeprom[self.chassicInfoAreaOffset * 8: ( + self.chassicInfoAreaOffset * 8 + self.chassisInfoArea.size)] + if ord(commonHead[3]) != ord(self.INITVALUE): + self.boardInfoArea = BoardInfoArea( + name="Board Info Area", size=self.SUGGESTED_SIZE_BOARD_INFO_AREA) + self.boardInfoArea.isPresent = True + self.boardInfoAreaOffset = ord(commonHead[3]) + self.boardInfoArea.size = ord( + eeprom[self.boardInfoAreaOffset * 8 + 1]) * 8 + d_print("Board Info Area is present size:%d" % + (self.boardInfoArea.size)) + self.boardInfoArea.data = eeprom[self.boardInfoAreaOffset * 8: ( + self.boardInfoAreaOffset * 8 + self.boardInfoArea.size)] + if FruUtil.checksum(self.boardInfoArea.data[:-1]) != ord(self.boardInfoArea.data[-1:]): + strtmp = "check boardInfoArea checksum error[cal:%02x data:%02x]" % \ + (FruUtil.checksum( + self.boardInfoArea.data[:-1]), ord(self.boardInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.boardInfoArea.decodedata() + if ord(commonHead[4]) != ord(self.INITVALUE): + d_print("Product Info Area is present") + self.productInfoArea = ProductInfoArea( + name="Product Info Area ", size=self.SUGGESTED_SIZE_PRODUCT_INFO_AREA) + self.productInfoArea.isPresent = True + self.productinfoAreaOffset = ord(commonHead[4]) + d_print("length offset value: %02x" % + ord(eeprom[self.productinfoAreaOffset * 8 + 1])) + self.productInfoArea.size = ord( + eeprom[self.productinfoAreaOffset * 8 + 1]) * 8 + d_print("Product Info Area is present size:%d" % + (self.productInfoArea.size)) + + self.productInfoArea.data = eeprom[self.productinfoAreaOffset * 8: ( + self.productinfoAreaOffset * 8 + self.productInfoArea.size)] + if FruUtil.checksum(self.productInfoArea.data[:-1]) != ord(self.productInfoArea.data[-1:]): + strtmp = "check productInfoArea checksum error [cal:%02x data:%02x]" % ( + FruUtil.checksum(self.productInfoArea.data[:-1]), ord(self.productInfoArea.data[-1:])) + raise FruException(strtmp, -3) + self.productInfoArea.decodedata() + if ord(commonHead[5]) != ord(self.INITVALUE): + self.multiRecordArea = MultiRecordArea( + name="MultiRecord record Area ") + d_print("MultiRecord record present") + self.multiRecordArea.isPresent = True + self.multiRecordAreaOffset = ord(commonHead[5]) + self.multiRecordArea.data = eeprom[self.multiRecordAreaOffset * 8: ( + self.multiRecordAreaOffset * 8 + self.multiRecordArea.size)] + + def initDefault(self): + self.version = self.COMMON_HEAD_VERSION + self.internalUserAreaOffset = self.INITVALUE + self.chassicInfoAreaOffset = self.INITVALUE + self.boardInfoAreaOffset = self.INITVALUE + self.productinfoAreaOffset = self.INITVALUE + self.multiRecordAreaOffset = self.INITVALUE + self.PAD = self.INITVALUE + self.zeroCheckSum = self.INITVALUE + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + self.productInfoArea = None + self.internalUseArea = None + self.boardInfoArea = None + self.chassisInfoArea = None + self.multiRecordArea = None + # self.recalcute() + + @property + def version(self): + return self._version + + @version.setter + def version(self, name): + self._version = name + + @property + def internalUserAreaOffset(self): + return self._internalUserAreaOffset + + @internalUserAreaOffset.setter + def internalUserAreaOffset(self, obj): + self._internalUserAreaOffset = obj + + @property + def chassicInfoAreaOffset(self): + return self._chassicInfoAreaOffset + + @chassicInfoAreaOffset.setter + def chassicInfoAreaOffset(self, obj): + self._chassicInfoAreaOffset = obj + + @property + def productinfoAreaOffset(self): + return self._productinfoAreaOffset + + @productinfoAreaOffset.setter + def productinfoAreaOffset(self, obj): + self._productinfoAreaOffset = obj + + @property + def boardInfoAreaOffset(self): + return self._boardInfoAreaOffset + + @boardInfoAreaOffset.setter + def boardInfoAreaOffset(self, obj): + self._boardInfoAreaOffset = obj + + @property + def multiRecordAreaOffset(self): + return self._multiRecordAreaOffset + + @multiRecordAreaOffset.setter + def multiRecordAreaOffset(self, obj): + self._multiRecordAreaOffset = obj + + @property + def zeroCheckSum(self): + return self._zeroCheckSum + + @zeroCheckSum.setter + def zeroCheckSum(self, obj): + self._zeroCheckSum = obj + + @property + def productInfoArea(self): + return self._ProductInfoArea + + @productInfoArea.setter + def productInfoArea(self, obj): + self._ProductInfoArea = obj + + @property + def internalUseArea(self): + return self._InternalUseArea + + @internalUseArea.setter + def internalUseArea(self, obj): + self.internalUseArea = obj + + @property + def boardInfoArea(self): + return self._BoardInfoArea + + @boardInfoArea.setter + def boardInfoArea(self, obj): + self._BoardInfoArea = obj + + @property + def chassisInfoArea(self): + return self._ChassisInfoArea + + @chassisInfoArea.setter + def chassisInfoArea(self, obj): + self._ChassisInfoArea = obj + + @property + def multiRecordArea(self): + return self._multiRecordArea + + @multiRecordArea.setter + def multiRecordArea(self, obj): + self._multiRecordArea = obj + + @property + def bindata(self): + return self._bindata + + @bindata.setter + def bindata(self, obj): + self._bindata = obj + + @property + def bodybin(self): + return self._bodybin + + @bodybin.setter + def bodybin(self, obj): + self._bodybin = obj + + def recalcuteCommonHead(self): + self.bindata = "" + self.offset = self.SUGGESTED_SIZE_COMMON_HEADER + d_print("common Header %d" % self.offset) + d_print("fru eeprom size %d" % self._frusize) + if self.internalUseArea is not None and self.internalUseArea.isPresent: + self.internalUserAreaOffset = self.offset // 8 + self.offset += self.internalUseArea.size + d_print("internalUseArea is present offset:%d" % self.offset) + + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + self.chassicInfoAreaOffset = self.offset // 8 + self.offset += self.chassisInfoArea.size + d_print("chassisInfoArea is present offset:%d" % self.offset) + + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + self.boardInfoAreaOffset = self.offset // 8 + self.offset += self.boardInfoArea.size + d_print("boardInfoArea is present offset:%d" % self.offset) + d_print("boardInfoArea is present size:%d" % + self.boardInfoArea.size) + + if self.productInfoArea is not None and self.productInfoArea.isPresent: + self.productinfoAreaOffset = self.offset // 8 + self.offset += self.productInfoArea.size + d_print("productInfoArea is present offset:%d" % self.offset) + + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + self.multiRecordAreaOffset = self.offset // 8 + d_print("multiRecordArea is present offset:%d" % self.offset) + + if self.internalUserAreaOffset == self.INITVALUE: + self.internalUserAreaOffset = 0 + if self.productinfoAreaOffset == self.INITVALUE: + self.productinfoAreaOffset = 0 + if self.chassicInfoAreaOffset == self.INITVALUE: + self.chassicInfoAreaOffset = 0 + if self.boardInfoAreaOffset == self.INITVALUE: + self.boardInfoAreaOffset = 0 + if self.multiRecordAreaOffset == self.INITVALUE: + self.multiRecordAreaOffset = 0 + + self.zeroCheckSum = (0x100 - ord(self.version) - self.internalUserAreaOffset - self.chassicInfoAreaOffset - self.productinfoAreaOffset + - self.boardInfoAreaOffset - self.multiRecordAreaOffset) & 0xff + d_print("zerochecksum:%x" % self.zeroCheckSum) + self.data = "" + self.data += chr(self.version[0]) + chr(self.internalUserAreaOffset) + chr(self.chassicInfoAreaOffset) + chr( + self.boardInfoAreaOffset) + chr(self.productinfoAreaOffset) + chr(self.multiRecordAreaOffset) + chr(self.INITVALUE[0]) + chr(self.zeroCheckSum) + + self.bindata = self.data + self.bodybin + totallen = len(self.bindata) + d_print("totallen %d" % totallen) + if (totallen < self._frusize): + self.bindata = self.bindata.ljust(self._frusize, chr(self.INITVALUE[0])) + else: + raise FruException('bin data more than %d' % self._frusize, -2) + + def recalcutebin(self): + self.bodybin = "" + if self.internalUseArea is not None and self.internalUseArea.isPresent: + d_print("internalUseArea present") + self.bodybin += self.internalUseArea.data + if self.chassisInfoArea is not None and self.chassisInfoArea.isPresent: + d_print("chassisInfoArea present") + self.bodybin += self.chassisInfoArea.data + if self.boardInfoArea is not None and self.boardInfoArea.isPresent: + d_print("boardInfoArea present") + self.boardInfoArea.recalcute() + self.bodybin += self.boardInfoArea.data + if self.productInfoArea is not None and self.productInfoArea.isPresent: + d_print("productInfoAreapresent") + self.productInfoArea.recalcute() + self.bodybin += self.productInfoArea.data + if self.multiRecordArea is not None and self.multiRecordArea.isPresent: + d_print("multiRecordArea present") + self.bodybin += self.productInfoArea.data + + def recalcute(self, fru_eeprom_size=256): + self._frusize = fru_eeprom_size + self.recalcutebin() + self.recalcuteCommonHead() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/onietlv.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/onietlv.py new file mode 100755 index 000000000000..e75063e8bde4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/eepromutil/onietlv.py @@ -0,0 +1,449 @@ +#!/usr/bin/python3 +import binascii + + +class OnietlvException(Exception): + def __init__(self, message='onietlverror', code=-100): + err = 'errcode: {0} message:{1}'.format(code, message) + Exception.__init__(self, err) + self.code = code + self.message = message + + +class onie_tlv(object): + TLV_INFO_ID_STRING = "TlvInfo\x00" + TLV_INFO_INIA_ID = "\x00\x00\x13\x11" + TLV_INFO_VERSION = 0x01 + TLV_INFO_LENGTH = 0x00 + TLV_INFO_LENGTH_VALUE = 0xba + + TLV_CODE_PRODUCT_NAME = 0x21 + TLV_CODE_PART_NUMBER = 0x22 + TLV_CODE_SERIAL_NUMBER = 0x23 + TLV_CODE_MAC_BASE = 0x24 + TLV_CODE_MANUF_DATE = 0x25 + TLV_CODE_DEVICE_VERSION = 0x26 + TLV_CODE_LABEL_REVISION = 0x27 + TLV_CODE_PLATFORM_NAME = 0x28 + TLV_CODE_ONIE_VERSION = 0x29 + TLV_CODE_MAC_SIZE = 0x2A + TLV_CODE_MANUF_NAME = 0x2B + TLV_CODE_MANUF_COUNTRY = 0x2C + TLV_CODE_VENDOR_NAME = 0x2D + TLV_CODE_DIAG_VERSION = 0x2E + TLV_CODE_SERVICE_TAG = 0x2F + TLV_CODE_VENDOR_EXT = 0xFD + TLV_CODE_CRC_32 = 0xFE + _TLV_DISPLAY_VENDOR_EXT = 1 + TLV_CODE_RJ_CARID = 0x01 + _TLV_INFO_HDR_LEN = 11 + TLV_CODE_PRODUCT_ID = 0x40 + TLV_CODE_HW_VERSION = 0x41 + TLV_CODE_MAIN_FILENAME = 0x42 + TLV_CODE_DTS_FINENAME = 0x43 + TLV_CODE_SY_SERIAL0 = 0x44 + TLV_CODE_SY_SERIAL1 = 0x45 + TLV_CODE_SY_SERIAL2 = 0x46 + TLV_CODE_SY_SERIAL3 = 0x47 + TLV_CODE_PROJECT_ID = 0x48 + TLV_CODE_SETMAC_VERSION = 0x49 + TLV_CODE_EEPROM_TYPE = 0x4A + + @property + def dstatus(self): + return self._dstatus + + @property + def cardid(self): + return self._cardid + + @property + def productname(self): + return self._productname + + @property + def partnum(self): + return self._partnum + + @property + def serialnum(self): + return self._serialnum + + @property + def macbase(self): + return self._macbase + + @property + def manufdate(self): + return self._manufdate + + @property + def deviceversion(self): + return self._deviceversion + + @property + def labelrevision(self): + return self._labelrevision + + @property + def platformname(self): + return self._platformname + + @property + def onieversion(self): + return self._onieversion + + @property + def macsize(self): + return self._macsize + + @property + def manufname(self): + return self._manufname + + @property + def manufcountry(self): + return self._manufcountry + + @property + def vendorname(self): + return self._vendorname + + @property + def diagname(self): + return self._diagname + + @property + def servicetag(self): + return self._servicetag + + @property + def vendorext(self): + return self._vendorext + + @property + def fanbus(self): + return self._fanbus + + @property + def fanloc(self): + return self._fanloc + + def __init__(self): + self._cardid = "" + self._productname = "" + self._partnum = "" + self._serialnum = "" + self._macbase = "" + self._manufdate = "" + self._deviceversion = "" + self._labelrevision = "" + self._platformname = "" + self._onieversion = "" + self._macsize = "" + self._manufname = "" + self._manufcountry = "" + self._vendorname = "" + self._diagname = "" + self._servicetag = "" + self._vendorext = "" + self._productid = "" + self._hwversion = "" + self._mainfilename = "" + self._dtsfilename = "" + self._syserial0 = "" + self._syserial1 = "" + self._syserial2 = "" + self._syserial3 = "" + self._projectid = "" + self._setmacversion = "" + self._eepromtype = "" + self._crc32 = "" + self._dstatus = 0 + + def oniecrc32(self, v): + data_array = bytearray() + for x in v: + data_array.append(ord(x)) + return '0x%08x' % (binascii.crc32(bytes(data_array)) & 0xffffffff) + + def getTLV_BODY(self, type, value): + x = [] + temp_t = "" + if type == self.TLV_CODE_MAC_BASE: + arr = value.split(':') + for tt in arr: + temp_t += chr(int(tt, 16)) + elif type == self.TLV_CODE_DEVICE_VERSION: + temp_t = chr(value) + elif type == self.TLV_CODE_MAC_SIZE: + temp_t = chr(value >> 8) + chr(value & 0x00ff) + else: + temp_t = value + x.append(chr(type)) + x.append(chr(len(temp_t))) + for i in temp_t: + x.append(i) + return x + + def generate_ext(self, cardid): + s = "%08x" % cardid + ret = "" + for t in range(0, 4): + ret += chr(int(s[2 * t:2 * t + 2], 16)) + ret = chr(0x01) + chr(len(ret)) + ret + return ret + + def generate_value(self, _t): + ret = [] + for i in self.TLV_INFO_ID_STRING: + ret.append(i) + ret.append(chr(self.TLV_INFO_VERSION)) + ret.append(chr(self.TLV_INFO_LENGTH)) + ret.append(chr(self.TLV_INFO_LENGTH_VALUE)) + + total_len = 0 + for key in _t: + x = self.getTLV_BODY(key, _t[key]) + ret += x + total_len += len(x) + ret[10] = chr(total_len + 6) + + ret.append(chr(0xFE)) + ret.append(chr(0x04)) + s = self.oniecrc32(''.join(ret)) + for t in range(0, 4): + ret.append(chr(int(s[2 * t + 2:2 * t + 4], 16))) + totallen = len(ret) + if (totallen < 256): + for left_t in range(0, 256 - totallen): + ret.append(chr(0x00)) + return (ret, True) + + def decode_tlv(self, e): + tlv_index = 0 + tlv_end = len(e) + ret = [] + while tlv_index < tlv_end and (tlv_index + 2 + ord(e[tlv_index + 1])) <= len(e): + rt = self.decoder(e[tlv_index:tlv_index + 2 + ord(e[tlv_index + 1])]) + ret.append(rt) + if ord(e[tlv_index]) == self.TLV_CODE_CRC_32: + break + tlv_index += ord(e[tlv_index + 1]) + 2 + return ret + + def decode(self, e): + if e[0:8] != self.TLV_INFO_ID_STRING: + raise OnietlvException("ONIE tlv head info error,not onie tlv type", -1) + total_len = (ord(e[9]) << 8) | ord(e[10]) + tlv_index = self._TLV_INFO_HDR_LEN + tlv_end = self._TLV_INFO_HDR_LEN + total_len + if tlv_end > len(e): + raise OnietlvException("ONIE tlv length error", -2) + ret = [] + ret = self.decode_tlv(e[tlv_index:tlv_end]) + for item in ret: + if item['code'] == self.TLV_CODE_VENDOR_EXT: + if item["value"][0:4] == self.TLV_INFO_INIA_ID: + rt = self.decode_tlv(item["value"][4:]) + else: + rt = self.decode_tlv(item["value"][0:]) + ret.extend(rt) + return ret + + def decoder(self, t): + if ord(t[0]) == self.TLV_CODE_PRODUCT_NAME: + name = "Product Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._productname = value + elif ord(t[0]) == self.TLV_CODE_PART_NUMBER: + name = "Part Number" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._partnum = value + elif ord(t[0]) == self.TLV_CODE_SERIAL_NUMBER: + name = "Serial Number" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._serialnum = value + elif ord(t[0]) == self.TLV_CODE_MAC_BASE: + name = "Base MAC Address" + _len = ord(t[1]) + value = ":".join(['%02X' % ord(T) for T in t[2:8]]).upper() + self._macbase = value + elif ord(t[0]) == self.TLV_CODE_MANUF_DATE: + name = "Manufacture Date" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._manufdate = value + elif ord(t[0]) == self.TLV_CODE_DEVICE_VERSION: + name = "Device Version" + _len = ord(t[1]) + value = ord(t[2]) + self._deviceversion = value + elif ord(t[0]) == self.TLV_CODE_LABEL_REVISION: + name = "Label Revision" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._labelrevision = value + elif ord(t[0]) == self.TLV_CODE_PLATFORM_NAME: + name = "Platform Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._platformname = value + elif ord(t[0]) == self.TLV_CODE_ONIE_VERSION: + name = "ONIE Version" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._onieversion = value + elif ord(t[0]) == self.TLV_CODE_MAC_SIZE: + name = "MAC Addresses" + _len = ord(t[1]) + value = str((ord(t[2]) << 8) | ord(t[3])) + self._macsize = value + elif ord(t[0]) == self.TLV_CODE_MANUF_NAME: + name = "Manufacturer" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._manufname = value + elif ord(t[0]) == self.TLV_CODE_MANUF_COUNTRY: + name = "Manufacture Country" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._manufcountry = value + elif ord(t[0]) == self.TLV_CODE_VENDOR_NAME: + name = "Vendor Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._vendorname = value + elif ord(t[0]) == self.TLV_CODE_DIAG_VERSION: + name = "Diag Version" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._diagname = value + elif ord(t[0]) == self.TLV_CODE_SERVICE_TAG: + name = "Service Tag" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._servicetag = value + elif ord(t[0]) == self.TLV_CODE_VENDOR_EXT: + name = "Vendor Extension" + _len = ord(t[1]) + value = "" + if self._TLV_DISPLAY_VENDOR_EXT: + value = t[2:2 + ord(t[1])] + self._vendorext = value + elif ord(t[0]) == self.TLV_CODE_CRC_32 and len(t) == 6: + name = "CRC-32" + _len = ord(t[1]) + value = "0x%08X" % (((ord(t[2]) << 24) | ( + ord(t[3]) << 16) | (ord(t[4]) << 8) | ord(t[5])),) + self._crc32 = value + elif ord(t[0]) == self.TLV_CODE_RJ_CARID: + name = "Card id" + _len = ord(t[1]) + value = "" + for c in t[2:2 + ord(t[1])]: + value += "%02X" % (ord(c),) + self._cardid = value + elif ord(t[0]) == self.TLV_CODE_PRODUCT_ID: + name = "Product id" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._productid = value + elif ord(t[0]) == self.TLV_CODE_HW_VERSION: + name = "Hardware Version" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._hwversion = value + elif ord(t[0]) == self.TLV_CODE_MAIN_FILENAME: + name = "Main File Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._mainfilename = value + elif ord(t[0]) == self.TLV_CODE_DTS_FINENAME: + name = "DTS File Name" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._dtsfilename = value + elif ord(t[0]) == self.TLV_CODE_SY_SERIAL0: + name = "SY Serial 0" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._syserial0 = value + elif ord(t[0]) == self.TLV_CODE_SY_SERIAL1: + name = "SY Serial 1" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._syserial1 = value + elif ord(t[0]) == self.TLV_CODE_SY_SERIAL2: + name = "SY Serial 2" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._syserial2 = value + elif ord(t[0]) == self.TLV_CODE_SY_SERIAL3: + name = "SY Serial 3" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._syserial3 = value + elif ord(t[0]) == self.TLV_CODE_PROJECT_ID: + name = "Project id" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._projectid = value + elif ord(t[0]) == self.TLV_CODE_SETMAC_VERSION: + name = "Setmac Version" + _len = ord(t[1]) + value = t[2:2 + ord(t[1])] + self._setmacversion = value + elif ord(t[0]) == self.TLV_CODE_EEPROM_TYPE: + name = "EEPROM Type" + _len = ord(t[1]) + value = "" + for c in t[2:2 + ord(t[1])]: + value += "%02X" % (ord(c),) + self._eepromtype = value + else: + name = "Unknown" + _len = ord(t[1]) + value = "" + for c in t[2:2 + ord(t[1])]: + value += "0x%02X " % (ord(c),) + return {"name": name, "code": ord(t[0]), "value": value, "lens": _len} + + def __str__(self): + formatstr = "Card id : %s \n" \ + "Product Name : %s \n" \ + "Part Number : %s \n" \ + "Serial Number : %s \n" \ + "Base MAC Address : %s \n" \ + "Manufacture Date : %s \n" \ + "Device Version : %s \n" \ + "Label Revision : %s \n" \ + "Platform Name : %s \n" \ + "ONIE Version : %s \n" \ + "MAC Addresses : %s \n" \ + "Manufacturer : %s \n" \ + "Manufacture Country : %s \n" \ + "Vendor Name : %s \n" \ + "Diag Version : %s \n" \ + "Service Tag : %s \n" \ + "CRC-32 : %s \n" + return formatstr % (self._cardid, + self._productname, + self._partnum, + self._serialnum, + self._macbase, + self._manufdate, + self._deviceversion, + self._labelrevision, + self._platformname, + self._onieversion, + self._macsize, + self._manufname, + self._manufcountry, + self._vendorname, + self._diagname, + self._servicetag, + self._crc32) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/baseutil.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/baseutil.py new file mode 100755 index 000000000000..33d559a39d0f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/baseutil.py @@ -0,0 +1,141 @@ +#!/usr/bin/env python3 +####################################################### +# +# baseutil.py +# Python implementation of the Class baseutil +# Original author: rd@ruijie.com.cn +# +####################################################### +import importlib.machinery +import os +import syslog +from plat_hal.osutil import osutil + +SYSLOG_IDENTIFIER = "HAL" + +CONFIG_DB_PATH = "/etc/sonic/config_db.json" +BOARD_ID_PATH = "/sys/module/ruijie_common/parameters/dfd_my_type" + + +def getonieplatform(path): + if not os.path.isfile(path): + return "" + machine_vars = {} + with open(path) as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars.get("onie_platform") + + +def getboardid(): + if not os.path.exists(BOARD_ID_PATH): + return "NA" + with open(BOARD_ID_PATH) as fd: + id_str = fd.read().strip() + return "0x%x" % (int(id_str, 10)) + + +def getplatform_config_db(): + if not os.path.isfile(CONFIG_DB_PATH): + return "" + val = os.popen("sonic-cfggen -j %s -v DEVICE_METADATA.localhost.platform" % CONFIG_DB_PATH).read().strip() + if len(val) <= 0: + return "" + else: + return val + + +def getplatform_name(): + if os.path.isfile('/host/machine.conf'): + return getonieplatform('/host/machine.conf') + elif os.path.isfile('/usr/share/sonic/hwsku/machine.conf'): + return getonieplatform('/usr/share/sonic/hwsku/machine.conf') + else: + return getplatform_config_db() + + +CONFIG_FILE_LIST = ["/usr/local/bin/", "/usr/lib/python3/dist-packages/", "/usr/local/lib/python3.7/dist-packages/hal-config/", "/usr/local/lib/python3.9/dist-packages/hal-config/"] + +platform = (getplatform_name()).replace("-", "_") +boardid = getboardid() + +boardid_devicefile = (platform + "_"+ boardid + "_device.py") +boardid_monitorfile = (platform + "_"+ boardid + "_monitor.py") + +devicefile = (platform + "_device.py") +monitorfile = (platform + "_monitor.py") + + +class baseutil: + + CONFIG_NAME = 'devices' + MONITOR_CONFIG_NAME = 'monitor' + UBOOT_ENV_URL = '/etc/device/uboot_env' + + @staticmethod + def get_config(): + real_path = None + for configfile_path in CONFIG_FILE_LIST: + boardid_config_file_path = (configfile_path + boardid_devicefile) + config_file_path = (configfile_path + devicefile) + if os.path.exists(boardid_config_file_path): + real_path = boardid_config_file_path + break + elif os.path.exists(config_file_path): + real_path = config_file_path + break + if real_path is None: + raise Exception("get hal device config error") + devices = importlib.machinery.SourceFileLoader(baseutil.CONFIG_NAME, real_path).load_module() + return devices.devices + + @staticmethod + def get_monitor_config(): + real_path = None + for configfile_path in CONFIG_FILE_LIST: + boardid_config_file_path = (configfile_path + boardid_monitorfile) + config_file_path = (configfile_path + monitorfile) + if os.path.exists(boardid_config_file_path): + real_path = boardid_config_file_path + break + elif os.path.exists(config_file_path): + real_path = config_file_path + break + if real_path is None: + raise Exception("get hal monitor config error") + monitor = importlib.machinery.SourceFileLoader(baseutil.MONITOR_CONFIG_NAME, real_path).load_module() + return monitor.monitor + + @staticmethod + def get_productname(): + ret, val = osutil.command("cat %s |grep productname | awk -F\"=\" '{print $2;}'" % baseutil.UBOOT_ENV_URL) + tmp = val.lower().replace('-', '_') + if ret != 0 or len(val) <= 0: + raise Exception("get productname error") + else: + return tmp + + @staticmethod + def get_platform(): + ret, val = osutil.command("cat %s |grep conffitname | awk -F\"=\" '{print $2;}'" % baseutil.UBOOT_ENV_URL) + if ret != 0 or len(val) <= 0: + raise Exception("get platform error") + else: + return val + + @staticmethod + def get_product_fullname(): + ret, val = osutil.command("cat %s |grep productname | awk -F\"=\" '{print $2;}'" % baseutil.UBOOT_ENV_URL) + if ret != 0 or len(val) <= 0: + raise Exception("get productname error") + else: + return val + + @staticmethod + def logger_debug(msg): + syslog.openlog(SYSLOG_IDENTIFIER) + syslog.syslog(syslog.LOG_DEBUG, msg) + syslog.closelog() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/chassisbase.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/chassisbase.py new file mode 100755 index 000000000000..b1b08e12bc7a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/chassisbase.py @@ -0,0 +1,322 @@ +#!/usr/bin/env python3 +####################################################### +# +# chassisbase.py +# Python implementation of the Class chassisbase +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.dcdc import dcdc +from plat_hal.onie_e2 import onie_e2 +from plat_hal.psu import psu +from plat_hal.led import led +from plat_hal.temp import temp +from plat_hal.fan import fan +from plat_hal.cpld import cpld +from plat_hal.component import component +from plat_hal.cpu import cpu +from plat_hal.baseutil import baseutil + + +class chassisbase(object): + __onie_e2_list = [] + __psu_list = [] + __led_list = [] + __temp_list = [] + __fan_list = [] + __card_list = [] + __sensor_list = [] + __dcdc_list = [] + __cpld_list = [] + __comp_list = [] + __bios_list = [] + __bmc_list = [] + __cpu = None + + def __init__(self, conftype=0, conf=None): + # type: (object, object, object) -> object + """ + init chassisbase as order + + type = 0 use default conf, maybe auto find by platform + type = 1 use given conf, conf is not None + + BITMAP + bit 16 + bit 0 PSU + bit 1 LED + bit 2 TEMP + bit 3 fan + bit 4 card + bit 5 sensor + """ + __confTemp = None + + if conftype == 0: + # user + __confTemp = baseutil.get_config() + elif conftype == 1: + __confTemp = conf + + # onie_e2 + onie_e2temp = [] + onie_e2config = __confTemp.get('onie_e2', []) + for i in range(len((onie_e2config))): + onie_e2_1 = onie_e2(onie_e2config[i]) + onie_e2temp.append(onie_e2_1) + self.onie_e2_list = onie_e2temp + + # psu + psutemp = [] + psuconfig = __confTemp.get('psus', []) + for i in range(len((psuconfig))): + psu1 = psu(psuconfig[i]) + psutemp.append(psu1) + self.psu_list = psutemp + + # led + ledtemp = [] + ledconfig = __confTemp.get('leds', []) + for i in range(len((ledconfig))): + led1 = led(ledconfig[i]) + ledtemp.append(led1) + self.led_list = ledtemp + + # temp + temptemp = [] + tempconfig = __confTemp.get('temps', []) + for i in range(len((tempconfig))): + temp1 = temp(tempconfig[i]) + temptemp.append(temp1) + self.temp_list = temptemp + + # fan + fantemp = [] + fanconfig = __confTemp.get('fans', []) + for i in range(len((fanconfig))): + fan1 = fan(fanconfig[i]) + fantemp.append(fan1) + self.fan_list = fantemp + + # dcdc + dcdctemp = [] + dcdcconfig = __confTemp.get('dcdc', []) + for i in dcdcconfig: + dcdc1 = dcdc(i) + dcdctemp.append(dcdc1) + self.dcdc_list = dcdctemp + + # cpld + cpldtemp = [] + cpldconfig = __confTemp.get('cplds', []) + for i in range(len((cpldconfig))): + cpld1 = cpld(cpldconfig[i]) + cpldtemp.append(cpld1) + self.cpld_list = cpldtemp + + # compoment: cpld/fpga/bios + comptemp = [] + compconfig = __confTemp.get('comp_cpld', []) + for i in range(len((compconfig))): + comp1 = component(compconfig[i]) + comptemp.append(comp1) + self.comp_list = comptemp + + compconfig = __confTemp.get('comp_fpga', []) + for i in range(len((compconfig))): + comp1 = component(compconfig[i]) + self.comp_list.append(comp1) + + compconfig = __confTemp.get('comp_bios', []) + for i in range(len((compconfig))): + comp1 = component(compconfig[i]) + self.comp_list.append(comp1) + + # cpu + cpuconfig = __confTemp.get('cpu', []) + if len(cpuconfig): + self.cpu = cpu(cpuconfig[0]) + + # dcdc + @property + def dcdc_list(self): + return self.__dcdc_list + + @dcdc_list.setter + def dcdc_list(self, val): + self.__dcdc_list = val + + # sensor + @property + def sensor_list(self): + return self.__sensor_list + + @sensor_list.setter + def sensor_list(self, val): + self.__sensor_list = val + + def get_sensor_byname(self, name): + tmp = self.sensor_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # onie_e2 + @property + def onie_e2_list(self): + return self.__onie_e2_list + + @onie_e2_list.setter + def onie_e2_list(self, val): + self.__onie_e2_list = val + + def get_onie_e2_byname(self, name): + tmp = self.onie_e2_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # psu + @property + def psu_list(self): + return self.__psu_list + + @psu_list.setter + def psu_list(self, val): + self.__psu_list = val + + def get_psu_byname(self, name): + tmp = self.psu_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # fan + @property + def fan_list(self): + return self.__fan_list + + @fan_list.setter + def fan_list(self, val): + self.__fan_list = val + + def get_fan_byname(self, name): + tmp = self.fan_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # led + + @property + def led_list(self): + return self.__led_list + + @led_list.setter + def led_list(self, val): + self.__led_list = val + + def get_ledlist_config(self): + pass + + def get_led_byname(self, name): + tmp = self.led_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # temp + @property + def temp_list(self): + return self.__temp_list + + @temp_list.setter + def temp_list(self, val): + self.__temp_list = val + + def get_temp_byname(self, name): + tmp = self.temp_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # cpld + @property + def cpld_list(self): + return self.__cpld_list + + @cpld_list.setter + def cpld_list(self, val): + self.__cpld_list = val + + def get_cpld_byname(self, name): + tmp = self.cpld_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + @property + def comp_list(self): + return self.__comp_list + + @comp_list.setter + def comp_list(self, val): + self.__comp_list = val + + def get_comp_byname(self, name): + tmp = self.comp_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # bios + @property + def bios_list(self): + return self.__bios_list + + @bios_list.setter + def bios_list(self, val): + self.__bios_list = val + + def get_bios_byname(self, name): + tmp = self.bios_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # bmc + @property + def bmc_list(self): + return self.__bmc_list + + @bmc_list.setter + def bmc_list(self, val): + self.__bmc_list = val + + def get_bmc_byname(self, name): + tmp = self.bmc_list + for i in range(len(tmp)): + if name == tmp[i].name: + return tmp[i] + return None + + # cpu + @property + def cpu(self): + return self.__cpu + + @cpu.setter + def cpu(self, val): + self.__cpu = val + + def get_cpu_byname(self, name): + return self.cpu diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/component.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/component.py new file mode 100755 index 000000000000..2a85e518d31e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/component.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +####################################################### +# +# component.py +# Python implementation of the Class fan +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from plat_hal.osutil import osutil + +class component(devicebase): + __user_reg = None + + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.version_file = conf.get('VersionFile', None) + self.comp_id = conf.get("comp_id", None) + self.desc = conf.get("desc", None) + self.slot = conf.get("slot", None) + + def get_version(self): + version = "NA" + try: + ret, version = self.get_value(self.version_file) + if (ret == False): + return version + pattern = self.version_file.get('pattern', None) + version = osutil.std_match(version, pattern) + except Exception as e: + return version + return version diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpld.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpld.py new file mode 100755 index 000000000000..594a248b379b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpld.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +####################################################### +# +# fan.py +# Python implementation of the Class fan +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase + + +class cpld(devicebase): + __user_reg = None + + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.user_reg = conf.get('UserReg', None) + self.console_reg = conf.get('ConsoleReg', None) + self.console_reg_attrs = conf.get('ConsoleRegAttrs', None) + self.version_file = conf.get('VersionFile', None) + self.cpld_id = conf.get("cpld_id", None) + self.desc = conf.get("desc", None) + self.slot = conf.get("slot", None) + self.format = conf.get("format", "big_endian") + + def get_user_reg(self): + if (self.user_reg is None): + return False + ret, val = self.get_value(self.user_reg) + return val + + def set_user_reg(self, value): + if (self.user_reg is None): + return False + byte = value & 0xFF + ret, val = self.set_value(self.user_reg, byte) + return ret + + def set_console_owner(self, owner): + ret = False + + if (self.console_reg is None): + return False + tmpattr = self.console_reg_attrs.get(owner, None) + if tmpattr is not None: + ret, val = self.set_value(self.console_reg, tmpattr) + return ret + + def get_version(self): + ret, val = self.get_value(self.version_file) + if (ret == False): + val = "N/A" + return val + val = val.strip('\n').split(" ") + if len(val) < 4: + val = "N/A" + return val + if self.format == "little_endian": + cpld_version = "%s%s%s%s" % (val[3], val[2], val[1], val[0]) + else: + cpld_version = "%s%s%s%s" % (val[0], val[1], val[2], val[3]) + return cpld_version diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpu.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpu.py new file mode 100755 index 000000000000..d89394a579f5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/cpu.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +############################################################################### +# +# Hardware Abstraction Layer APIs -- CPU APIs. +# +# Copyright (C) Ruijie, INC. +# +############################################################################### +from plat_hal.devicebase import devicebase + + +class cpu(devicebase): + + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.cpu_reset_cnt_reg = conf.get('CpuResetCntReg', None) + + def get_cpu_reset_num(self): + """ + get cpu reset num. + @return cpu reset number, -1 for failure + """ + ret = -1 + if self.cpu_reset_cnt_reg is None: + self.logger_debug("ERR: no support get cpu reset num") + return ret + ret, reset_num = self.get_value(self.cpu_reset_cnt_reg) + if ret is False or reset_num is None: + self.logger_debug("ERR: i2c read cpu_reset_cnt_reg,result:%s" % reset_num) + else: + if isinstance(reset_num, str): + ret = int(reset_num, 16) + else: + ret = reset_num + return ret diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/dcdc.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/dcdc.py new file mode 100755 index 000000000000..ba604995043d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/dcdc.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +from plat_hal.devicebase import devicebase +from plat_hal.sensor import sensor + + +class dcdc(devicebase): + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.dcdc_id = conf.get("dcdc_id", None) + self.sensor = sensor(conf) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/devicebase.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/devicebase.py new file mode 100755 index 000000000000..8574962f36ac --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/devicebase.py @@ -0,0 +1,223 @@ +#!/usr/bin/env python3 +####################################################### +# +# devicebase.py +# Python implementation of the Class devicebase +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.osutil import osutil +from plat_hal.baseutil import baseutil +import subprocess + + +class devicebase(object): + _name = None + __error_ret = -99999 + + @property + def name(self): + return self._name + + @name.setter + def name(self, val): + self._name = val + + def dumpValueByI2c(self, bus, loc): + str = "" + for i in range(256): + ret, val = self.get_i2c(bus, loc, i) + str += chr(val) + return str + + def byteTostr(self, val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + def get_eeprom_info(self, conf): + if conf.get('way') == 'sysfs' or conf.get('way') == 'devfile': + ret, eeprom = self.get_value(conf) + if ret is False: + return None + else: + eeprom = self.dumpValueByI2c(conf.get('bus'), conf.get('addr')) + return eeprom + + def exec_os_cmd(self, cmd): + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + return proc.returncode, stdout + + def get_value(self, config): + ''' + get value by config way + way i2c/sysfs/lpc + ''' + way = config.get("way") + if way == 'sysfs': + return self.get_sysfs(config.get("loc"), config.get("flock_path")) + elif way == "i2c": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.get_i2c(bus, addr, offset) + elif way == "io": + io_addr = config.get('io_addr') + read_len = config.get('read_len', 1) + return self.get_io(io_addr, read_len) + elif way == "i2cword": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.get_i2cword(bus, addr, offset) + elif way == "devmem": + addr = config.get("addr") + digit = config.get("digit") + mask = config.get("mask", None) + return self.get_devmem(addr, digit, mask) + elif way == "sdk": + type = config.get("type") + if type == "bcm_temp": + return self.getbcmtemp() + elif type == "bcm_reg": + reg = config.get("reg") + return self.getbcmreg(reg) + else: + raise Exception("cannot found sdk type deal") + elif way == "devfile": + loc = config.get("loc") + offset = config.get("offset") + len = config.get("len") + return self.devfile_read(loc, offset, len) + elif way == "devfile_ascii": + loc = config.get("loc") + offset = config.get("offset") + len = config.get("len") + return self.devfile_read_ascii(loc, offset, len) + elif way == 'cmd': + cmd = config.get("cmd") + ret, log = self.exec_os_cmd(cmd) + if ret: + return False, ("cmd write exec %s failed, log: %s" % (cmd, log)) + else: + return True, log + else: + raise Exception("cannot found way deal") + + def devfile_read(self, loc, offset, len): + return osutil.readdevfile(loc, offset, len) + + def devfile_read_ascii(self, loc, offset, len): + return osutil.readdevfile_ascii(loc, offset, len) + + def get_sysfs(self, loc, flock_path=None): + return self.getsysfs(loc, flock_path) + + def getsysfs(self, loc, flock_path=None): + ret, val = osutil.readsysfs(loc, flock_path) + return ret, val + + def get_devmem(self, addr, digit, mask): + return osutil.getdevmem(addr, digit, mask) + + def get_i2cword(self, bus, addr, offset): + return self.geti2cword(bus, addr, offset) + + def geti2cword(self, bus, addr, offset): + ret, val = osutil.geti2cword(bus, addr, offset) + return ret, val + + def get_io(self, reg_addr, read_len): + return self.getio(reg_addr, read_len) + + def getio(self, reg_addr, read_len): + ret, val = osutil.io_rd(reg_addr, read_len) + return ret, val + + def get_i2c(self, bus, addr, offset): + return self.geti2c(bus, addr, offset) + + def geti2c(self, bus, addr, offset): + ret, val = osutil.rji2cget(bus, addr, offset) + return ret, val + + def set_value(self, config, val): + ''' + get value by config way + way i2c/sysfs/lpc + ''' + way = config.get("way") + if way == 'sysfs': + return self.set_sysfs(config.get("loc"), "0x%02x" % val) + elif way == "i2c": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.set_i2c(bus, addr, offset, val) + elif way == "i2cpec": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.seti2c_byte_pec(bus, addr, offset, val) + elif way == 'i2cword': + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.set_i2cword(bus, addr, offset, val) + elif way == "i2cwordpec": + bus = config.get("bus") + addr = config.get("addr") + offset = config.get("offset") + return self.set_i2cwordpec(bus, addr, offset, val) + return False, "unsupport ways: %s" % way + + def set_sysfs(self, loc, value): + return self.setsysfs(loc, value) + + def setsysfs(self, loc, value): + return osutil.writesysfs(loc, value) + + def set_i2cword(self, bus, addr, offset, byte): + return self.seti2cword(bus, addr, offset, byte) + + def seti2cword(self, bus, addr, offset, byte): + return osutil.seti2cword(bus, addr, offset, byte) + + def set_i2cwordpec(self, bus, addr, offset, val): + return osutil.seti2cwordpec(bus, addr, offset, val) + + def seti2c_byte_pec(self, bus, addr, offset, val): + return osutil.seti2c_byte_pec(bus, addr, offset, val) + + def set_i2c(self, bus, addr, offset, byte): + return self.seti2c(bus, addr, offset, byte) + + def seti2c(self, bus, addr, offset, byte): + ret, val = osutil.rji2cset(bus, addr, offset, byte) + return ret, val + + def getbcmtemp(self): + try: + sta, ret = osutil.getmactemp() + if sta == True: + mac_aver = float(ret.get("average", self.__error_ret)) + mac_aver = mac_aver * 1000 + else: + return False, ret + except AttributeError as e: + return False, str(e) + return True, mac_aver + + def getbcmreg(self, reg): + ret, val = osutil.getsdkreg(reg) + return ret, val + + def logger_debug(self, msg): + baseutil.logger_debug(msg) + + def command(self, cmd): + ret, output = osutil.command(cmd) + return ret, output diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/fan.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/fan.py new file mode 100755 index 000000000000..5799dfb9981c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/fan.py @@ -0,0 +1,381 @@ +#!/usr/bin/env python3 +####################################################### +# +# fan.py +# Python implementation of the Class fan +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from eepromutil.fru import ipmifru +from plat_hal.rotor import rotor + + +class fan(devicebase): + __rotor_list = [] + __pn = None + __raweeprom = None + __sn = None + __hw_version = None + __present = None + __e2loc = None + __rotors = None + __AirFlow = None + __SpeedMin = None + __SpeedMax = None + __productName = None + __productSerialNumber = None + __WatchdogStatus = None + __led_attrs_config = None + __led_config = None + __WatchdogStatus_config = None + __AirFlowconifg = None + __EnableWatchdogConf = None + __Rotor_config = None + __fan_display_name = None # 'N/A' + __fan_display_name_conifg = None + + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.sn = conf.get('sn', None) + self.present = conf.get('present', None) + self.e2loc = conf.get('e2loc', None) + self.SpeedMin = conf.get('SpeedMin', None) + self.SpeedMax = conf.get('SpeedMax', None) + self.AirFlowconifg = conf.get("airflow", None) + self.WatchdogStatus_config = conf.get('WatchdogStatus', None) + self.EnableWatchdogConf = conf.get('EnableWatchdogConf', None) + self.led_attrs_config = conf.get('led_attrs', None) + self.led_config = conf.get('led', None) + self.Rotor_config = conf.get('Rotor', None) + self.fan_display_name_conifg = conf.get("fan_display_name", None) + rotor_tmp = [] + for key, value in (self.Rotor_config).items(): + rotor_tmp.append(rotor(value)) + rotor_tmp.sort(key=lambda x: x.name, reverse=False) + self.rotor_list = rotor_tmp + self.rotors = len(self.rotor_list) + + @property + def EnableWatchdogConf(self): + return self.__EnableWatchdogConf + + @EnableWatchdogConf.setter + def EnableWatchdogConf(self, val): + self.__EnableWatchdogConf = val + + @property + def rotor_list(self): + return self.__rotor_list + + @rotor_list.setter + def rotor_list(self, val): + self.__rotor_list = val + + @property + def Rotor_config(self): + return self.__Rotor_config + + @Rotor_config.setter + def Rotor_config(self, val): + self.__Rotor_config = val + + @property + def productName(self): + return self.__productName + + @productName.setter + def productName(self, val): + self.__productName = val + + @property + def productSerialNumber(self): + return self.__productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, val): + self.__productSerialNumber = val + + @property + def hw_version(self): + return self.__hw_version + + @hw_version.setter + def hw_version(self, val): + self.__hw_version = val + + @property + def sn(self): + return self.__sn + + @sn.setter + def sn(self, val): + self.__sn = val + + @property + def pn(self): + return self.__pn + + @pn.setter + def pn(self, val): + self.__pn = val + + @property + def raweeprom(self): + return self.__raweeprom + + @raweeprom.setter + def raweeprom(self, val): + self.__raweeprom = val + + @property + def SpeedMax(self): + return self.__SpeedMax + + @SpeedMax.setter + def SpeedMax(self, val): + self.__SpeedMax = val + + @property + def SpeedMin(self): + return self.__SpeedMin + + @SpeedMin.setter + def SpeedMin(self, val): + self.__SpeedMin = val + + @property + def rotors(self): + return self.__rotors + + @property + def AirFlow(self): + return self.__AirFlow + + @AirFlow.setter + def AirFlow(self, val): + self.__AirFlow = val + + @rotors.setter + def rotors(self, val): + self.__rotors = val + + @property + def fan_display_name_conifg(self): + return self.__fan_display_name_conifg + + @fan_display_name_conifg.setter + def fan_display_name_conifg(self, val): + self.__fan_display_name_conifg = val + + @property + def fan_display_name(self): + return self.__fan_display_name + + @fan_display_name.setter + def fan_display_name(self, val): + self.__fan_display_name = val + + def getspeed(self, conf): + tmp = None + if conf is None: + return -1 + ret, val = self.get_value(conf) + if ret == True: + tmp = int(str(val), 10) + else: + val = None + if val is not None: + return int(15000000 / tmp) + return -1 + + def get_speed(self, rotor_index): + rotor = self.get_rotor_index(rotor_index) + if rotor is None: + return None + speed = rotor.rotor_Speed.Value + if speed is None: + return None + return int(speed) + + def set_led(self, color): + status = self.led_attrs_config.get(color, None) + if status is None: + return False + + mask = self.led_attrs_config.get('mask', 0xff) + ret, value = self.get_value(self.led_config) + if ret is False or value is None: + return False + setval = (int(value) & ~mask) | (status) + ret, val = self.set_value(self.led_config, setval) + return ret + + def get_led(self): + mask = self.led_attrs_config.get('mask', 0xff) + ret, value = self.get_value(self.led_config) + if ret is False or value is None: + return False, 'N/A' + ledval = (int(value) & mask) + for key, val in self.led_attrs_config.items(): + if (ledval == val) and (key != "mask"): + return True, key + return False, 'N/A' + + def set_speed(self, rotor_index, level): + if level > 255 or level < 0: + return False + rotor = self.get_rotor_index(rotor_index) + if rotor is None: + return False + ret, val = self.set_value(rotor.Speedconfig, int(level)) + return ret + + def get_rotor_index(self, rotor_index): + if rotor_index > len(self.rotor_list): + return None + rotor = self.rotor_list[rotor_index - 1] + return rotor + + def get_rotor_byname(self, rotor_index): + for rotor in self.rotor_list: + if rotor.name == rotor_index: + return rotor + return None + + def get_presence(self): + ret, val = self.get_value(self.present) + if ret is False or val is None: + return -1 + if isinstance(val, str): + value = int(val, 16) + else: + value = val + mask = self.present.get("mask") + flag = value & mask + okval = self.present.get("okval", 0) + if flag == okval: + return True + else: + return False + + def get_speed_pwm(self, rotor_index): + rotor = self.get_rotor_index(rotor_index) + if rotor is None: + return False + if rotor.i2c_speed is None: + return False + val = round(rotor.i2c_speed * 100 / 255) + return val + + def feed_watchdog(self, pwm): + ret = False + for rotor in self.rotor_list: + ret, val = rotor.feed_watchdog() + if ret is False: + return ret + return ret + + def get_fru_info(self): + try: + if self.get_presence() is False: + raise Exception("%s: not present" % self.name) + eeprom = self.get_eeprom_info(self.e2loc) + if eeprom is None: + raise Exception("%s: value is none" % self.name) + fru = ipmifru() + if isinstance(eeprom, bytes): + eeprom = self.byteTostr(eeprom) + fru.decodeBin(eeprom) + self.productName = fru.productInfoArea.productName.strip() # PN + self.productSerialNumber = fru.productInfoArea.productSerialNumber.strip() # SN + self.hw_version = fru.productInfoArea.productVersion.strip() # HW + except Exception as e: + self.productName = None + self.productSerialNumber = None + self.hw_version = None + return False + return True + + def decode_eeprom_info(self): + '''get fan name, hw version, sn''' + return self.get_fru_info() + + def get_AirFlow(self): + if self.productName is None: + ret = self.decode_eeprom_info() + if ret is False: + self.AirFlow = None + return False + if self.AirFlowconifg is None: + self.AirFlow = None + return False + else: + for i in self.AirFlowconifg: + if self.productName in self.AirFlowconifg[i]: + self.AirFlow = i + return True + self.AirFlow = None + return False + + def enable_watchdog(self, enable, timeout_sec): + ret = False + if enable == True: + byte = self.EnableWatchdogConf.get("enable_byte", None) + ret, val = self.set_value(self.EnableWatchdogConf, byte) + elif enable == False: + byte = self.EnableWatchdogConf.get("disable_byte", None) + ret, val = self.set_value(self.EnableWatchdogConf, byte) + return ret + + def get_watchdog_status(self): + dic = {"support": None, "open": None, "work_full": None, "work_allow_set": None} + if self.WatchdogStatus_config is None: + return None + ret, val = self.get_value(self.WatchdogStatus_config) + if ret is False or val is None: + return None + support_watchdog_off = self.WatchdogStatus_config.get("support_watchdog_off", None) + is_open_off = self.WatchdogStatus_config.get("is_open_off", None) + full_running_off = self.WatchdogStatus_config.get("full_running_off", None) + running_setting_off = self.WatchdogStatus_config.get("running_setting_off", None) + if support_watchdog_off is not None: + if support_watchdog_off & val == self.WatchdogStatus_config.get("support_watchdog_mask", None): + dic["support"] = True + else: + dic["support"] = False + return dic + if is_open_off is not None: + if is_open_off & val == self.WatchdogStatus_config.get("is_open_mask", None): + dic["open"] = True + else: + dic["open"] = False + if full_running_off is not None: + if full_running_off & val == self.WatchdogStatus_config.get("full_running_mask", None): + dic["work_full"] = True + else: + dic["work_full"] = False + if running_setting_off is not None: + if running_setting_off & val == self.WatchdogStatus_config.get("running_setting_mask", None): + dic["work_allow_set"] = True + else: + dic["work_allow_set"] = False + return dic + + def get_fan_display_name(self): + if self.productName is None: + ret = self.get_fru_info() + if ret is False: + self.fan_display_name = None + return False + if self.fan_display_name_conifg is None: + self.fan_display_name = self.productName + return False + else: + for i in self.fan_display_name_conifg: + if self.productName in self.fan_display_name_conifg[i]: + self.fan_display_name = i + return True + self.fan_display_name = self.productName + return False diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/interface.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/interface.py new file mode 100755 index 000000000000..43ffa7d4f29c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/interface.py @@ -0,0 +1,1331 @@ +#!/usr/bin/env python3 +####################################################### +# +# interface.py +# Python implementation of the Class interface +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.chassisbase import chassisbase +import collections +from plat_hal.baseutil import baseutil +from plat_hal.osutil import osutil + + +def Singleton(cls): + _instance = {} + + def _singleton(*args, **kargs): + if cls not in _instance: + _instance[cls] = cls(*args, **kargs) + return _instance[cls] + + return _singleton + + +@Singleton +class interface(object): + __chas = None + __error_ret = None + + def __init__(self): + self.chas = chassisbase() + self.__error_ret = -99999 + self.__na_ret = 'N/A' + + @property + def na_ret(self): + return self.__na_ret + + @na_ret.setter + def na_ret(self, val): + self.__na_ret = val + + @property + def error_ret(self): + return self.__error_ret + + @error_ret.setter + def error_ret(self, val): + self.__error_ret = val + + @property + def chas(self): + return self.__chas + + @chas.setter + def chas(self, val): + self.__chas = val + + # onie_e2 + def get_onie_e2(self): + onie_e2_list = self.chas.onie_e2_list + return onie_e2_list + + def get_onie_e2_path(self, name): + onie_e2 = self.chas.get_onie_e2_byname(name) + if onie_e2 is None: + return None + return onie_e2.e2_path + + def get_onie_e2_obj(self, name): + onie_e2 = self.chas.get_onie_e2_byname(name) + if onie_e2 is None: + return None + onie_e2.get_onie_e2_info() + return onie_e2 + + # temp + def get_temps(self): + templist = self.chas.temp_list + return templist + + def get_temp_total_number(self): + templist = self.chas.temp_list + return len(templist) + + def check_temp_id_exist(self, temp_id): + templist = self.chas.temp_list + for temp in templist: + if temp.temp_id == temp_id: + return True + return False + + def get_temp_id_number(self): + templist = self.chas.temp_list + temp_num = 0 + for i in range(len(templist)): + temp_id = "TEMP" + str(i + 1) + ret = self.check_temp_id_exist(temp_id) + if ret == True: + temp_num = temp_num + 1 + else: + return temp_num + return temp_num + + def get_temp_location(self, temp_name): + temp = self.chas.get_temp_byname(temp_name) + return temp.get_location() + + def set_temp_location(self, temp_name, location): + temp = self.chas.get_temp_byname(temp_name) + return temp.set_location(location) + + def set_temp_name(self, temp_name, name): + temp = self.chas.get_temp_byname(temp_name) + return temp.set_name(name) + + def get_appoint_temp(self, temp_name): + temp = self.chas.get_led_byname(temp_name) + return temp.get_temp() + + def set_appoint_temp(self, temp_name, val): + temp = self.chas.get_temp_byname(temp_name) + return temp.set_temp(val) + + def get_temp_mintemp(self, temp_name): + temp = self.chas.get_temp_byname(temp_name) + return temp.get_mintemp() + + def set_temp_mintemp(self, temp_name, val): + temp = self.chas.get_temp_byname(temp_name) + return temp.set_mintemp(val) + + # led + def get_leds(self): + ledlist = self.chas.led_list + return ledlist + + def get_led_total_number(self): + ledlist = self.chas.led_list + return len(ledlist) + + def get_led_color(self, led_name): + led = self.chas.get_led_byname(led_name) + if led is None: + return -1 + return led.get_color() + + def get_led_color_by_type(self, led_type): + ledlist = self.chas.led_list + ledtmp = None + for temp in ledlist: + if temp.led_type == led_type: + ledtmp = temp + break + if ledtmp is None: + return -1 + return ledtmp.get_color() + + def set_led_color(self, led_name, color): + led = self.chas.get_led_byname(led_name) + if led is None: + return -1 + return led.set_color(color) + + # psu + def get_psu_total_number(self): + psulist = self.chas.psu_list + if psulist is None: + return -1 + return len(psulist) + + def get_psus(self): + psulist = self.chas.psu_list + return psulist + + def get_psu_presence(self, psu_name): + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + return psu.present + + def get_psu_fru_info(self, psu_name): + ''' + { + "Name": "PSU1", + "SN": "serial_number_example", # 'N/A' + "PN": "part_number_example", # 'N/A' + "AirFlow": "B2F" # 'N/A' + } + ''' + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + psu.get_fru_info() + psu.get_AirFlow() + psu.get_psu_display_name() + + dic = collections.OrderedDict() + dic["Name"] = psu.name + dic["SN"] = psu.productSerialNumber if (psu.productSerialNumber is not None) else self.na_ret + dic["PN"] = psu.productPartModelName if (psu.productPartModelName is not None) else self.na_ret + dic["DisplayName"] = psu.psu_display_name if (psu.psu_display_name is not None) else self.na_ret + dic["VENDOR"] = psu.productManufacturer if (psu.productManufacturer is not None) else self.na_ret + dic["HW"] = psu.productVersion if (psu.productVersion is not None) else self.na_ret + dic["AirFlow"] = psu.AirFlow if (psu.AirFlow is not None) else self.na_ret + return dic + + def get_psu_input_output_status(self, psu_name): + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + psu.InputsCurrent.Value # just for clear faults + if (psu.InputStatus == True) and (psu.OutputStatus == True): + status = True + else: + status = False + return status + + def get_psu_status(self, psu_name): + """ + Get status of a specific PSU + @return dict of the specific PSU's status, None for failure + Example return value(all keys are mandatory) + { + "Name": "PSU1", + "InputType": "DC", # "AC" or 'N/A' + "InputStatus": True, # H/W status bit + "OutputStatus": True # H/W status bit + "FanSpeed": { + "Value": 4000, # -99999 + "Min": 2000, # -99999 + "Max": 10000 # -99999 + }, + "Temperature": { + "Value": 40.0, # -99999.0 + "Min": -30.0, # -99999.0 + "Max": 50.0 # -99999.0 + } + } + """ + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + + dic = collections.OrderedDict() + # psu.get_Temperature() + temp_dict = collections.OrderedDict() + temp_dict['Min'] = psu.Temperature.Min + temp_dict['Max'] = psu.Temperature.Max + temp_dict['Value'] = psu.Temperature.Value + temp_dict['Unit'] = psu.Temperature.Unit + dic["Temperature"] = temp_dict + + # psu.get_FanSpeed() + fan_speed_dict = collections.OrderedDict() + fan_speed_dict['Min'] = psu.FanSpeed.Min + fan_speed_dict['Max'] = psu.FanSpeed.Max + fan_speed_dict['Tolerance'] = psu.FanSpeedTolerance + fan_speed_dict['Value'] = psu.FanSpeed.Value + fan_speed_dict['Unit'] = psu.FanSpeed.Unit + dic["FanSpeed"] = fan_speed_dict + + dic["Name"] = psu.name + dic["InputType"] = psu.InputsType + dic["InputStatus"] = psu.InputStatus + dic["OutputStatus"] = psu.OutputStatus + dic["TempStatus"] = psu.TempStatus + dic["FanStatus"] = psu.FanStatus + return dic + + def get_psu_power_status(self, psu_name): + """ + Get power status of a specific PSU + @return dict of the specific PSU's power status, None for failure + Example return value + { + "Name": "PSU1", + "Inputs": { + "Status": True, # H/W status bit + "Type": "DC", # or "AC" or "N/A" + "Voltage": { + "Value": 220, # -1 + "LowAlarm": 200, # -1 + "HighAlarm": 240, # -1 + "Unit": "V" + }, + "Current": { + "Value": 6.0, # -99999.0 + "LowAlarm": 0.2, # -99999.0 + "HighAlarm": 7.0, # -99999.0 + "Unit": "A" + }, + "Power": { + "Value": 1000, # -99999 + "LowAlarm": -1, # -99999 + "HighAlarm": 1400, # -99999 + "Unit": "W" + } + }, + "Outputs": { + "Status": True, + "Voltage": { + "Value": 220, + "LowAlarm": 200, + "HighAlarm": 240, + "Unit": "V" + }, + "Current": { + "Value": 6.0, + "LowAlarm": 0.2, + "HighAlarm": 7.0, + "Unit": "A" + }, + "Power": { + "Value": 1000, + "LowAlarm": -1, # Don't care + "HighAlarm": 1400, + "Unit": "W" + } + } + } + """ + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + + dic = collections.OrderedDict() + inputdic = collections.OrderedDict() + Outputsdic = collections.OrderedDict() + dic["Name"] = psu.name + inputdic["Status"] = psu.InputStatus + inputdic["Type"] = psu.InputsType + + # psu.get_InputsVoltage() + inputdic_voltage = collections.OrderedDict() + + inputdic_voltage["Value"] = psu.InputsVoltage.Value + inputdic_voltage["LowAlarm"] = psu.InputsVoltage.Min + inputdic_voltage["HighAlarm"] = psu.InputsVoltage.Max + inputdic_voltage["Unit"] = psu.InputsVoltage.Unit + + inputdic["Voltage"] = inputdic_voltage + inputdic_current = collections.OrderedDict() + inputdic_current["Value"] = psu.InputsCurrent.Value + inputdic_current["LowAlarm"] = psu.InputsCurrent.Min + inputdic_current["HighAlarm"] = psu.InputsCurrent.Max + inputdic_current["Unit"] = psu.InputsCurrent.Unit + inputdic["Current"] = inputdic_current + + inputdic_power = collections.OrderedDict() + inputdic_power["Value"] = psu.InputsPower.Value + inputdic_power["LowAlarm"] = psu.InputsPower.Min + inputdic_power["HighAlarm"] = psu.InputsPower.Max + inputdic_power["Unit"] = psu.InputsPower.Unit + inputdic["Power"] = inputdic_power + Outputsdic["Status"] = psu.InputStatus + + outputdic_voltage = collections.OrderedDict() + outputdic_current = collections.OrderedDict() + outputdic_power = collections.OrderedDict() + + outputdic_voltage["Value"] = psu.OutputsVoltage.Value + outputdic_voltage["LowAlarm"] = psu.OutputsVoltage.Min + outputdic_voltage["HighAlarm"] = psu.OutputsVoltage.Max + outputdic_voltage["Unit"] = psu.OutputsVoltage.Unit + + outputdic_current["Value"] = psu.OutputsCurrent.Value + outputdic_current["LowAlarm"] = psu.OutputsCurrent.Min + outputdic_current["HighAlarm"] = psu.OutputsCurrent.Max + outputdic_current["Unit"] = psu.OutputsCurrent.Unit + + outputdic_power["Value"] = psu.OutputsPower.Value + outputdic_power["LowAlarm"] = psu.OutputsPower.Min + outputdic_power["HighAlarm"] = psu.OutputsPower.Max + outputdic_power["Unit"] = psu.OutputsPower.Unit + + Outputsdic["Voltage"] = outputdic_voltage + Outputsdic["Current"] = outputdic_current + Outputsdic["Power"] = outputdic_power + + dic["Inputs"] = inputdic + dic["Outputs"] = Outputsdic + + return dic + + def set_psu_fan_speed_pwm(self, psu_name, pwm): + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + return psu.set_fan_speed_pwm(pwm) + + def get_psu_fan_speed_pwm(self, psu_name): + psu = self.chas.get_psu_byname(psu_name) + if psu is None: + return -1 + return psu.get_fan_speed_pwm() + + def get_psu_info_all(self): + """ + { + "Number": 2, + "PSU1": { + "SN": "serial_number_example", # 'N/A' + "PN": "part_number_example", # 'N/A' + "AirFlow": "F2B", # 'N/A' + + "FanSpeed": { + "Value": 4000, + "Min": 2000, + "Max": 30000 + }, + "Temperature": { + "Value": 35.0, + "Min": -20.0, + "Max": 45.0 + }, + "Inputs": { + "Status": True, # H/W status bit + "Type": "DC", # or "AC" + "Voltage": { + "Value": 220, + "LowAlarm": 200, + "HighAlarm": 240, + "Unit": "V" + }, + "Current": { + "Value": 6.0, + "LowAlarm": 0.2, + "HighAlarm": 7.0, + "Unit": "A" + }, + "Power": { + "Value": 1000, + "LowAlarm": -1, + "HighAlarm": 1400, + "Unit": "W" + } + }, + "Outputs": { + "Status": True, + "Voltage": { + "Value": 220, + "LowAlarm": 200, + "HighAlarm": 240, + "Unit": "V" + }, + "Current": { + "Value": 6.0, + "LowAlarm": 0.2, + "HighAlarm": 7.0, + "Unit": "A" + }, + "Power": { + "Value": 1000, + "LowAlarm": -1, # Don't care + "HighAlarm": 1400, + "Unit": "W" + } + } + } + } + """ + + psus = self.get_psus() + dict = collections.OrderedDict() + dict['Number'] = len(psus) + for psu in psus: + dicttmp = self.get_psu_fru_info(psu.name) + dicttmp.update(self.get_psu_status(psu.name)) + dicttmp.update(self.get_psu_power_status(psu.name)) + if self.get_psu_presence(psu.name) is True: + dicttmp['Present'] = 'yes' + else: + dicttmp['Present'] = 'no' + dict[psu.name] = dicttmp + return dict + + def get_fans(self): + fanlist = self.chas.fan_list + return fanlist + + # fan + def get_fan_total_number(self): + fanlist = self.chas.fan_list + if fanlist is None: + return -1 + return len(fanlist) + + def get_fan_rotor_number(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + ret = fan.rotors + if ret is None: + return -1 + return ret + + def get_fan_speed(self, fan_name, rotor_index): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + ret = fan.get_speed(rotor_index) + if ret is None: + return -1 + return ret + + def set_fan_speed(self, fan_name, rotor_index, speed): + return -1 + + def fan_speed_set_level(self, fan_name, rotor_index, level): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + ret = fan.set_speed(rotor_index, level) + if ret is True: + return 0 + else: + return -1 + + def get_fan_speed_pwm(self, fan_name, rotor_index): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + val = fan.get_speed_pwm(rotor_index) + if val is False: + return -1 + return val + + def set_fan_speed_pwm(self, fan_name, rotor_index, pwm): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + if isinstance(pwm, str): + rate = float(pwm.strip('%s')) + speed = round(rate * 255 / 100) + elif isinstance(pwm, int): + speed = round(pwm * 255 / 100) + elif isinstance(pwm, float): + speed = round(pwm * 255 / 100) + else: + return -1 + ret = self.fan_speed_set_level(fan.name, rotor_index, speed) + if ret == 0: + return 0 + return -1 + + def get_fan_watchdog_status(self): + fan = self.chas.fan_list[0] + dic = fan.get_watchdog_status() + if dic is None or dic["support"] == False: + return self.na_ret + elif dic["open"] is False or dic["work_allow_set"] is True: + return "Normal" + elif dic["work_full"] is True: + return "Abnormal" + else: + return "Abnormal" + + def enable_fan_watchdog(self, enable=True, timeout_sec=10): + fan = self.chas.fan_list[0] + ret = fan.enable_watchdog(enable, timeout_sec) + if ret is True: + return 0 + else: + return -1 + + def feed_fan_watchdog(self, pwm): + fan_list = self.chas.fan_list + if fan_list is None: + return -1 + for fan in fan_list: + ret = fan.feed_watchdog(pwm) + if ret is False: + return -1 + return 0 + + def set_fan_led(self, fan_name, color): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + ret = fan.set_led(color) + if ret is True: + return 0 + return -1 + + def get_fan_led(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return False, 'N/A' + return fan.get_led() + + def get_fan_presence(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + return fan.get_presence() + + def get_fan_fru_info(self, fan_name): + """ + Get specific fan's information + # Properties + "Name": "FAN1", + "SN": "serial_number_example", # 'N/A' + "PN": "part_number_exampple", # 'N/A' + "Rotors": 2, # -1 + "AirFlow": "F2B", # 'N/A' + "SpeedMin": 2000, # -1 + "SpeedMax": 30000 # -1 + """ + fan = self.chas.get_fan_byname(fan_name) + fan.get_fru_info() + fan.get_AirFlow() + fan.get_fan_display_name() + + dic = collections.OrderedDict() + dic["Name"] = fan.name + dic["SN"] = fan.productSerialNumber + if dic["SN"] is None: + dic["SN"] = self.na_ret + dic["PN"] = fan.productName + if dic["PN"] is None: + dic["PN"] = self.na_ret + dic["DisplayName"] = fan.fan_display_name + if dic["DisplayName"] is None: + dic["DisplayName"] = self.na_ret + + dic["Rotors"] = fan.rotors + dic["AirFlow"] = fan.AirFlow + if dic["AirFlow"] is None: + dic["AirFlow"] = self.na_ret + dic["SpeedMin"] = fan.SpeedMin + dic["SpeedMax"] = fan.SpeedMax + return dic + + def get_fan_eeprom_info(self, fan_name): + """ + Get specific fan's information + # Properties + "Name": "M6510-FAN-F", # 'N/A' + "SN": "serial_number_example", # 'N/A' + "HW": "hw_version_exampple", # 'N/A' + """ + fan = self.chas.get_fan_byname(fan_name) + fan.decode_eeprom_info() + dic = collections.OrderedDict() + dic["NAME"] = fan.productName + if dic["NAME"] is None: + dic["NAME"] = self.na_ret + dic["SN"] = fan.productSerialNumber + if dic["SN"] is None: + dic["SN"] = self.na_ret + dic["HW"] = fan.hw_version + if dic["HW"] is None: + dic["HW"] = self.na_ret + + return dic + + def get_product_fullname(self): + return baseutil.get_product_fullname() + + def get_fan_status(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + rotorlist = fan.rotor_list + dir = collections.OrderedDict() + for rotor in rotorlist: + dir_val = collections.OrderedDict() + if rotor.rotor_Running == True: + dir_val['Running'] = 'yes' + else: + dir_val['Running'] = 'no' + if rotor.rotor_HwAlarm == True: + dir_val['HwAlarm'] = 'yes' + else: + dir_val['HwAlarm'] = 'no' + dir_val['Speed'] = int(rotor.rotor_Speed.Value) + dir[rotor.name] = dir_val + return dir + + def get_fan_rotor_status(self, fan_name, rotor_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + rotorlist = fan.rotor_list + for i in range(len(rotorlist)): + if rotor_name == rotorlist[i].name: + rotor = rotorlist[i] + if rotor.rotor_Running == True: + return True + else: + return False + return -1 + + def get_fan_roll_status(self, fan_name, rotor_index): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + rotor = fan.get_rotor_index(rotor_index) + if rotor is None: + return -1 + if rotor.rotor_Running == True: + return True + return False + + def get_fan_info_fru(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + fan.get_fru_info() + fan.get_AirFlow() + dic = collections.OrderedDict() + dic["Name"] = fan.name + dic["SN"] = fan.productSerialNumber + if dic["SN"] is None: + dic["SN"] = self.na_ret + dic["PN"] = fan.productPartModelName + if dic["PN"] is None: + dic["PN"] = self.na_ret + flag = self.get_fan_presence(fan_name) + if flag is True: + dic["Present"] = "yes" + elif flag is False: + dic["Present"] = "no" + else: + dic["Present"] = self.na_ret + dic["Rotors"] = fan.rotors + dic["AirFlow"] = fan.AirFlow + if dic["AirFlow"] is None: + dic["AirFlow"] = self.na_ret + return dic + + # support TLV and FRU FAN E2 + def get_fan_info(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return None + fan.get_AirFlow() + dic = self.get_fan_eeprom_info(fan_name) + flag = self.get_fan_presence(fan_name) + if flag is True: + dic["Present"] = "yes" + elif flag is False: + dic["Present"] = "no" + else: + dic["Present"] = self.na_ret + dic["Rotors"] = fan.rotors + dic["AirFlow"] = fan.AirFlow + if dic["AirFlow"] is None: + dic["AirFlow"] = self.na_ret + return dic + + def get_fan_info_rotor(self, fan_name): + fan = self.chas.get_fan_byname(fan_name) + if fan is None: + return -1 + rotorlist = fan.rotor_list + dir = collections.OrderedDict() + for rotor in rotorlist: + dir_val = collections.OrderedDict() + if rotor.rotor_Running == True: + dir_val['Running'] = 'yes' + else: + dir_val['Running'] = 'no' + if rotor.rotor_HwAlarm == True: + dir_val['HwAlarm'] = 'yes' + else: + dir_val['HwAlarm'] = 'no' + speed_value = rotor.rotor_Speed.Value + if speed_value is None: + dir_val['Speed'] = self.error_ret + else: + dir_val['Speed'] = int(speed_value) + if rotor.SpeedMin is None: + dir_val['SpeedMin'] = self.error_ret + else: + dir_val['SpeedMin'] = rotor.SpeedMin + if rotor.SpeedMax is None: + dir_val['SpeedMax'] = self.error_ret + else: + dir_val['SpeedMax'] = rotor.SpeedMax + if rotor.Tolerance is None: + dir_val['Tolerance'] = self.error_ret + else: + dir_val['Tolerance'] = rotor.Tolerance + + dir[rotor.name] = dir_val + return dir + + def get_fan_info_all(self): + fanlist = self.chas.fan_list + dic = collections.OrderedDict() + dic['Number'] = len(fanlist) + dic['WatchdogStatus'] = self.get_fan_watchdog_status() + for fan in fanlist: + dic[fan.name] = self.get_fan_info(fan.name) + dic[fan.name].update(self.get_fan_info_rotor(fan.name)) + return dic + + def temp_test(self): + templist = self.chas.temp_list + dicret = collections.OrderedDict() + + for temp in templist: + dic = collections.OrderedDict() + temp_value = temp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["LowAlarm"] = temp.Min + dic["HighAlarm"] = temp.Max + dicret[temp.name] = dic + return dicret + + # dcdc + def get_dcdc_total_number(self): + dcdclist = self.chas.dcdc_list + if dcdclist is None: + return -1 + return len(dcdclist) + + def get_dcdc_by_id(self, dcdc_id): + dcdclist = self.chas.dcdc_list + dcdctmp = None + for dcdc in dcdclist: + if dcdc.dcdc_id == dcdc_id: + dcdctmp = dcdc + dic = collections.OrderedDict() + if dcdctmp is None: + dic["Name"] = self.error_ret + dic["Min"] = self.error_ret + dic["Max"] = self.error_ret + dic["Low"] = self.error_ret + dic["High"] = self.error_ret + dic["Value"] = self.error_ret + dic["Unit"] = self.error_ret + else: + dic["Name"] = dcdctmp.name + dic["Min"] = dcdctmp.sensor.Min + dic["Max"] = dcdctmp.sensor.Max + dic["Low"] = dcdctmp.sensor.Low + dic["High"] = dcdctmp.sensor.High + tmp = dcdctmp.sensor.Value + if tmp is not None: + dic['Value'] = tmp + else: + dic['Value'] = self.error_ret + dic["Unit"] = dcdctmp.sensor.Unit + return dic + + def get_dcdc_all_info(self): + val_list = collections.OrderedDict() + dcdclist = self.chas.dcdc_list + for dcdc in dcdclist: + dicttmp = {} + sensorname = "%s" % (dcdc.name) + dicttmp['Min'] = dcdc.sensor.Min + dicttmp['Max'] = dcdc.sensor.Max + tmp = dcdc.sensor.Value + if tmp is not None: + dicttmp['Value'] = tmp + else: + dicttmp['Value'] = self.error_ret + dicttmp['Unit'] = dcdc.sensor.Unit + val_list[sensorname] = dicttmp + return val_list + + # sensors + def get_monitor_temp(self, name): + templist = self.chas.temp_list + temptmp = None + for temp in templist: + if temp.name == name: + temptmp = temp + + dic = collections.OrderedDict() + if temptmp is None: + dic["Min"] = self.error_ret + dic["Max"] = self.error_ret + dic["Value"] = self.error_ret + dic["Unit"] = self.error_ret + else: + dic["Min"] = temptmp.Min + dic["Max"] = temptmp.Max + temp_value = temptmp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["Unit"] = temptmp.Unit + return dic + + def get_monitor_temp_by_id(self, temp_id): + templist = self.chas.temp_list + temptmp = None + for temp in templist: + if temp.temp_id == temp_id: + temptmp = temp + + dic = collections.OrderedDict() + if temptmp is None: + dic["Name"] = self.error_ret + dic["Api_name"] = self.error_ret + dic["Min"] = self.error_ret + dic["Max"] = self.error_ret + dic["Low"] = self.error_ret + dic["High"] = self.error_ret + dic["Value"] = self.error_ret + dic["Unit"] = self.error_ret + else: + dic["Name"] = temptmp.name + dic["Api_name"] = temptmp.api_name + dic["Min"] = temptmp.Min + dic["Max"] = temptmp.Max + dic["Low"] = temptmp.Low + dic["High"] = temptmp.High + temp_value = temptmp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["Unit"] = temptmp.Unit + return dic + + def get_temp_info(self): + val_list = collections.OrderedDict() + # temp + templist = self.chas.temp_list + for temp in templist: + dic = collections.OrderedDict() + dic["Min"] = temp.Min + dic["Max"] = temp.Max + dic["Low"] = temp.Low + dic["High"] = temp.High + temp_value = temp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["Unit"] = temp.Unit + val_list[temp.name] = dic + return val_list + + def get_sensor_info(self): + val_list = collections.OrderedDict() + # temp + templist = self.chas.temp_list + for temp in templist: + dic = collections.OrderedDict() + dic["Min"] = temp.Min + dic["Max"] = temp.Max + dic["Low"] = temp.Low + dic["High"] = temp.High + temp_value = temp.Value + dic["Value"] = temp_value if (temp_value is not None) else self.error_ret + dic["Unit"] = temp.Unit + val_list[temp.name] = dic + # fan + fanlist = self.chas.fan_list + for fan in fanlist: + for rotor in fan.rotor_list: + sensorname = "%s%s" % (fan.name, rotor.name) + speed = collections.OrderedDict() + speed['Min'] = rotor.rotor_Speed.Min + speed['Max'] = rotor.rotor_Speed.Max + rotor_speed_Value = rotor.rotor_Speed.Value + speed['Value'] = rotor_speed_Value if (rotor_speed_Value is not None) else self.error_ret + speed['Unit'] = rotor.rotor_Speed.Unit + val_list[sensorname] = speed + + val_list.update(self.get_dcdc_all_info()) + + # psu + psulist = self.chas.psu_list + for psu in psulist: + inputdic_voltage = collections.OrderedDict() + inputdic_current = collections.OrderedDict() + inputdic_power = collections.OrderedDict() + outputdic_voltage = collections.OrderedDict() + outputdic_current = collections.OrderedDict() + outputdic_power = collections.OrderedDict() + temperature = collections.OrderedDict() + fanspeed = collections.OrderedDict() + + psu_temp_value = psu.Temperature.Value + temperature["Value"] = psu_temp_value if (psu_temp_value is not None) else self.error_ret + temperature["Min"] = psu.Temperature.Min + temperature["Max"] = psu.Temperature.Max + temperature["Unit"] = psu.Temperature.Unit + + fanspeed["Value"] = psu.FanSpeed.Value + fanspeed["Min"] = psu.FanSpeed.Min + fanspeed["Max"] = psu.FanSpeed.Max + fanspeed["Unit"] = psu.FanSpeed.Unit + + psu_inputvoltage_value = psu.InputsVoltage.Value + inputdic_voltage["Value"] = psu_inputvoltage_value if ( + psu_inputvoltage_value is not None) else self.error_ret + inputdic_voltage["Min"] = psu.InputsVoltage.Min + inputdic_voltage["Max"] = psu.InputsVoltage.Max + inputdic_voltage["Unit"] = psu.InputsVoltage.Unit + + psu_inputcurrent_value = psu.InputsCurrent.Value + inputdic_current["Value"] = psu_inputcurrent_value if ( + psu_inputcurrent_value is not None) else self.error_ret + inputdic_current["Min"] = psu.InputsCurrent.Min + inputdic_current["Max"] = psu.InputsCurrent.Max + inputdic_current["Unit"] = psu.InputsCurrent.Unit + + psu_inputpower_value = psu.InputsPower.Value + inputdic_power["Value"] = psu_inputpower_value if (psu_inputpower_value is not None) else self.error_ret + inputdic_power["Min"] = psu.InputsPower.Min + inputdic_power["Max"] = psu.InputsPower.Max + inputdic_power["Unit"] = psu.InputsPower.Unit + + psu_outputvoltage_value = psu.OutputsVoltage.Value + outputdic_voltage["Value"] = psu_outputvoltage_value if ( + psu_outputvoltage_value is not None) else self.error_ret + outputdic_voltage["Min"] = psu.OutputsVoltage.Min + outputdic_voltage["Max"] = psu.OutputsVoltage.Max + outputdic_voltage["Unit"] = psu.OutputsVoltage.Unit + + psu_outputcurrent_value = psu.OutputsCurrent.Value + outputdic_current["Value"] = psu_outputcurrent_value if ( + psu_outputcurrent_value is not None) else self.error_ret + outputdic_current["Min"] = psu.OutputsCurrent.Min + outputdic_current["Max"] = psu.OutputsCurrent.Max + outputdic_current["Unit"] = psu.OutputsCurrent.Unit + + psu_outputpower_value = psu.OutputsPower.Value + outputdic_power["Value"] = psu_outputpower_value if ( + psu_outputpower_value is not None) else self.error_ret + outputdic_power["Min"] = psu.OutputsPower.Min + outputdic_power["Max"] = psu.OutputsPower.Max + outputdic_power["Unit"] = psu.OutputsPower.Unit + + val_list["%s%s" % (psu.name, "Vol_I")] = inputdic_voltage + val_list["%s%s" % (psu.name, "Curr_I")] = inputdic_current + val_list["%s%s" % (psu.name, "Power_I")] = inputdic_power + val_list["%s%s" % (psu.name, "Vol_O")] = outputdic_voltage + val_list["%s%s" % (psu.name, "Curr_O")] = outputdic_current + val_list["%s%s" % (psu.name, "Power_O")] = outputdic_power + val_list["%s%s" % (psu.name, "Fan")] = fanspeed + val_list["%s%s" % (psu.name, "Temp")] = temperature + + return val_list + + # cpld + def get_cpld_total_number(self): + cpldlist = self.chas.cpld_list + return len(cpldlist) + + def get_cpld_user_reg(self): + cpld = self.chas.get_cpld_byname("BASE_CPLD") + if cpld is None: + return None + else: + return cpld.get_user_reg() + + def set_cpld_user_reg(self, value): + if (isinstance(value, int) == False): + baseutil.logger_debug("value must int %s" % type(value)) + return -1 + if (int(value) < 0 or int(value) > 255): + baseutil.logger_debug("value must [0 - 255]") + return -1 + cpld = self.chas.get_cpld_byname("BASE_CPLD") + if cpld is None: + baseutil.logger_debug("name BASE_CPLD not find") + return -1 + if cpld.set_user_reg(value) == True: + return 0 + else: + return -1 + + def set_cpld_console_owner(self, owner): + """ + Set console I/O owner + + @param owner I/O owner of the console, either "cpu" or "bmc" + + @return 0 for success, -1 for failure + """ + if (owner is None): + baseutil.logger_debug("owner is None") + return -1 + if (owner != "cpu" and owner != "bmc"): + baseutil.logger_debug("owner is %s, must cpu or bmc" % owner) + return -1 + cpld = self.chas.get_cpld_byname("BASE_CPLD") + if cpld is None: + baseutil.logger_debug("name BASE_CPLD not find") + return -1 + if cpld.set_console_owner(owner) == True: + return 0 + else: + return -1 + + def get_cpld_version_by_id(self, cpld_id): + cpldlist = self.chas.cpld_list + cpldtmp = None + for cpld in cpldlist: + if cpld.cpld_id == cpld_id: + cpldtmp = cpld + + dic = collections.OrderedDict() + if cpldtmp is None: + dic["Name"] = self.na_ret + dic["Version"] = self.na_ret + dic["Desc"] = self.na_ret + dic["Slot"] = None + else: + dic["Name"] = cpldtmp.name + dic["Version"] = cpldtmp.get_version() + dic["Desc"] = cpldtmp.desc + dic["Slot"] = cpldtmp.slot + return dic + + def get_cpld_all_version(self): + """ + Get version of all CPLDs' that can be read from BMC + + @return dict of CPLDs' version or None for failure. + example outputs: + { + "BASE_CPLD": "0.1", # or "N/A" for read failure + "FAN_CPLD": "0.2" + } + """ + cpld_version = { + "BASE_CPLD": "N/A", + "FAN_CPLD": "N/A" + } + for cpld_name in cpld_version.keys(): + cpld = self.chas.get_cpld_byname(cpld_name) + if cpld is None: + baseutil.logger_debug("name %s not find" % cpld_name) + continue + cpld_version[cpld_name] = cpld.get_version() + return cpld_version + + # comp + def get_comp_total_number(self): + complist = self.chas.comp_list + return len(complist) + + def get_comp_list(self): + return self.chas.comp_list + + def get_comp_id(self, comp): + return comp.comp_id + + def get_comp_version_by_id(self, id): + comp_list = self.chas.comp_list + comptmp = None + for comp in comp_list: + if comp.comp_id == id: + comptmp = comp + break + + dic = collections.OrderedDict() + if comptmp is None: + dic["Name"] = self.na_ret + dic["Version"] = self.na_ret + dic["Desc"] = self.na_ret + dic["Slot"] = None + else: + dic["Name"] = comptmp.name + dic["Version"] = comptmp.get_version() + dic["Desc"] = comptmp.desc + dic["Slot"] = comptmp.slot + return dic + + def get_bmc_productname(self): + """ + Get product name + + @return product name string, e.g. $(device name)-F-$(VENDOR_NAME), if error return "N/A" + """ + bmc = self.chas.get_bmc_byname("master") + if (bmc is None): + baseutil.logger_debug("name bmc(master) not find") + return self.na_ret + return bmc.get_productname() + + def call_bmc_diagcmd(self, cmdstr): + """ + Call BMC diag comman func + + @return ret: 0 sucess , -1 fail + outmsg: if success is out msg, or fail is err msg + """ + if (cmdstr is None or cmdstr == ""): + outmsg = "cmdstr is empty" + baseutil.logger_debug(outmsg) + return -1, outmsg + bmc = self.chas.get_bmc_byname("master") + if (bmc is None): + outmsg = "name bmc(master) not find" + baseutil.logger_debug(outmsg) + return -1, outmsg + baseutil.logger_debug("call cmdstr %s" % cmdstr) + return bmc.call_diagcmd(cmdstr) + + def write_bios_version(self, flash, version): + bios = self.chas.get_bios_byname("master") + if bios is None: + baseutil.logger_debug("name bios(master) not find") + return -1 + return bios.set_bios_version(flash, version) + + def get_bios_version(self): + bios = self.chas.get_bios_byname("master") + if bios is None: + baseutil.logger_debug("name bios(master) not find") + return -1 + return bios.get_bios_version() + + def get_bios_status(self): + bios = self.chas.get_bios_byname("master") + if bios is None: + baseutil.logger_debug("name bios(master) not find") + return -1 + return bios.get_bios_boot_status() + + def monitor_cpu_host_watchdog(self, value): + cpu = self.chas.get_cpu_byname("cpu") + if cpu is None: + baseutil.logger_debug("name cpu not find") + return -1 + return cpu.set_cpu_host_watchdog(value) + + def get_bmc_mac_rov(self): + """ + Get BMC mac rov + + @return ret: 0 sucess , -1 fail + outmsg: if success is out msg, or fail is err msg + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + msg = "name master not find" + baseutil.logger_debug(msg) + return -1, msg + return bmc.get_mac_rov() + + def get_bmc_next_boot(self): + """ + Get next booting flash of BMC + + @return 'master'/'slave' on success, "N/A" for failure + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return self.na_ret + return bmc.get_next_boot() + + def set_bmc_next_boot(self, flash): + """ + Set flash from which next BMC boot + + @param flash Booting flash of BMC, "master" or "slave" + + @return 0 on success, -1 for failure + """ + if flash is None or (flash != "master" and flash != "slave"): + baseutil.logger_debug("parameter flash illegal, should be [master|slave]") + return -1 + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return -1 + return bmc.set_next_boot(flash) + + def reboot_bmc(self): + """ + Reboot running BMC + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return -1 + return bmc.reboot() + + def get_bmc_info(self): + """ + Get BMC info + + @return dict of BMC info or None for failure + "Version": "1.1.1", # "N/A" + "Flash": "master", # "N/A" + "Next": "master" # "N/A" + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return self.na_ret + return bmc.get_info() + + def get_bmc_version_all(self): + """ + @return dict of BMCs + { + "MasterVersion": "1.1.1", # "N/A" + "SlaveVersion": "1.1.1" # "N/A" + } + """ + bmc = self.chas.get_bmc_byname("master") + if bmc is None: + baseutil.logger_debug("name master not find") + return self.na_ret + return bmc.get_version_all() + + def bmc_execute_command(self, cmd_str): + ret, output = osutil.command(cmd_str) + if ret: + baseutil.logger_debug("execute %s command failed" % (cmd_str)) + return ret, output + + def get_cpu_status(self): + """ + Get CPU current status. + + @return 'S0', ..., 'S5', or 'N/A' for failure + """ + cpu = self.chas.get_cpu_byname("cpu") + if cpu is None: + baseutil.logger_debug("name cpu not find") + return self.na_ret + return cpu.get_state() + + def get_cpu_reset_num(self): + """ + Get CPU reset num + @return CPU reset num on success, -1 for failure + """ + cpu = self.chas.get_cpu_byname("cpu") + if cpu is None: + msg = "name cpu not find" + baseutil.logger_debug(msg) + return -1 + return cpu.get_cpu_reset_num() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/led.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/led.py new file mode 100755 index 000000000000..967a100b9826 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/led.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +####################################################### +# +# led.py +# Python implementation of the Class led +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase + + +class led(devicebase): + def __init__(self, conf=None): + if conf is not None: + self.name = conf.get('name', None) + self.led_type = conf.get('led_type', None) + self.led_attrs_config = conf.get('led_attrs', None) + self.led_config = conf.get('led', None) + + def set_color(self, color): + status = self.led_attrs_config.get(color, None) + if status is None: + return False + + mask = self.led_attrs_config.get('mask', 0xff) + + if isinstance(self.led_config, list): + for led_config_index in self.led_config: + ret, value = self.get_value(led_config_index) + if (ret is False) or (value is None): + return False + setval = (int(value) & ~mask) | (status) + ret, val = self.set_value(led_config_index, setval) + if ret is False: + return ret + else: + ret, value = self.get_value(self.led_config) + if (ret is False) or (value is None): + return False + setval = (int(value) & ~mask) | (status) + ret, val = self.set_value(self.led_config, setval) + return ret + + def get_color(self): + mask = self.led_attrs_config.get('mask', 0xff) + ret, value = self.get_value(self.led_config) + if ret is False or value is None: + return False, 'N/A' + ledval = (int(value) & mask) + for key, val in self.led_attrs_config.items(): + if (ledval == val) and (key != "mask"): + return True, key + return False, 'N/A' + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/onie_e2.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/onie_e2.py new file mode 100755 index 000000000000..76ac1658267b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/onie_e2.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +####################################################### +# +# onie_e2.py +# Python implementation of the Class onie_e2 +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from eepromutil.onietlv import onie_tlv + + +class onie_e2(devicebase): + + def __init__(self, conf=None): + self._cardid = "" + self._productname = "" + self._partnum = "" + self._serialnum = "" + self._macbase = "" + self._manufdate = "" + self._deviceversion = "" + self._labelrevision = "" + self._platformname = "" + self._onieversion = "" + self._macsize = "" + self._manufname = "" + self._manufcountry = "" + self._vendorname = "" + self._diagname = "" + self._servicetag = "" + + if conf is not None: + self.name = conf.get('name', None) + self.e2loc = conf.get('e2loc', None) + self.e2_path = self.e2loc.get('loc', None) + + @property + def cardid(self): + return self._cardid + + @property + def productname(self): + return self._productname + + @property + def partnum(self): + return self._partnum + + @property + def serialnum(self): + return self._serialnum + + @property + def macbase(self): + return self._macbase + + @property + def manufdate(self): + return self._manufdate + + @property + def deviceversion(self): + return self._deviceversion + + @property + def labelrevision(self): + return self._labelrevision + + @property + def platformname(self): + return self._platformname + + @property + def onieversion(self): + return self._onieversion + + @property + def macsize(self): + return self._macsize + + @property + def manufname(self): + return self._manufname + + @property + def manufcountry(self): + return self._manufcountry + + @property + def vendorname(self): + return self._vendorname + + @property + def diagname(self): + return self._diagname + + @property + def servicetag(self): + return self._servicetag + + def get_onie_e2_info(self): + try: + eeprom = self.get_eeprom_info(self.e2loc) + if eeprom is None: + raise Exception("%s: value is none" % self.name) + onietlv = onie_tlv() + onietlv.decode(eeprom) + self._cardid = onietlv.cardid + self._productname = onietlv.productname + self._partnum = onietlv.partnum + self._serialnum = onietlv.serialnum + self._macbase = onietlv.macbase + self._manufdate = onietlv.manufdate + self._deviceversion = onietlv.deviceversion + self._labelrevision = onietlv.labelrevision + self._platformname = onietlv.platformname + self._onieversion = onietlv.onieversion + self._macsize = onietlv.macsize + self._manufname = onietlv.manufname + self._manufcountry = onietlv.manufcountry + self._vendorname = onietlv.vendorname + self._diagname = onietlv.diagname + self._servicetag = onietlv.servicetag + except Exception as e: + return False + return True diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/osutil.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/osutil.py new file mode 100755 index 000000000000..aa6f39b20f8c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/osutil.py @@ -0,0 +1,401 @@ +#!/usr/bin/env python3 +####################################################### +# +# osutil.py +# Python implementation of the Class osutil +# Original author: rd@ruijie.com.cn +# +####################################################### + +import os +import time +import glob +import re +from rjutil.smbus import SMBus +import time +import subprocess +from functools import wraps +import fcntl +import syslog + + +PLATFORM_HAL_DEBUG_FILE = "/etc/.platform_hal_debug_flag" + + +def platform_hal_debug(s): + if os.path.exists(PLATFORM_HAL_DEBUG_FILE): + syslog.openlog("PLATFORM_HAL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def retry(maxretry=6, delay=0.01): + ''' + maxretry: max retry times + delay : interval after last retry + ''' + def decorator(f): + @wraps(f) + def wrapper(*args, **kwargs): + time_retry = maxretry + time_delay = delay + result_msg = "" + while time_retry: + try: + val, result_msg = f(*args, **kwargs) + if val is False: + time_retry -= 1 + time.sleep(time_delay) + continue + else: + return val, result_msg + except Exception as e: + time_retry -= 1 + result_msg = str(e) + time.sleep(time_delay) + return False, "max time retry last errmsg is {}".format(result_msg) + return wrapper + return decorator + + +pidfile = -1 + + +def file_rw_lock(file_path): + global pidfile + pidfile = open(file_path, "r") + try: + fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB) + platform_hal_debug("file_rw_lock success") + return True + except Exception as e: + pidfile.close() + pidfile = -1 + return False + + +def file_rw_unlock(): + try: + global pidfile + + if pidfile != -1: + fcntl.flock(pidfile, fcntl.LOCK_UN) + pidfile.close() + pidfile = -1 + platform_hal_debug("file_rw_unlock success") + else: + platform_hal_debug("pidfile is invalid, do nothing") + return True + except Exception as e: + platform_hal_debug("file_rw_unlock err, msg: %s" % (str(e))) + return False + + +def take_file_rw_lock(file_path): + loop = 1000 + ret = False + for i in range(0, loop): + ret = file_rw_lock(file_path) + if ret is True: + break + time.sleep(0.001) + return ret + + +class osutil(object): + """ + osutil + """ + + @staticmethod + @retry(maxretry=6) + def rji2cget_python(bus, addr, reg): + with SMBus(bus) as y: + val, ind = y.read_byte_data(addr, reg, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2cset_python(bus, addr, reg, value): + with SMBus(bus) as y: + val, ind = y.write_byte_data(addr, reg, value, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2cgetword_python(bus, addr, reg): + with SMBus(bus) as y: + val, ind = y.read_word_data(addr, reg, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2csetword_python(bus, addr, reg, value): + with SMBus(bus) as y: + val, ind = y.write_word_data(addr, reg, value, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2csetwordpec_python(bus, addr, reg, value): + with SMBus(bus) as y: + val, ind = y.write_word_data_pec(addr, reg, value, True) + return val, ind + + @staticmethod + @retry(maxretry=6) + def rji2cset_byte_pec_python(bus, addr, reg, value): + with SMBus(bus) as y: + val, ind = y.write_byte_data_pec(addr, reg, value, True) + return val, ind + + @staticmethod + def command(cmdstr): + retcode, output = subprocess.getstatusoutput(cmdstr) + return retcode, output + + @staticmethod + def geti2cword_i2ctool(bus, addr, offset): + command_line = "i2cget -f -y %d 0x%02x 0x%02x wp" % (bus, addr, offset) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + return True, int(ret_t, 16) + time.sleep(0.1) + return False, ret_t + + @staticmethod + def seti2cword_i2ctool(bus, addr, offset, val): + command_line = "i2cset -f -y %d 0x%02x 0x%0x 0x%04x wp" % (bus, addr, offset, val) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + return True, ret_t + time.sleep(0.1) + return False, ret_t + + @staticmethod + def rji2cget_i2ctool(bus, devno, address): + command_line = "i2cget -f -y %d 0x%02x 0x%02x " % (bus, devno, address) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + return True, int(ret_t, 16) + time.sleep(0.1) + return False, ret_t + + @staticmethod + def rji2cset_i2ctool(bus, devno, address, byte): + command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%02x" % ( + bus, devno, address, byte) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + return True, ret_t + return False, ret_t + + @staticmethod + def geti2cword(bus, addr, offset): + return osutil.rji2cgetword_python(bus, addr, offset) + + @staticmethod + def seti2cword(bus, addr, offset, val): + return osutil.rji2csetword_python(bus, addr, offset, val) + + @staticmethod + def seti2cwordpec(bus, addr, offset, val): + return osutil.rji2csetwordpec_python(bus, addr, offset, val) + + @staticmethod + def seti2c_byte_pec(bus, addr, offset, val): + return osutil.rji2cset_byte_pec_python(bus, addr, offset, val) + + @staticmethod + def rji2cget(bus, devno, address): + return osutil.rji2cget_python(bus, devno, address) + + @staticmethod + def rji2cset(bus, devno, address, byte): + return osutil.rji2cset_python(bus, devno, address, byte) + + @staticmethod + def byteTostr(val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + @staticmethod + def io_rd(reg_addr, read_len=1): + try: + regaddr = 0 + if isinstance(reg_addr, int): + regaddr = reg_addr + else: + regaddr = int(reg_addr, 16) + devfile = "/dev/port" + fd = os.open(devfile, os.O_RDWR | os.O_CREAT) + os.lseek(fd, regaddr, os.SEEK_SET) + str = os.read(fd, read_len) + return True, "".join(["%02x" % item for item in str]) + except ValueError as e: + return False, str(e) + except Exception as e: + return False, str(e) + finally: + os.close(fd) + + @staticmethod + def readsysfs(location, flock_path=None): + flock_path_tmp = None + platform_hal_debug("readsysfs, location:%s, flock_path:%s" % (location, flock_path)) + try: + if flock_path is not None: + flock_paths = glob.glob(flock_path) + if len(flock_paths) != 0: + flock_path_tmp = flock_paths[0] + platform_hal_debug("try to get file lock, path:%s" % flock_path_tmp) + ret = take_file_rw_lock(flock_path_tmp) + if ret is False: + platform_hal_debug("take file lock timeout, path:%s" % flock_path_tmp) + return False, ("take file rw lock timeout, path:%s" % flock_path_tmp) + else: + platform_hal_debug("config error, can't find flock_path:%s" % flock_path) + + locations = glob.glob(location) + with open(locations[0], 'rb') as fd1: + retval = fd1.read() + retval = osutil.byteTostr(retval) + if flock_path_tmp is not None: + file_rw_unlock() + + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + except Exception as e: + if flock_path_tmp is not None: + file_rw_unlock() + platform_hal_debug("readsysfs error, msg:%s" % str(e)) + return False, (str(e) + " location[%s]" % location) + return True, retval + + @staticmethod + def writesysfs(location, value): + try: + if not os.path.isfile(location): + print(location, 'not found !') + return False, ("location[%s] not found !" % location) + with open(location, 'w') as fd1: + fd1.write(value) + except Exception as e: + return False, (str(e) + " location[%s]" % location) + return True, ("set location[%s] %s success !" % (location, value)) + + @staticmethod + def getdevmem(addr, digit, mask): + command_line = "devmem 0x%02x %d" % (addr, digit) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = osutil.command(command_line) + if ret == 0: + if mask is not None: + ret_t = str(int(ret_t, 16) & mask) + return True, ret_t + return False, ret_t + + @staticmethod + def readdevfile_ascii(path, offset, len): + msg = "" + ret = "" + joinstr = '' + fd = -1 + + if not os.path.exists(path): + msg = path + " not found !" + return False, msg + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, len) + for item in ret: + joinstr += '%02x ' % item # like sysfs, display in hex + except Exception as e: + msg = str(e) + return False, msg + finally: + if fd > 0: + os.close(fd) + return True, joinstr + + @staticmethod + def readdevfile(path, offset, len): + msg = "" + ret = "" + fd = -1 + + if not os.path.exists(path): + msg = path + " not found !" + return False, msg + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, len) + except Exception as e: + msg = str(e) + return False, msg + finally: + if fd > 0: + os.close(fd) + return True, ret + + @staticmethod + def rj_os_system(cmd): + status, output = subprocess.getstatusoutput(cmd) + return status, output + + @staticmethod + def getsdkreg(reg): + try: + cmd = "bcmcmd -t 1 'getr %s ' < /dev/null" % reg + ret, result = osutil.rj_os_system(cmd) + result_t = result.strip().replace("\r", "").replace("\n", "") + if ret != 0 or "Error:" in result_t: + return False, result + patt = r"%s.(.*):(.*)>drivshell" % reg + rt = re.findall(patt, result_t, re.S) + test = re.findall("=(.*)", rt[0][0])[0] + except Exception as e: + return False, 'get sdk register error' + return True, test + + @staticmethod + def getmactemp(): + try: + result = {} + # waitForDocker() + # need to exec twice + osutil.rj_os_system("bcmcmd -t 1 \"show temp\" < /dev/null") + ret, log = osutil.rj_os_system("bcmcmd -t 1 \"show temp\" < /dev/null") + if ret: + return False, result + else: + logs = log.splitlines() + for line in logs: + if "average" in line: + b = re.findall(r'\d+.\d+', line) + result["average"] = b[0] + elif "maximum" in line: + b = re.findall(r'\d+.\d+', line) + result["maximum"] = b[0] + except Exception as e: + return False, str(e) + return True, result diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/psu.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/psu.py new file mode 100755 index 000000000000..d59173c5670b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/psu.py @@ -0,0 +1,620 @@ +#!/usr/bin/env python3 +####################################################### +# +# psu.py +# Python implementation of the Class psu +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from eepromutil.fru import ipmifru +from plat_hal.sensor import sensor + + +class psu(devicebase): + __pmbus = None + __e2loc = None + __present = None + __productManufacturer = None # : ARTESYN + __productName = None # : CRPS550W + __productPartModelName = None # : CSU550AP-3-300 + __productVersion = None # : AB + __productSerialNumber = None # : M623UZ00JYABL + __AirFlow = None # 'N/A' + __AirFlowconifg = None + __psu_display_name = None # 'N/A' + __psu_display_name_conifg = None + __psu_not_present_pwm = None + __InputStatus_config = None + __OutputStatus_config = None + __FanSpeed_config = None + __Temperature_config = None + __InputStatus = None + __OutputStatus = None + __FanSpeed = None + __Temperature = None + __FanSpeedMin = None + __FanSpeedMax = None + __FanSpeedTolerance = None + __InputsVoltage_config = None + __InputsCurrent_config = None + __InputsPower_config = None + __OutputsVoltage_config = None + __OutputsCurrent_config = None + __OutputsPower_config = None + __InputsVoltage = {} + __InputsCurrent = None + __InputsPower = None + __OutputsVoltage = None + __OutputsCurrent = None + __OutputsPower = None + __InputsType_config = None + __InputsType = None + __psu_sn_config = None + __psu_hw_config = None + __psu_pn_config = None + __psu_vendor_config = None + __TempStatus_config = None + __FanStatus_config = None + __TempStatus = None + __FanStatus = None + + def __init__(self, conf=None): + self.pmbus = conf.get("pmbusloc", None) + self.e2loc = conf.get("e2loc", None) + self.__presentconfig = conf.get("present", None) + self.name = conf.get("name", None) + self.AirFlowconifg = conf.get("airflow", None) + self.psu_display_name_conifg = conf.get("psu_display_name", None) + self.psu_not_present_pwm = conf.get("psu_not_present_pwm", 100) + self.Temperature_config = conf.get("Temperature", None) + self.Temperature = sensor(self.Temperature_config) + + self.FanSpeedTolerance = conf.get('psu_fan_tolerance', 30) + self.FanSpeed_config = conf.get("FanSpeed", None) + self.FanSpeed = sensor(self.FanSpeed_config) + + self.__InputsVoltage_config = conf.get("InputsVoltage", None) + self.generate_psu_input_vol(self.__InputsVoltage_config) + self.__InputsCurrent_config = conf.get("InputsCurrent", None) + self.InputsCurrent = sensor(self.__InputsCurrent_config) + self.__InputsPower_config = conf.get("InputsPower", None) + self.InputsPower = sensor(self.__InputsPower_config) + self.__OutputsVoltage_config = conf.get("OutputsVoltage", None) + self.OutputsVoltage = sensor(self.__OutputsVoltage_config) + self.__OutputsCurrent_config = conf.get("OutputsCurrent", None) + self.OutputsCurrent = sensor(self.__OutputsCurrent_config) + self.__OutputsPower_config = conf.get("OutputsPower", None) + self.OutputsPower = sensor(self.__OutputsPower_config) + + self.__InputStatus_config = conf.get("InputsStatus", None) + self.__OutputStatus_config = conf.get("OutputsStatus", None) + self.__InputsType_config = conf.get('InputsType', None) + self.__psu_sn_config = conf.get('psu_sn', None) + self.__psu_hw_config = conf.get('psu_hw', None) + self.__psu_pn_config = conf.get('psu_pn', None) + self.__psu_vendor_config = conf.get('psu_vendor', None) + self.__TempStatus_config = conf.get("TempStatus", None) + self.__FanStatus_config = conf.get("FanStatus", None) + + def generate_psu_input_vol(self, config): + tmp = {} + for (key, item) in config.items(): + tmp.setdefault(key, sensor(item)) + self.__InputsVoltage = tmp + + def get_psu_sensor_by_name(self, psutype): + return self.__InputsVoltage.get(psutype) or self.__InputsVoltage.get('other') + + @property + def InputsVoltage(self): + psutype = self.InputsType + input_sensor = self.get_psu_sensor_by_name(psutype) + if input_sensor is None: + return None + else: + return input_sensor + + @InputsVoltage.setter + def InputsVoltage(self, val): + self.__InputsVoltage = val + + @property + def InputsCurrent(self): + return self.__InputsCurrent + + @InputsCurrent.setter + def InputsCurrent(self, val): + self.__InputsCurrent = val + + @property + def InputsPower(self): + return self.__InputsPower + + @InputsPower.setter + def InputsPower(self, val): + self.__InputsPower = val + + @property + def OutputsVoltage(self): + return self.__OutputsVoltage + + @OutputsVoltage.setter + def OutputsVoltage(self, val): + self.__OutputsVoltage = val + + @property + def OutputsCurrent(self): + return self.__OutputsCurrent + + @OutputsCurrent.setter + def OutputsCurrent(self, val): + self.__OutputsCurrent = val + + @property + def OutputsPower(self): + return self.__OutputsPower + + @OutputsPower.setter + def OutputsPower(self, val): + self.__OutputsPower = val + + @property + def InputStatus(self): + if self.present == False: + self.__InputStatus = False + else: + ret, val = self.get_value(self.__InputStatus_config) + mask = self.__InputStatus_config.get("mask") + if ret == True: + ttt = val & mask + if ttt == 0: + self.__InputStatus = True + else: + self.__InputStatus = False + else: + self.__InputStatus = False + return self.__InputStatus + + @InputStatus.setter + def InputStatus(self, val): + self.__InputStatus = val + + @property + def TempStatus(self): + if self.__TempStatus_config is None: + return None + if self.present == False: + self.__TempStatus = False + else: + ret, val = self.get_value(self.__TempStatus_config) + mask = self.__TempStatus_config.get("mask") + if ret == True: + ttt = val & mask + if ttt == 0: + self.__TempStatus = True + else: + self.__TempStatus = False + else: + self.__TempStatus = False + return self.__TempStatus + + @TempStatus.setter + def TempStatus(self, val): + self.__TempStatus = val + + @property + def FanStatus(self): + if self.__FanStatus_config is None: + return None + if self.present == False: + self.__FanStatus = False + else: + ret, val = self.get_value(self.__FanStatus_config) + mask = self.__FanStatus_config.get("mask") + if ret == True: + ttt = val & mask + if ttt == 0: + self.__FanStatus = True + else: + self.__FanStatus = False + else: + self.__FanStatus = False + return self.__FanStatus + + @FanStatus.setter + def FanStatus(self, val): + self.__FanStatus = val + + @property + def InputsType(self): + psutypedecode = self.__InputsType_config.get('psutypedecode', None) + if self.present == False: + self.__InputsType = psutypedecode.get(0x00) + else: + ret, val = self.get_value(self.__InputsType_config) + self.__InputsType = self.__InputsType_config.get(val, None) + if self.__InputsType is not None: + return self.__InputsType + if ret == True and val in psutypedecode: + self.__InputsType = psutypedecode.get(val) + else: + self.__InputsType = psutypedecode.get(0x00) + return self.__InputsType + + @InputsType.setter + def InputsType(self, val): + self.__InputsType = val + + @property + def FanSpeedMin(self): + return self.__FanSpeedMin + + @FanSpeedMin.setter + def FanSpeedMin(self, val): + self.__FanSpeedMin = val + + @property + def FanSpeedMax(self): + return self.__FanSpeedMax + + @FanSpeedMax.setter + def FanSpeedMax(self, val): + self.__FanSpeedMax = val + + @property + def FanSpeedTolerance(self): + return self.__FanSpeedTolerance + + @FanSpeedTolerance.setter + def FanSpeedTolerance(self, val): + self.__FanSpeedTolerance = val + + @property + def OutputStatus(self): + if self.present == False: + self.__OutputStatus = False + else: + ret, val = self.get_value(self.__OutputStatus_config) + mask = self.__OutputStatus_config.get("mask") + if ret == True: + ttt = val & mask + if ttt == 0: + self.__OutputStatus = True + else: + self.__OutputStatus = False + else: + self.__OutputStatus = False + return self.__OutputStatus + + @OutputStatus.setter + def OutputStatus(self, val): + self.__OutputStatus = val + + @property + def FanSpeed(self): + return self.__FanSpeed + + @FanSpeed.setter + def FanSpeed(self, val): + self.__FanSpeed = val + + @property + def Temperature(self): + return self.__Temperature + + @Temperature.setter + def Temperature(self, val): + self.__Temperature = val + + @property + def Temperature_config(self): + return self.__Temperature_config + + @Temperature_config.setter + def Temperature_config(self, val): + self.__Temperature_config = val + + @property + def AirFlowconifg(self): + return self.__AirFlowconifg + + @AirFlowconifg.setter + def AirFlowconifg(self, val): + self.__AirFlowconifg = val + + @property + def psu_display_name_conifg(self): + return self.__psu_display_name_conifg + + @psu_display_name_conifg.setter + def psu_display_name_conifg(self, val): + self.__psu_display_name_conifg = val + + @property + def pmbus(self): + return self.__pmbus + + @pmbus.setter + def pmbus(self, val): + self.__pmbus = val + + @property + def e2loc(self): + return self.__e2loc + + @e2loc.setter + def e2loc(self, val): + self.__e2loc = val + + @property + def AirFlow(self): + return self.__AirFlow + + @AirFlow.setter + def AirFlow(self, val): + self.__AirFlow = val + + @property + def psu_display_name(self): + return self.__psu_display_name + + @psu_display_name.setter + def psu_display_name(self, val): + self.__psu_display_name = val + + @property + def psu_not_present_pwm(self): + return self.__psu_not_present_pwm + + @psu_not_present_pwm.setter + def psu_not_present_pwm(self, val): + self.__psu_not_present_pwm = val + + @property + def present(self): + ret, val = self.get_value(self.__presentconfig) + if ret is False or val is None: + return False + mask = self.__presentconfig.get("mask") + if isinstance(val, str): + value = int(val, 16) + else: + value = val + ttt = value & mask + okval = self.__presentconfig.get("okval", 0) + if ttt == okval: + return True + else: + return False + + @present.setter + def present(self, val): + self.__present = val + + @property + def productManufacturer(self): + return self.__productManufacturer + + @productManufacturer.setter + def productManufacturer(self, val): + self.__productManufacturer = val + + @property + def productName(self): + return self.__productName + + @productName.setter + def productName(self, val): + self.__productName = val + + @property + def productPartModelName(self): + return self.__productPartModelName + + @productPartModelName.setter + def productPartModelName(self, val): + self.__productPartModelName = val + + @property + def productVersion(self): + return self.__productVersion + + @productVersion.setter + def productVersion(self, val): + self.__productVersion = val + + @property + def productSerialNumber(self): + return self.__productSerialNumber + + @productSerialNumber.setter + def productSerialNumber(self, val): + self.__productSerialNumber = val + + @property + def psu_sn_sysfs(self): + if self.__psu_sn_config is None: + return None + ret, val = self.get_value(self.__psu_sn_config) + if ret is False or val is None: + return None + return val + + @property + def psu_hw_sysfs(self): + if self.__psu_hw_config is None: + return None + ret, val = self.get_value(self.__psu_hw_config) + if ret is False or val is None: + return None + return val + + @property + def psu_pn_sysfs(self): + if self.__psu_pn_config is None: + return None + ret, val = self.get_value(self.__psu_pn_config) + if ret is False or val is None: + return None + return val + + @property + def psu_vendor_sysfs(self): + if self.__psu_vendor_config is None: + return None + ret, val = self.get_value(self.__psu_vendor_config) + if ret is False or val is None: + return None + return val + + def __str__(self): + formatstr = \ + "name : %s \n" \ + "productManufacturer : %s \n" \ + "productName : %s \n" \ + "productPartModelName: %s \n" \ + "productVersion : %s \n" \ + "productSerialNumber : %s \n" \ + "AirFlow : %s \n" \ + + tmpstr = formatstr % (self.name, self.productManufacturer, + self.productName, self.productPartModelName, + self.productVersion, self.productSerialNumber, self.AirFlow) + return tmpstr + + def get_fan_speed_pwm(self): + if self.present == False: + return self.psu_not_present_pwm + selfconfig = {} + selfconfig['bus'] = self.pmbus['bus'] + selfconfig['addr'] = self.pmbus['addr'] + selfconfig['way'] = 'i2cword' + selfconfig['offset'] = 0x3b + ret, val = self.get_value(selfconfig) + if ret == True: + return val + else: + return None + + def set_fan_speed_pwm(self, pwm): + ''' + pmbus + if duty: + i2cset -f -y 0x3b 0x0064 wp + ''' + if self.present == False: + return None + if 0 <= pwm <= 100: + '''enable duty first ''' + selfconfig = {} + + selfconfig['bus'] = self.pmbus['bus'] + selfconfig['addr'] = self.pmbus['addr'] + selfconfig['way'] = 'i2cpec' + selfconfig['offset'] = 0x3a + self.set_value(selfconfig, 0x80) + + selfconfig['way'] = 'i2cwordpec' + selfconfig['offset'] = 0x3b + bytetmp = pwm + ret, val = self.set_value(selfconfig, int(bytetmp)) + if ret == True: + return True + else: + return None + else: + raise Exception("pwm not in range [0,100]") + + def get_fru_info_by_sysfs(self): + try: + psu_sn = self.psu_sn_sysfs + psu_hw = self.psu_hw_sysfs + psu_pn = self.psu_pn_sysfs + psu_vendor = self.psu_vendor_sysfs + if psu_sn is None or psu_hw is None or psu_pn is None or psu_vendor is None: + return False + self.productSerialNumber = psu_sn.strip().replace(chr(0), "") + self.productVersion = psu_hw.strip() + self.productPartModelName = psu_pn.strip() + self.productManufacturer = psu_vendor.strip().replace(chr(0), "") + except Exception as e: + self.productSerialNumber = None + self.productVersion = None + self.productPartModelName = None + self.productManufacturer = None + return False + return True + + def get_fru_info_by_decode(self): + try: + eeprom = self.get_eeprom_info(self.e2loc) + if eeprom is None: + raise Exception("%s:value is none" % self.name) + fru = ipmifru() + if isinstance(eeprom, bytes): + eeprom = self.byteTostr(eeprom) + fru.decodeBin(eeprom) + if fru.productInfoArea is not None: + self.productManufacturer = fru.productInfoArea.productManufacturer.strip() + self.productName = fru.productInfoArea.productName.strip() + self.productPartModelName = fru.productInfoArea.productPartModelName.strip() + self.productVersion = fru.productInfoArea.productVersion.strip() + self.productSerialNumber = fru.productInfoArea.productSerialNumber.strip().replace(chr(0), "") + except Exception as e: + self.productManufacturer = None + self.productName = None + self.productPartModelName = None + self.productVersion = None + self.productSerialNumber = None + return False + return True + + def get_fru_info(self): + try: + if self.present is not True: + raise Exception("%s: not present" % self.name) + if self.get_fru_info_by_sysfs() is True: + return True + return self.get_fru_info_by_decode() + except Exception as e: + self.productManufacturer = None + self.productName = None + self.productPartModelName = None + self.productVersion = None + self.productSerialNumber = None + return False + + def get_AirFlow(self): + if self.productPartModelName is None: + ret = self.get_fru_info() + if ret is False: + self.AirFlow = None + return False + if self.AirFlowconifg is None: + self.AirFlow = None + return False + else: + for i in self.AirFlowconifg: + if self.productPartModelName in self.AirFlowconifg[i]: + self.AirFlow = i + return True + self.AirFlow = None + return False + + def get_psu_display_name(self): + if self.productPartModelName is None: + ret = self.get_fru_info() + if ret is False: + self.psu_display_name = None + return False + if self.psu_display_name_conifg is None: + self.psu_display_name = self.productPartModelName + return False + else: + for i in self.psu_display_name_conifg: + if self.productPartModelName in self.psu_display_name_conifg[i]: + self.psu_display_name = i + return True + self.psu_display_name = self.productPartModelName + return False diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/rotor.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/rotor.py new file mode 100755 index 000000000000..80e318d4132a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/rotor.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +####################################################### +# +# rotor.py +# Python implementation of the Class rotor +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.devicebase import devicebase +from plat_hal.sensor import sensor + + +class rotor(devicebase): + __rotor_Running = None + __rotor_HwAlarm_conf = None + __rotor_Speed = None + __rotor_run_conf = None + __Speedconfig = None + __i2c_speed = None + __SpeedMin = None + __SpeedMax = None + __SpeedTolerance = None + + def __init__(self, conf=None): + self.name = conf.get('name', None) + self.rotor_HwAlarm_conf = conf.get('HwAlarm', None) + self.rotor_run_conf = conf.get('Running', None) + self.SpeedMin = conf.get('SpeedMin', None) + self.SpeedMax = conf.get('SpeedMax', None) + self.Tolerance = conf.get('tolerance', 30) + self.rotor_Speed = sensor(conf.get('Speed', None)) + self.Speedconfig = conf.get('Set_speed', None) + + def getRunning(self): + ret, val = self.get_value(self.rotor_run_conf) + if ret is False or val is None: + return False + if isinstance(val, str): + value = int(val, 16) + else: + value = val + mask = self.rotor_run_conf.get("mask") + is_runing_value = self.rotor_run_conf.get("is_runing") + flag = value & mask + if flag == is_runing_value: + return True + else: + return False + + @property + def SpeedMin(self): + return self.__SpeedMin + + @SpeedMin.setter + def SpeedMin(self, val): + self.__SpeedMin = val + + @property + def SpeedMax(self): + return self.__SpeedMax + + @SpeedMax.setter + def SpeedMax(self, val): + self.__SpeedMax = val + + @property + def Tolerance(self): + return self.__SpeedTolerance + + @Tolerance.setter + def Tolerance(self, val): + self.__SpeedTolerance = val + + @property + def i2c_speed(self): + ret, val = self.get_value(self.Speedconfig) + if ret == False: + return None + if val is not None: + self.__i2c_speed = val + return self.__i2c_speed + + def feed_watchdog(self): + ret, val = self.get_value(self.Speedconfig) + if ret == False: + return False, None + if val is not None: + ret, val = self.set_value(self.Speedconfig, val) + return ret, val + return False, None + + @i2c_speed.setter + def i2c_speed(self, val): + self.__i2c_speed = val + + @property + def Speedconfig(self): + return self.__Speedconfig + + @Speedconfig.setter + def Speedconfig(self, val): + self.__Speedconfig = val + + @property + def rotor_run_conf(self): + return self.__rotor_run_conf + + @rotor_run_conf.setter + def rotor_run_conf(self, val): + self.__rotor_run_conf = val + + @property + def rotor_Speed(self): + return self.__rotor_Speed + + @rotor_Speed.setter + def rotor_Speed(self, val): + self.__rotor_Speed = val + + @property + def rotor_HwAlarm(self): + ret, val = self.get_value(self.rotor_HwAlarm_conf) + mask = self.rotor_HwAlarm_conf.get("mask") + no_alarm_value = self.rotor_HwAlarm_conf.get("no_alarm") + if ret is False or val is None: + return False + if isinstance(val, str): + value = int(val, 16) + else: + value = val + flag = value & mask + if flag == no_alarm_value: + return False + else: + return True + + @rotor_HwAlarm.setter + def rotor_HwAlarm(self, val): + self.__rotor_HwAlarm = val + + @property + def rotor_HwAlarm_conf(self): + return self.__rotor_HwAlarm_conf + + @rotor_HwAlarm_conf.setter + def rotor_HwAlarm_conf(self, val): + self.__rotor_HwAlarm_conf = val + + @property + def rotor_Running(self): + self.__rotor_Running = self.getRunning() + return self.__rotor_Running + + @rotor_Running.setter + def rotor_Running(self, val): + self.__rotor_Running = val diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/sensor.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/sensor.py new file mode 100755 index 000000000000..eb932f2629b0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/sensor.py @@ -0,0 +1,220 @@ +#!/usr/bin/env python3 +####################################################### +# +# sensor.py +# Python implementation of the Class sensor +# Original author: rd@ruijie.com.cn +# +####################################################### +import time +from plat_hal.devicebase import devicebase + + +class sensor(devicebase): + + __Value = None + __Min = None + __Max = None + __Low = None + __High = None + __ValueConfig = None + __Flag = None + __Unit = None + __format = None + __read_times = None + + __Min_config = None + __Max_config = None + __Low_config = None + __High_config = None + + @property + def Min_config(self): + return self.__Min_config + + @Min_config.setter + def Min_config(self, val): + self.__Min_config = val + + @property + def Max_config(self): + return self.__Max_config + + @Max_config.setter + def Max_config(self, val): + self.__Max_config = val + + @property + def Low_config(self): + return self.__Low_config + + @Low_config.setter + def Low_config(self, val): + self.__Low_config = val + + @property + def High_config(self): + return self.__High_config + + @High_config.setter + def High_config(self, val): + self.__High_config = val + + @property + def Unit(self): + return self.__Unit + + @Unit.setter + def Unit(self, val): + self.__Unit = val + + @property + def format(self): + return self.__format + + @format.setter + def format(self, val): + self.__format = val + + @property + def read_times(self): + return self.__read_times + + @read_times.setter + def read_times(self, val): + self.__read_times = val + + @property + def ValueConfig(self): + return self.__ValueConfig + + @ValueConfig.setter + def ValueConfig(self, val): + self.__ValueConfig = val + + @property + def Flag(self): + return self.__Flag + + @Flag.setter + def Flag(self, val): + self.__Flag = val + + def get_median(self, value_config, read_times): + val_list = [] + for i in range(0, read_times): + ret, real_value = self.get_value(value_config) + if i != (read_times - 1): + time.sleep(0.01) + if ret is False or real_value is None: + continue + val_list.append(real_value) + val_list.sort() + if val_list: + return True, val_list[int((len(val_list) - 1) / 2)] + return False, None + + @property + def Value(self): + try: + ret, val = self.get_median(self.ValueConfig, self.read_times) + if ret is False or val is None: + return None + if self.format is None: + self.__Value = int(val) + else: + self.__Value = eval(self.format % val) + self.__Value = round(float(self.__Value), 3) + except Exception as e: + return None + return self.__Value + + @Value.setter + def Value(self, val): + self.__Value = val + + @property + def Min(self): + try: + if self.format is None: + self.__Min = self.Min_config + else: + self.__Min = eval(self.format % self.Min_config) + self.__Min = round(float(self.__Min), 3) + except Exception as e: + return None + return self.__Min + + @Min.setter + def Min(self, val): + self.__Min = val + + @property + def Max(self): + try: + if self.format is None: + self.__Max = self.Max_config + else: + self.__Max = eval(self.format % self.Max_config) + self.__Max = round(float(self.__Max), 3) + except Exception as e: + return None + return self.__Max + + @Max.setter + def Max(self, val): + self.__Max = val + + @property + def Low(self): + try: + if self.format is None: + self.__Low = self.Low_config + else: + self.__Low = eval(self.format % self.Low_config) + except Exception as e: + return None + return self.__Low + + @Low.setter + def Low(self, val): + self.__Low = val + + @property + def High(self): + try: + if self.format is None: + self.__High = self.High_config + else: + self.__High = eval(self.format % self.High_config) + except Exception as e: + return None + return self.__High + + @High.setter + def High(self, val): + self.__High = val + + def __init__(self, conf=None): + self.ValueConfig = conf.get("value", None) + self.Flag = conf.get("flag", None) + self.Min_config = conf.get("Min", None) + self.Max_config = conf.get("Max", None) + self.Low_config = conf.get("Low", None) + self.High_config = conf.get("High", None) + self.Unit = conf.get('Unit', None) + self.format = conf.get('format', None) + self.read_times = conf.get('read_times', 1) + + def __str__(self): + formatstr = \ + "ValueConfig: : %s \n" \ + "Min : %s \n" \ + "Max : %s \n" \ + "Unit : %s \n" \ + "format: : %s \n" + + tmpstr = formatstr % (self.ValueConfig, self.Min, + self.Max, self.Unit, + self.format) + return tmpstr diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/temp.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/temp.py new file mode 100755 index 000000000000..2652d11cc493 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/plat_hal/temp.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python3 +####################################################### +# +# temp.py +# Python implementation of the Class temp +# Original author: rd@ruijie.com.cn +# +####################################################### +from plat_hal.sensor import sensor +import os +import syslog + + +PLATFORM_HAL_TEMP_DEBUG_FILE = "/etc/.platform_hal_temp_debug_flag" + +def platform_hal_temp_debug(s): + if os.path.exists(PLATFORM_HAL_TEMP_DEBUG_FILE): + syslog.openlog("PLATFORM_HAL_TEPM", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + +class temp(sensor): + def __init__(self, conf=None): + super(temp, self).__init__(conf.get('Temperature', None)) + self.name = conf.get("name", None) + self.temp_id = conf.get("temp_id", None) + self.api_name = conf.get("api_name", self.name) + self.fix_value = conf.get("fix_value", None) + self.temp_invalid = conf.get("invalid", None) + self.temp_error = conf.get("error", None) + + def __str__(self): + super(temp, self).__str__() + + def temp_cali_by_fan_pwm(self, param, origin_value): + fan_pwm_conf = param.get("fan_pwm") + temp_fix_list = param.get("temp_fix_list") + + + ret, val = self.get_value(fan_pwm_conf) + if ret is False or val is None: + platform_hal_temp_debug("temp calibration get fan pwm failed, msg: %s, return None" % (val)) + return None + + fan_pwm = int(val) + for item in temp_fix_list: + if fan_pwm >= item["min"] and fan_pwm <= item["max"]: + fix_value = origin_value + item["fix"] + platform_hal_temp_debug("temp calibration by fan pwm, origin_value: %s, pwm: %s, fix_value: %s" % + (origin_value, fan_pwm, fix_value)) + return fix_value + platform_hal_temp_debug("temp calibration by fan pwm, origin_value: %s, pwm: %s, not match return None" % + (origin_value, fan_pwm)) + return None + + def fix_temp_value(self, origin_value): + try: + fix_type = self.fix_value.get("fix_type") + + if fix_type == "func": + func_name = self.fix_value.get("func_name") + func_param = self.fix_value.get("func_param") + value = eval(func_name)(func_param, origin_value) + return value + + if fix_type == "config": + coefficient = self.fix_value.get("coefficient", 1) + addend = self.fix_value.get("addend", 0) + value = (origin_value + addend) * coefficient + platform_hal_temp_debug("temp calibration by config, coefficient: %s, addend: %s, origin_value: %s, fix_value: %s" % + (coefficient, addend, origin_value, value)) + return value + + platform_hal_temp_debug("unsupport fix type: %s, return origin value: %s" % (fix_type, origin_value)) + return origin_value + except Exception as e: + platform_hal_temp_debug("fix_temp_value raise exception, msg: %s" % (str(e))) + return None + + def get_max_value(self, conf): + try: + ret, val = self.get_value(conf) + if ret is False or val is None: + return None + return val + except Exception as e: + return None + + def check_flag(self): + try: + okbit = self.Flag.get('okbit') + okval = self.Flag.get('okval') + ret, val = self.get_value(self.Flag) + if (ret == False) or (val is None): + return False + val_t = (int(val) & (1 << okbit)) >> okbit + if val_t != okval: + return False + except Exception as e: + return False + return True + + @property + def Value(self): + try: + if self.Flag is not None: + if self.check_flag() == False: + return None + if isinstance(self.ValueConfig, list): + max = None + for i in self.ValueConfig: + tmp = self.get_max_value(i) + if tmp is None: + continue + if max is None or max < tmp: + max = tmp + if max is None: + return None + if self.format is None: + self.__Value = int(max) + else: + self.__Value = eval(self.format % max) + else: + ret, val = self.get_value(self.ValueConfig) + if ret is False or val is None: + return None + if self.format is None: + self.__Value = int(val) + else: + self.__Value = eval(self.format % val) + except Exception as e: + return None + if self.fix_value is not None and self.__Value != self.temp_invalid and self.__Value != self.temp_error: + self.__Value = self.fix_temp_value(self.__Value) + return self.__Value + + @Value.setter + def Value(self, val): + self.__Value = val diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/baseutil.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/baseutil.py new file mode 100755 index 000000000000..fa7dadd91350 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/baseutil.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +import os + + +def get_machine_info(): + if not os.path.isfile('/host/machine.conf'): + return None + machine_vars = {} + with open('/host/machine.conf') as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars + + +def get_platform_info(machine_info): + if machine_info is not None: + if 'onie_platform' in machine_info: + return machine_info['onie_platform'] + elif 'aboot_platform' in machine_info: + return machine_info['aboot_platform'] + return None + + +def get_board_id(machine_info): + if machine_info is not None: + if 'onie_board_id' in machine_info: + return machine_info['onie_board_id'].lower() + return "NA" + + +def get_onie_machine(machine_info): + if machine_info is not None: + if 'onie_machine' in machine_info: + return machine_info['onie_machine'] + return None + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/smbus.py b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/smbus.py new file mode 100755 index 000000000000..f3fee702bb46 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/lib/rjutil/smbus.py @@ -0,0 +1,777 @@ +#!/usr/bin/env python3 +# smbus2 - A drop-in replacement for smbus-cffi/smbus-python +# The MIT License (MIT) +# Copyright (c) 2017 Karl-Petter Lindegaard +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import os +import sys +from fcntl import ioctl +from ctypes import c_uint32, c_uint8, c_uint16, c_char, POINTER, Structure, Array, Union, create_string_buffer, string_at + + +# Commands from uapi/linux/i2c-dev.h +I2C_SLAVE = 0x0703 # Use this slave address +I2C_SLAVE_FORCE = 0x0706 # Use this slave address, even if it is already in use by a driver! +I2C_FUNCS = 0x0705 # Get the adapter functionality mask +I2C_RDWR = 0x0707 # Combined R/W transfer (one STOP only) +I2C_SMBUS = 0x0720 # SMBus transfer. Takes pointer to i2c_smbus_ioctl_data +I2C_PEC = 0x0708 + +# SMBus transfer read or write markers from uapi/linux/i2c.h +I2C_SMBUS_WRITE = 0 +I2C_SMBUS_READ = 1 + +# Size identifiers uapi/linux/i2c.h +I2C_SMBUS_QUICK = 0 +I2C_SMBUS_BYTE = 1 +I2C_SMBUS_BYTE_DATA = 2 +I2C_SMBUS_WORD_DATA = 3 +I2C_SMBUS_PROC_CALL = 4 +# This isn't supported by Pure-I2C drivers with SMBUS emulation, like those in RaspberryPi, OrangePi, etc :( +I2C_SMBUS_BLOCK_DATA = 5 +I2C_SMBUS_BLOCK_PROC_CALL = 7 # Like I2C_SMBUS_BLOCK_DATA, it isn't supported by Pure-I2C drivers either. +I2C_SMBUS_I2C_BLOCK_DATA = 8 +I2C_SMBUS_BLOCK_MAX = 32 + +# To determine what functionality is present (uapi/linux/i2c.h) +try: + from enum import IntFlag +except Exception as e: + IntFlag = int + + +class I2cFunc(IntFlag): + """ + These flags identify the operations supported by an I2C/SMBus device. + + You can test these flags on your `smbus.funcs` + + On newer python versions, I2cFunc is an IntFlag enum, but it + falls back to class with a bunch of int constants on older releases. + """ + I2C = 0x00000001 + ADDR_10BIT = 0x00000002 + PROTOCOL_MANGLING = 0x00000004 # I2C_M_IGNORE_NAK etc. + SMBUS_PEC = 0x00000008 + NOSTART = 0x00000010 # I2C_M_NOSTART + SLAVE = 0x00000020 + SMBUS_BLOCK_PROC_CALL = 0x00008000 # SMBus 2.0 + SMBUS_QUICK = 0x00010000 + SMBUS_READ_BYTE = 0x00020000 + SMBUS_WRITE_BYTE = 0x00040000 + SMBUS_READ_BYTE_DATA = 0x00080000 + SMBUS_WRITE_BYTE_DATA = 0x00100000 + SMBUS_READ_WORD_DATA = 0x00200000 + SMBUS_WRITE_WORD_DATA = 0x00400000 + SMBUS_PROC_CALL = 0x00800000 + SMBUS_READ_BLOCK_DATA = 0x01000000 + SMBUS_WRITE_BLOCK_DATA = 0x02000000 + SMBUS_READ_I2C_BLOCK = 0x04000000 # I2C-like block xfer + SMBUS_WRITE_I2C_BLOCK = 0x08000000 # w/ 1-byte reg. addr. + SMBUS_HOST_NOTIFY = 0x10000000 + + SMBUS_BYTE = 0x00060000 + SMBUS_BYTE_DATA = 0x00180000 + SMBUS_WORD_DATA = 0x00600000 + SMBUS_BLOCK_DATA = 0x03000000 + SMBUS_I2C_BLOCK = 0x0c000000 + SMBUS_EMUL = 0x0eff0008 + + +# i2c_msg flags from uapi/linux/i2c.h +I2C_M_RD = 0x0001 + +# Pointer definitions +LP_c_uint8 = POINTER(c_uint8) +LP_c_uint16 = POINTER(c_uint16) +LP_c_uint32 = POINTER(c_uint32) + + +############################################################# +# Type definitions as in i2c.h + + +class i2c_smbus_data(Array): + """ + Adaptation of the i2c_smbus_data union in ``i2c.h``. + + Data for SMBus messages. + """ + _length_ = I2C_SMBUS_BLOCK_MAX + 2 + _type_ = c_uint8 + + +class union_i2c_smbus_data(Union): + _fields_ = [ + ("byte", c_uint8), + ("word", c_uint16), + ("block", i2c_smbus_data) + ] + + +union_pointer_type = POINTER(union_i2c_smbus_data) + + +class i2c_smbus_ioctl_data(Structure): + """ + As defined in ``i2c-dev.h``. + """ + _fields_ = [ + ('read_write', c_uint8), + ('command', c_uint8), + ('size', c_uint32), + ('data', union_pointer_type)] + __slots__ = [name for name, type in _fields_] + + @staticmethod + def create(read_write=I2C_SMBUS_READ, command=0, size=I2C_SMBUS_BYTE_DATA): + u = union_i2c_smbus_data() + return i2c_smbus_ioctl_data( + read_write=read_write, command=command, size=size, + data=union_pointer_type(u)) + + +############################################################# +# Type definitions for i2c_rdwr combined transactions + + +class i2c_msg(Structure): + """ + As defined in ``i2c.h``. + """ + _fields_ = [ + ('addr', c_uint16), + ('flags', c_uint16), + ('len', c_uint16), + ('buf', POINTER(c_char))] + + def __iter__(self): + """ Iterator / Generator + + :return: iterates over :py:attr:`buf` + :rtype: :py:class:`generator` which returns int values + """ + idx = 0 + while idx < self.len: + yield ord(self.buf[idx]) + idx += 1 + + def __len__(self): + return self.len + + def __bytes__(self): + return string_at(self.buf, self.len) + + def __repr__(self): + return 'i2c_msg(%d,%d,%r)' % (self.addr, self.flags, self.__bytes__()) + + def __str__(self): + s = self.__bytes__() + if sys.version_info.major >= 3: + s = ''.join(map(chr, s)) + return s + + @staticmethod + def read(address, length): + """ + Prepares an i2c read transaction. + + :param address: Slave address. + :type: address: int + :param length: Number of bytes to read. + :type: length: int + :return: New :py:class:`i2c_msg` instance for read operation. + :rtype: :py:class:`i2c_msg` + """ + arr = create_string_buffer(length) + return i2c_msg( + addr=address, flags=I2C_M_RD, len=length, + buf=arr) + + @staticmethod + def write(address, buf): + """ + Prepares an i2c write transaction. + + :param address: Slave address. + :type address: int + :param buf: Bytes to write. Either list of values or str. + :type buf: list + :return: New :py:class:`i2c_msg` instance for write operation. + :rtype: :py:class:`i2c_msg` + """ + if sys.version_info.major >= 3: + if isinstance(buf, str): + buf = bytes(map(ord, buf)) + else: + buf = bytes(buf) + else: + if not isinstance(buf, str): + buf = ''.join([chr(x) for x in buf]) + arr = create_string_buffer(buf, len(buf)) + return i2c_msg( + addr=address, flags=0, len=len(arr), + buf=arr) + + +class i2c_rdwr_ioctl_data(Structure): + """ + As defined in ``i2c-dev.h``. + """ + _fields_ = [ + ('msgs', POINTER(i2c_msg)), + ('nmsgs', c_uint32) + ] + __slots__ = [name for name, type in _fields_] + + @staticmethod + def create(*i2c_msg_instances): + """ + Factory method for creating a i2c_rdwr_ioctl_data struct that can + be called with ``ioctl(fd, I2C_RDWR, data)``. + + :param i2c_msg_instances: Up to 42 i2c_msg instances + :rtype: i2c_rdwr_ioctl_data + """ + n_msg = len(i2c_msg_instances) + msg_array = (i2c_msg * n_msg)(*i2c_msg_instances) + return i2c_rdwr_ioctl_data( + msgs=msg_array, + nmsgs=n_msg + ) + + +############################################################# + + +class SMBus(object): + + def __init__(self, bus=None, force=False): + """ + Initialize and (optionally) open an i2c bus connection. + + :param bus: i2c bus number (e.g. 0 or 1) + or an absolute file path (e.g. `/dev/i2c-42`). + If not given, a subsequent call to ``open()`` is required. + :type bus: int or str + :param force: force using the slave address even when driver is + already using it. + :type force: boolean + """ + self.fd = None + self.funcs = I2cFunc(0) + if bus is not None: + self.open(bus) + self.address = None + self.force = force + self._force_last = None + + def __enter__(self): + """Enter handler.""" + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + """Exit handler.""" + self.close() + + def open(self, bus): + """ + Open a given i2c bus. + + :param bus: i2c bus number (e.g. 0 or 1) + or an absolute file path (e.g. '/dev/i2c-42'). + :type bus: int or str + :raise TypeError: if type(bus) is not in (int, str) + """ + if isinstance(bus, int): + filepath = "/dev/i2c-{}".format(bus) + elif isinstance(bus, str): + filepath = bus + else: + raise TypeError("Unexpected type(bus)={}".format(type(bus))) + + self.fd = os.open(filepath, os.O_RDWR) + self.funcs = self._get_funcs() + + def close(self): + """ + Close the i2c connection. + """ + if self.fd: + os.close(self.fd) + self.fd = None + + def _set_address(self, address, force=None): + """ + Set i2c slave address to use for subsequent calls. + + :param address: + :type address: int + :param force: + :type force: Boolean + """ + force = force if force is not None else self.force + if self.address != address or self._force_last != force: + if force is True: + ioctl(self.fd, I2C_SLAVE_FORCE, address) + else: + ioctl(self.fd, I2C_SLAVE, address) + self.address = address + self._force_last = force + + def _get_funcs(self): + """ + Returns a 32-bit value stating supported I2C functions. + + :rtype: int + """ + f = c_uint32() + ioctl(self.fd, I2C_FUNCS, f) + return f.value + + def write_quick(self, i2c_addr, force=None): + """ + Perform quick transaction. Throws IOError if unsuccessful. + :param i2c_addr: i2c address + :type i2c_addr: int + :param force: + :type force: Boolean + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=0, size=I2C_SMBUS_QUICK) + ioctl(self.fd, I2C_SMBUS, msg) + + def read_byte(self, i2c_addr, force=None): + """ + Read a single byte from a device. + + :rtype: int + :param i2c_addr: i2c address + :type i2c_addr: int + :param force: + :type force: Boolean + :return: Read byte value + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=0, size=I2C_SMBUS_BYTE + ) + ioctl(self.fd, I2C_SMBUS, msg) + return msg.data.contents.byte + + def write_byte(self, i2c_addr, value, force=None): + """ + Write a single byte to a device. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param value: value to write + :type value: int + :param force: + :type force: Boolean + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=value, size=I2C_SMBUS_BYTE + ) + ioctl(self.fd, I2C_SMBUS, msg) + + def read_byte_data(self, i2c_addr, register, force=None): + """ + Read a single byte from a designated register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to read + :type register: int + :param force: + :type force: Boolean + :return: Read byte value + :rtype: int + """ + val_t = -1 + returnmsg = "" + try: + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=register, size=I2C_SMBUS_BYTE_DATA + ) + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + self.close() + returnmsg = str(e) + if val_t < 0: + return False, returnmsg + else: + return True, msg.data.contents.byte + + def write_byte_data(self, i2c_addr, register, value, force=None): + """ + Write a byte to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to write to + :type register: int + :param value: Byte value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: None + """ + val_t = -1 + returnmsg = "" + try: + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_BYTE_DATA + ) + msg.data.contents.byte = value + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, "" + + def write_byte_data_pec(self, i2c_addr, register, value, force=None): + """ + Write a byte to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to write to + :type register: int + :param value: Byte value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: None + """ + val_t = -1 + returnmsg = "" + try: + val_t = ioctl(self.fd, I2C_PEC, 1) + if val_t < 0: + raise Exception("set pec mod error") + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_BYTE_DATA + ) + msg.data.contents.byte = value + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, "" + + def read_word_data(self, i2c_addr, register, force=None): + """ + Read a single word (2 bytes) from a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to read + :type register: int + :param force: + :type force: Boolean + :return: 2-byte word + :rtype: int + """ + val_t = -1 + returnmsg = "" + try: + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=register, size=I2C_SMBUS_WORD_DATA + ) + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, msg.data.contents.word + + def write_word_data_pec(self, i2c_addr, register, value, force=None): + """ + Write a byte to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to write to + :type register: int + :param value: Word value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: None + """ + val_t = -1 + returnmsg = "" + try: + val_t = ioctl(self.fd, I2C_PEC, 1) + if val_t < 0: + raise Exception("set pec mod error") + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_WORD_DATA + ) + msg.data.contents.word = value + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, "" + + def write_word_data(self, i2c_addr, register, value, force=None): + """ + Write a byte to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to write to + :type register: int + :param value: Word value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: None + """ + val_t = -1 + returnmsg = "" + try: + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_WORD_DATA + ) + msg.data.contents.word = value + val_t = ioctl(self.fd, I2C_SMBUS, msg) + except Exception as e: + returnmsg = str(e) + self.close() + if val_t < 0: + return False, returnmsg or "" + else: + return True, "" + + def process_call(self, i2c_addr, register, value, force=None): + """ + Executes a SMBus Process Call, sending a 16-bit value and receiving a 16-bit response + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to read/write to + :type register: int + :param value: Word value to transmit + :type value: int + :param force: + :type force: Boolean + :rtype: int + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_PROC_CALL + ) + msg.data.contents.word = value + ioctl(self.fd, I2C_SMBUS, msg) + return msg.data.contents.word + + def read_block_data(self, i2c_addr, register, force=None): + """ + Read a block of up to 32-bytes from a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Start register + :type register: int + :param force: + :type force: Boolean + :return: List of bytes + :rtype: list + """ + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=register, size=I2C_SMBUS_BLOCK_DATA + ) + ioctl(self.fd, I2C_SMBUS, msg) + length = msg.data.contents.block[0] + return msg.data.contents.block[1:length + 1] + + def write_block_data(self, i2c_addr, register, data, force=None): + """ + Write a block of byte data to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Start register + :type register: int + :param data: List of bytes + :type data: list + :param force: + :type force: Boolean + :rtype: None + """ + length = len(data) + if length > I2C_SMBUS_BLOCK_MAX: + raise ValueError("Data length cannot exceed %d bytes" % I2C_SMBUS_BLOCK_MAX) + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_BLOCK_DATA + ) + msg.data.contents.block[0] = length + msg.data.contents.block[1:length + 1] = data + ioctl(self.fd, I2C_SMBUS, msg) + + def block_process_call(self, i2c_addr, register, data, force=None): + """ + Executes a SMBus Block Process Call, sending a variable-size data + block and receiving another variable-size response + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Register to read/write to + :type register: int + :param data: List of bytes + :type data: list + :param force: + :type force: Boolean + :return: List of bytes + :rtype: list + """ + length = len(data) + if length > I2C_SMBUS_BLOCK_MAX: + raise ValueError("Data length cannot exceed %d bytes" % I2C_SMBUS_BLOCK_MAX) + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_BLOCK_PROC_CALL + ) + msg.data.contents.block[0] = length + msg.data.contents.block[1:length + 1] = data + ioctl(self.fd, I2C_SMBUS, msg) + length = msg.data.contents.block[0] + return msg.data.contents.block[1:length + 1] + + def read_i2c_block_data(self, i2c_addr, register, length, force=None): + """ + Read a block of byte data from a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Start register + :type register: int + :param length: Desired block length + :type length: int + :param force: + :type force: Boolean + :return: List of bytes + :rtype: list + """ + if length > I2C_SMBUS_BLOCK_MAX: + raise ValueError("Desired block length over %d bytes" % I2C_SMBUS_BLOCK_MAX) + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_READ, command=register, size=I2C_SMBUS_I2C_BLOCK_DATA + ) + msg.data.contents.byte = length + ioctl(self.fd, I2C_SMBUS, msg) + return msg.data.contents.block[1:length + 1] + + def write_i2c_block_data(self, i2c_addr, register, data, force=None): + """ + Write a block of byte data to a given register. + + :param i2c_addr: i2c address + :type i2c_addr: int + :param register: Start register + :type register: int + :param data: List of bytes + :type data: list + :param force: + :type force: Boolean + :rtype: None + """ + length = len(data) + if length > I2C_SMBUS_BLOCK_MAX: + raise ValueError("Data length cannot exceed %d bytes" % I2C_SMBUS_BLOCK_MAX) + self._set_address(i2c_addr, force=force) + msg = i2c_smbus_ioctl_data.create( + read_write=I2C_SMBUS_WRITE, command=register, size=I2C_SMBUS_I2C_BLOCK_DATA + ) + msg.data.contents.block[0] = length + msg.data.contents.block[1:length + 1] = data + ioctl(self.fd, I2C_SMBUS, msg) + + def i2c_rdwr(self, *i2c_msgs): + """ + Combine a series of i2c read and write operations in a single + transaction (with repeated start bits but no stop bits in between). + + This method takes i2c_msg instances as input, which must be created + first with :py:meth:`i2c_msg.read` or :py:meth:`i2c_msg.write`. + + :param i2c_msgs: One or more i2c_msg class instances. + :type i2c_msgs: i2c_msg + :rtype: None + """ + ioctl_data = i2c_rdwr_ioctl_data.create(*i2c_msgs) + ioctl(self.fd, I2C_RDWR, ioctl_data) + + +class SMBusWrapper: + """ + Wrapper class around the SMBus. + Deprecated as of version 0.3.0. Please replace with :py:class:`SMBus`. + + Enables the user to wrap access to the :py:class:`SMBus` class in a + "with" statement. If auto_cleanup is True (default), the + :py:class:`SMBus` handle will be automatically closed + upon exit of the ``with`` block. + """ + + def __init__(self, bus_number=0, auto_cleanup=True, force=False): + """ + :param auto_cleanup: Close bus when leaving scope. + :type auto_cleanup: Boolean + :param force: Force using the slave address even when driver is already using it. + :type force: Boolean + """ + self.bus_number = bus_number + self.auto_cleanup = auto_cleanup + self.force = force + + def __enter__(self): + self.bus = SMBus(bus=self.bus_number, force=self.force) + return self.bus + + def __exit__(self, exc_type, exc_val, exc_tb): + if self.auto_cleanup: + self.bus.close() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modprobe_conf/kernel_drivers_blacklist.conf b/platform/broadcom/sonic-platform-modules-tencent/common/modprobe_conf/kernel_drivers_blacklist.conf new file mode 100755 index 000000000000..6abab99a644e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modprobe_conf/kernel_drivers_blacklist.conf @@ -0,0 +1,2 @@ +blacklist rg_fpga_pcie +blacklist rg_spi_gpio diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/modules/Makefile new file mode 100755 index 000000000000..420a47054215 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/Makefile @@ -0,0 +1,50 @@ +PWD = $(shell pwd) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +KVERSION ?= $(shell uname -r) +KERNEL_SRC ?= /lib/modules/$(KVERSION) + +module_out_put_dir := $(PWD)/build +export module_out_put_dir + +RG_PLAT_SYSFS_DIR = $(PWD)/rg_plat_sysfs + +export RG_PLAT_SYSFS_DIR + +ruijie_common-objs := ruijie_common_module.o dfd_tlveeprom.o +obj-m += rg_pmbus_core.o +obj-m += rg_csu550.o +obj-m += ruijie_common.o +obj-m += rg_ina3221.o +obj-m += rg_mac_bsc.o +obj-m += rg_tps53622.o +obj-m += rg_fpga_pcie.o +obj-m += rg_pcie_dev.o +obj-m += rg_fpga_i2c_bus_drv.o +obj-m += rg_fpga_pca954x_drv.o +obj-m += rg_lpc_drv.o +obj-m += rg_i2c_dev.o +obj-m += rg_io_dev.o +obj-m += rg_eeprom_93xx46.o +obj-m += rg_ucd9000.o +obj-m += rg_spi_93xx46.o +obj-m += rg_gpio_d1500.o +obj-m += rg_gpio_device.o +obj-m += rg_wdt.o +obj-m += rg_optoe.o +obj-m += rg_spi_gpio.o +obj-m += rg_spi_gpio_device.o +obj-m += rg_xdpe132g5c.o +obj-m += rg_i2c_gpio_device.o + +all : + $(MAKE) -C $(RG_PLAT_SYSFS_DIR) + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(module_out_put_dir) ]; then mkdir -p $(module_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(module_out_put_dir) + +clean : + rm -rf $(module_out_put_dir) + rm -f ${PWD}/*.o ${PWD}/*.ko ${PWD}/*.mod.c ${PWD}/.*.cmd ${PWD}/.*.o.d ${PWD}/*.mod + rm -f ${PWD}/Module.markers ${PWD}/Module.symvers ${PWD}/modules.order + rm -rf ${PWD}/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.c new file mode 100644 index 000000000000..cc209981d18a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.c @@ -0,0 +1,516 @@ +/* + * Copyright (C) 2003-2014 FreeIPMI Core Team + * + * 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 3 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, see . + * + */ +/*****************************************************************************\ + * Copyright (C) 2007-2014 Lawrence Livermore National Security, LLC. + * Copyright (C) 2007 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Albert Chu + * UCRL-CODE-232183 + * + * This file is part of Ipmi-fru, a tool used for retrieving + * motherboard field replaceable unit (FRU) information. For details, + * see http://www.llnl.gov/linux/. + * + * Ipmi-fru 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 3 of the License, or (at your + * option) any later version. + * + * Ipmi-fru 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 Ipmi-fru. If not, see . +\*****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ruijie.h" +#include "dfd_tlveeprom.h" + +/* using in is_valid_tlvinfo_header */ +static u_int32_t eeprom_size; + +/* + * 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 , "ONIE 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"}, +}; + +#if 0 +#define OPENBMC_VPD_KEY_INVAIL_VAL 0 + +static const tlv_code_map_t tlv_code_map[] = { + { TLV_CODE_PRODUCT_NAME , OPENBMC_VPD_KEY_PRODUCT_NAME}, + { TLV_CODE_PART_NUMBER , OPENBMC_VPD_KEY_PRODUCT_PART_MODEL_NUM}, + { TLV_CODE_SERIAL_NUMBER , OPENBMC_VPD_KEY_PRODUCT_SERIAL_NUM}, + { TLV_CODE_MAC_BASE , OPENBMC_VPD_KEY_INVAIL_VAL}, + { TLV_CODE_MANUF_DATE , OPENBMC_VPD_KEY_BOARD_MFG_DATE}, + { TLV_CODE_DEVICE_VERSION , OPENBMC_VPD_KEY_PRODUCT_VER}, + { TLV_CODE_LABEL_REVISION , OPENBMC_VPD_KEY_PRODUCT_CUSTOM7}, + { TLV_CODE_PLATFORM_NAME , OPENBMC_VPD_KEY_PRODUCT_CUSTOM1}, + { TLV_CODE_ONIE_VERSION , OPENBMC_VPD_KEY_PRODUCT_CUSTOM2}, + { TLV_CODE_MAC_SIZE , OPENBMC_VPD_KEY_INVAIL_VAL}, + { TLV_CODE_MANUF_NAME , OPENBMC_VPD_KEY_PRODUCT_MFR}, + { TLV_CODE_MANUF_COUNTRY , OPENBMC_VPD_KEY_PRODUCT_CUSTOM3}, + { TLV_CODE_VENDOR_NAME , OPENBMC_VPD_KEY_PRODUCT_CUSTOM4}, + { TLV_CODE_DIAG_VERSION , OPENBMC_VPD_KEY_PRODUCT_CUSTOM8}, + { TLV_CODE_SERVICE_TAG , OPENBMC_VPD_KEY_PRODUCT_CUSTOM5}, + { TLV_CODE_VENDOR_EXT , OPENBMC_VPD_KEY_PRODUCT_CUSTOM6}, + { TLV_CODE_CRC_32 , OPENBMC_VPD_KEY_INVAIL_VAL}, +}; +#endif + +#define TLV_CODE_NUM (sizeof(tlv_code_list) / sizeof(tlv_code_list[0])) + +#if 0 +#define TLV_CODE_MAP_NUM (sizeof(tlv_code_map) / sizeof(tlv_code_map[0])) +#endif + +const unsigned long crc_table[] = { + 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 long crc, const unsigned char *buf, unsigned len) +{ + unsigned i; + if (len < 1) + return 0xffffffff; + + for (i = 0; i != len; ++i) + { + crc = crc_table[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); + } + + crc = crc ^ 0xffffffff; + + return crc; +} + +/* + * 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)); +} + +/* + * 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 = eeprom_size; + 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. + */ +static void decode_tlv_value(tlvinfo_tlv_t *tlv, tlv_decode_value_t *decode_value) +{ + int i; + char *value; + u_int32_t length; + + value = (char *)decode_value->value; + + 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: + case TLV_CODE_VENDOR_EXT: + memcpy(value, tlv->value, tlv->length); + value[tlv->length] = 0; + length = tlv->length; + break; + case TLV_CODE_MAC_BASE: + length = sprintf(value, "%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: + length = sprintf(value, "%u", tlv->value[0]); + break; + case TLV_CODE_MAC_SIZE: + length = sprintf(value, "%u", (tlv->value[0] << 8) | tlv->value[1]); + break; + #if 0 + case TLV_CODE_VENDOR_EXT: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s 0x%02X", value, tlv->value[i]); + } + break; + #endif + case TLV_CODE_CRC_32: + length = sprintf(value, "0x%02X%02X%02X%02X", tlv->value[0], + tlv->value[1], tlv->value[2], tlv->value[3]); + break; + default: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s 0x%02X", value, tlv->value[i]); + } + break; + } + + decode_value->length = length; +} + +/* + * 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_tlv_t *eeprom_crc; + unsigned int calc_crc; + unsigned int stored_crc; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + // 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(0xffffffffL, (const unsigned char *)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]); + + return (calc_crc == stored_crc); +} + +/* + * 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. + */ +static bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + // 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. + */ +static bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, tlv_decode_value_t *decode_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, decode_value); + return true; + } + + return false; +} + +/* + * parse_tlv_eeprom + * + * parse the EEPROM into memory, if it hasn't already been read. + */ +int parse_tlv_eeprom(u_int8_t *eeprom, u_int32_t size) +{ + unsigned int i; + bool ret; + tlvinfo_header_t *eeprom_hdr; + //tlv_info_vec_t tlv_info; + tlv_decode_value_t decode_value; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_ERROR("Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_ERROR("Failed to check tlv crc.\n"); + return -1; + } + + for (i = 0; i < TLV_CODE_NUM; i++) { + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = tlvinfo_decode_tlv(eeprom, tlv_code_list[i].m_code, &decode_value); + if (!ret) { + DBG_ERROR("No found type: %s\n", tlv_code_list[i].m_name); + continue; + } + + DBG_DEBUG("i: %d,Found type: %s tlv[%d]:%s\n", i, tlv_code_list[i].m_name, tlv_code_list[i].m_code, + decode_value.value); + for (j = 0; j < decode_value.length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG("\n"); + } + DBG_DEBUG("%02x ", decode_value.value[j]); + } + DBG_DEBUG("\n\n"); + } + return 0; +} +static int dfd_parse_tlv_eeprom(u_int8_t *eeprom, u_int32_t size, u_int8_t main_type, tlv_decode_value_t *decode_value) +{ + bool ret; + tlvinfo_header_t *eeprom_hdr; + //tlv_info_vec_t tlv_info; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_ERROR("Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_ERROR("Failed to check tlv crc.\n"); + return -1; + } + + ret = tlvinfo_decode_tlv(eeprom, main_type, decode_value); + if (!ret) { + DBG_ERROR("No found type: %d\n", main_type); + return -1; + } + + DBG_DEBUG("Found type: %d, value: %s\n", main_type,decode_value->value); + for (j = 0; j < decode_value->length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG("\n"); + } + DBG_DEBUG("%02x ", decode_value->value[j]); + } + DBG_DEBUG("\n\n"); + + return 0; +} + +static int tlvinfo_find_rg_ext_tlv(tlv_decode_value_t *ext_tlv_value, u_int8_t ext_type, + u_int8_t *buf, u_int8_t *buf_len) +{ + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end, eeprom_index; + + // Search through the TLVs, looking for the first one which matches the + // supplied type code. + DBG_DEBUG("ext_tlv_value->length: %d.\n", ext_tlv_value->length); + for (eeprom_index = 0; eeprom_index < ext_tlv_value->length; eeprom_index++) { + if ((eeprom_index % 16) == 0) { + DBG_DEBUG("\n"); + } + DBG_DEBUG("%02x ", ext_tlv_value->value[eeprom_index]); + } + + DBG_DEBUG("\n"); + + eeprom_index = 0; + eeprom_end = ext_tlv_value->length; + while (eeprom_index < eeprom_end) { + eeprom_tlv = (tlvinfo_tlv_t *) &(ext_tlv_value->value[eeprom_index]); + if (!is_valid_tlv(eeprom_tlv)) { + DBG_ERROR("tlv is not valid, eeprom_tlv->type 0x%x.\n", eeprom_tlv->type); + return -1; + } + + DBG_DEBUG("eeprom_tlv->length %d.\n", eeprom_tlv->length); + if (eeprom_tlv->type == ext_type) { + if (*buf_len >= eeprom_tlv->length) { + memcpy(buf, eeprom_tlv->value, eeprom_tlv->length); + DBG_DEBUG("eeprom_tlv->length %d.\n", eeprom_tlv->length); + *buf_len = eeprom_tlv->length; + return 0; + } + DBG_ERROR("buf_len %d small than info_len %d.\n", *buf_len, eeprom_tlv->length); + return -1; + } + + eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; + } + + DBG_ERROR("ext_type %d: tlv is not found.\n", ext_type); + return -1; +} + +int dfd_tlvinfo_get_e2prom_info(u_int8_t *eeprom, u_int32_t size, dfd_tlv_type_t *tlv_type, u_int8_t* buf, u_int8_t *buf_len) +{ + tlv_decode_value_t decode_value; + int ret; + + if (eeprom == NULL || tlv_type == NULL || buf == NULL) { + DBG_ERROR("Input para invalid.\n"); + return -1; + } + + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = dfd_parse_tlv_eeprom(eeprom, size, tlv_type->main_type, &decode_value); + if (ret) { + DBG_ERROR("dfd_parse_tlv_eeprom failed ret %d.\n", ret); + return ret; + } + + if (tlv_type->main_type != TLV_CODE_VENDOR_EXT) { + if (*buf_len >= decode_value.length) { + memcpy(buf, decode_value.value, decode_value.length); + *buf_len = decode_value.length; + return 0; + } + DBG_ERROR("buf_len %d small than info_len %d.\n", *buf_len, decode_value.length); + return -1; + } + DBG_DEBUG("info_len %d.\n", decode_value.length); + + return tlvinfo_find_rg_ext_tlv(&decode_value, tlv_type->ext_type, buf, buf_len); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.h new file mode 100644 index 000000000000..6eaac5848223 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/dfd_tlveeprom.h @@ -0,0 +1,121 @@ +#ifndef DFD_OPENBMC_TLVEEPROM_H +#define DFD_OPENBMC_TLVEEPROM_H + +#ifndef u_int8_t +#define u_int8_t unsigned char +#endif + +#ifndef u_int16_t +#define u_int16_t unsigned short +#endif + +#ifndef u_int32_t +#define u_int32_t unsigned int +#endif + +#ifndef be16_to_cpu +#define be16_to_cpu(x) ntohs(x) +#endif + +#ifndef cpu_to_be16 +#define cpu_to_be16(x) htons(x) +#endif + +/** + * 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_NAME_LEN 64 +/* + * Struct for displaying the TLV codes and names. + */ +struct tlv_code_desc { + u_int8_t m_code; + char m_name[TLV_CODE_NAME_LEN]; +}; + +typedef struct dfd_tlv_type_s { + u_int8_t main_type; + u_int8_t ext_type; +} dfd_tlv_type_t; + +// Header Field Constants +#define TLV_INFO_ID_STRING "TlvInfo" +#define TLV_INFO_VERSION 0x01 +/*#define TLV_TOTAL_LEN_MAX (XXXXXXXX - sizeof(tlvinfo_header_t))*/ + +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; + +/* + * 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; + +#define TLV_VALUE_MAX_LEN 255 +/* + * 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) + +typedef struct tlv_decode_value_s { + u_int8_t value[TLV_DECODE_VALUE_MAX_LEN]; + u_int32_t length; +} tlv_decode_value_t; + +typedef enum dfd_tlvinfo_ext_tlv_type_e { + DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE = 1, +} dfd_tlvinfo_ext_tlv_type_t; + +#if 0 +#define TLV_TIME_LEN 64 + +int ipmi_tlv_validate_fru_area(const uint8_t fruid, const char *fru_file_name, + sd_bus *bus_type, const bool bmc_fru); + +extern const char *get_vpd_key_names(int key_id); +extern std::string getService(sdbusplus::bus::bus& bus, + const std::string& intf, + const std::string& path); +extern std::string getFRUValue(const std::string& section, + const std::string& key, + const std::string& delimiter, + IPMIFruInfo& fruData); +#endif + +int dfd_tlvinfo_get_e2prom_info(u_int8_t *eeprom, u_int32_t size, dfd_tlv_type_t *tlv_type, u_int8_t* buf, u_int8_t *buf_len); + +#endif /* endif DFD_OPENBMC_TLVEEPROM_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/fpga_i2c.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/fpga_i2c.h new file mode 100644 index 000000000000..8271a6706025 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/fpga_i2c.h @@ -0,0 +1,129 @@ +#ifndef _FPGA_I2C_H +#define _FPGA_I2C_H + +#include +#include +#include +#if 0 + +#define FPGA_I2C_EXT_9548_ADDR (0x00) +#define FPGA_I2C_EXT_9548_CHAN (0x04) +#define FPGA_I2C_DEV_SLAVE_ADDR (0x08) +#define FPGA_I2C_DEV_REG_ADDR (0x0C) +#define FPGA_I2C_DEV_RDWR_LEN (0x10) +#define FPGA_I2C_CTRL_REG (0x14) +#define FPGA_I2C_STATUS_REG (0x18) +#define FPGA_I2C_SCALE_REG (0x1C) +#define FPGA_I2C_FILTER_REG (0x20) +#define FPGA_I2C_STRETCH_REG (0x24) +#define FPGA_I2C_EXT_9548_EXITS_FLAG (0x28) +#define FPGA_I2C_INTERNAL_9548_CHAN (0x2C) +#define FPGA_I2C_RDWR_DATA_BUF (0x80) +#endif +#define FPGA_I2C_RDWR_MAX_LEN_DEFAULT (128) +#define I2C_REG_MAX_WIDTH (16) + +#define DEV_NAME_MAX_LEN (64) + +#define FPGA_I2C_MAX_TIMES (10) +#define FPGA_I2C_XFER_TIME_OUT (100000) +#define FPGA_I2C_SLEEP_TIME (40) + +typedef struct fpga_i2c_reg_s { + uint32_t i2c_scale; + uint32_t i2c_filter; + uint32_t i2c_stretch; + uint32_t i2c_ext_9548_exits_flag; + uint32_t i2c_ext_9548_addr; + uint32_t i2c_ext_9548_chan; + uint32_t i2c_in_9548_chan; + uint32_t i2c_slave; + uint32_t i2c_reg; + uint32_t i2c_reg_len; + uint32_t i2c_data_len; + uint32_t i2c_ctrl; + uint32_t i2c_status; + uint32_t i2c_err_vec; + uint32_t i2c_data_buf; + uint32_t i2c_data_buf_len; +} fpga_i2c_reg_t; + +typedef struct fpga_i2c_reset_cfg_s { + uint32_t i2c_adap_reset_flag; + uint32_t reset_addr; + uint32_t reset_on; + uint32_t reset_off; + uint32_t reset_delay_b; + uint32_t reset_delay; + uint32_t reset_delay_a; +} fpga_i2c_reset_cfg_t; + +typedef struct fpga_i2c_reg_addr_s { + uint8_t reg_addr_len; + uint8_t read_reg_addr[I2C_REG_MAX_WIDTH]; +} fpga_i2c_reg_addr_t; + +typedef struct fpga_i2c_dev_s { + fpga_i2c_reg_t reg; + fpga_i2c_reset_cfg_t reset_cfg; + fpga_i2c_reg_addr_t i2c_addr_desc; + const char *dev_name; + uint32_t i2c_scale_value; + uint32_t i2c_filter_value; + uint32_t i2c_stretch_value; + uint32_t i2c_timeout; + uint32_t i2c_func_mode; + wait_queue_head_t queue; + struct i2c_adapter adap; + int adap_nr; + struct device *dev; + bool i2c_params_check; +} fpga_i2c_dev_t; + +typedef struct fpga_i2c_bus_device_s { + int i2c_timeout; + int i2c_scale; + int i2c_filter; + int i2c_stretch; + int i2c_ext_9548_exits_flag; + int i2c_ext_9548_addr; + int i2c_ext_9548_chan; + int i2c_in_9548_chan; + int i2c_slave; + int i2c_reg; + int i2c_reg_len; + int i2c_data_len; + int i2c_ctrl; + int i2c_status; + int i2c_err_vec; + int i2c_data_buf; + int i2c_data_buf_len; + char dev_name[DEV_NAME_MAX_LEN]; + int adap_nr; + int i2c_scale_value; + int i2c_filter_value; + int i2c_stretch_value; + int i2c_func_mode; + int i2c_adap_reset_flag; + int i2c_reset_addr; + int i2c_reset_on; + int i2c_reset_off; + int i2c_rst_delay_b; /* delay time before reset(us) */ + int i2c_rst_delay; /* reset time(us) */ + int i2c_rst_delay_a; /* delay time after reset(us) */ + int device_flag; + bool i2c_params_check; + int i2c_data_buf_len_reg; + int i2c_offset_reg; +} fpga_i2c_bus_device_t; + +typedef struct fpga_pca954x_device_s { + struct i2c_client *client; + uint32_t i2c_bus; + uint32_t i2c_addr; + uint32_t fpga_9548_flag; + uint32_t fpga_9548_reset_flag; + uint32_t pca9548_base_nr; +} fpga_pca954x_device_t; + +#endif /* _FPGA_I2C_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_csu550.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_csu550.c new file mode 100644 index 000000000000..4b6794237b2e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_csu550.c @@ -0,0 +1,203 @@ +/* + * csu550.c - PMBUS for csu550 + * + * Copyright (c) 2018 sonic_rd + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,152) +#include +#else +#include +#endif +#include +#include +#include "rg_pmbus.h" + +/* + * 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 (rg_pmbus_check_word_register(client, 0, PMBUS_READ_VIN)) + info->func[0] |= PMBUS_HAVE_VIN; + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_IIN)) + info->func[0] |= PMBUS_HAVE_IIN; + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_PIN)) + info->func[0] |= PMBUS_HAVE_PIN; + if (info->func[0] + && rg_pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT)) + info->func[0] |= PMBUS_HAVE_STATUS_INPUT; + if (rg_pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) && + rg_pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) { + info->func[0] |= PMBUS_HAVE_FAN12; + if (rg_pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12)) + info->func[0] |= PMBUS_HAVE_STATUS_FAN12; + } + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) + info->func[0] |= PMBUS_HAVE_TEMP; + if (rg_pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2)) + info->func[0] |= PMBUS_HAVE_TEMP2; + if (rg_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) + && rg_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 (rg_pmbus_check_word_register(client, page, PMBUS_READ_VOUT)) { + info->func[page] |= PMBUS_HAVE_VOUT; + if (rg_pmbus_check_byte_register(client, page, + PMBUS_STATUS_VOUT)) + info->func[page] |= PMBUS_HAVE_STATUS_VOUT; + } + if (rg_pmbus_check_word_register(client, page, PMBUS_READ_IOUT)) { + info->func[page] |= PMBUS_HAVE_IOUT; + if (rg_pmbus_check_byte_register(client, 0, + PMBUS_STATUS_IOUT)) + info->func[page] |= PMBUS_HAVE_STATUS_IOUT; + } + if (rg_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 (rg_pmbus_check_byte_register(client, 0, PMBUS_PAGE)) { + int page; + + for (page = 1; page < PMBUS_PAGES; page++) { + if (rg_pmbus_set_page(client, page) < 0) + break; + } + (void)rg_pmbus_set_page(client, 0); + info->pages = page; + } else { + info->pages = 1; + } + } + + if (rg_pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) { + int vout_mode; + + vout_mode = rg_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; + struct pmbus_platform_data *pdata = NULL; + struct device *dev = &client->dev; + + info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), + GFP_KERNEL); + if (!info) + return -ENOMEM; + + if (!strncmp(id->name, "dps460", sizeof("dps460")) || + !strncmp(id->name, "rg_fsp1200", sizeof("rg_fsp1200")) || !strncmp(id->name, "rg_dps550", sizeof("rg_dps550"))) { + pdata = kzalloc(sizeof(struct pmbus_platform_data), GFP_KERNEL); + if (!pdata) { + kfree(info); + return -ENOMEM; + } + pdata->flags = PMBUS_SKIP_STATUS_CHECK; + } + + info->pages = id->driver_data; + info->identify = pmbus_identify; + dev->platform_data = pdata; + + return rg_pmbus_do_probe(client, id, info); +} + +static const struct i2c_device_id pmbus_id[] = { + {"rg_csu550", 0}, + {"rg_csu800", 1}, + {"rg_fsp1200", 1}, + {"rg_dps550", 1}, + {} +}; +MODULE_DEVICE_TABLE(i2c, pmbus_id); + +/* This is the driver that will be inserted */ +static struct i2c_driver pmbus_driver = { + .driver = { + .name = "rg_pmbus", + }, + .probe = pmbus_probe, + .remove = rg_pmbus_do_remove, + .id_table = pmbus_id, +}; + +module_i2c_driver(pmbus_driver); + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("ruijie psupmbus driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_eeprom_93xx46.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_eeprom_93xx46.c new file mode 100644 index 000000000000..41d3aab35a33 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_eeprom_93xx46.c @@ -0,0 +1,555 @@ +/* + * Driver for 93xx46 EEPROMs + * + * (C) 2011 DENX Software Engineering, Anatolij Gustschin + * + * 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 +#include +#include +#include + +#define OP_START 0x4 +#define OP_WRITE (OP_START | 0x1) +#define OP_READ (OP_START | 0x2) +#define ADDR_EWDS 0x00 +#define ADDR_ERAL 0x20 +#define ADDR_EWEN 0x30 + +static int g_rg_eeprom_93xx46_debug = 0; + +module_param(g_rg_eeprom_93xx46_debug, int, S_IRUGO | S_IWUSR); + +#define SPI_93xx46_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_eeprom_93xx46_debug) { \ + printk(KERN_INFO "[EEPROM-93xx46][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct eeprom_93xx46_devtype_data { + unsigned int quirks; +}; + +static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = { + .quirks = EEPROM_93XX46_QUIRK_SINGLE_WORD_READ | + EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH, +}; + +struct eeprom_93xx46_dev { + struct spi_device *spi; + struct eeprom_93xx46_platform_data *pdata; + struct mutex lock; + struct nvmem_config nvmem_config; + struct nvmem_device *nvmem; + int addrlen; + int size; +}; + +static inline bool has_quirk_single_word_read(struct eeprom_93xx46_dev *edev) +{ + return edev->pdata->quirks & EEPROM_93XX46_QUIRK_SINGLE_WORD_READ; +} + +static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev) +{ + return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH; +} + +static int eeprom_93xx46_read(void *priv, unsigned int off, + void *val, size_t count) +{ + struct eeprom_93xx46_dev *edev = priv; + char *buf = val; + int err = 0; + + if (unlikely(off >= edev->size)) + return 0; + if ((off + count) > edev->size) + count = edev->size - off; + if (unlikely(!count)) + return count; + + mutex_lock(&edev->lock); + + if (edev->pdata->prepare) + edev->pdata->prepare(edev); + + while (count) { + struct spi_message m; + struct spi_transfer t[2] = { { 0 } }; + u16 cmd_addr = OP_READ << edev->addrlen; + size_t nbytes = count; + int bits; + int data_bit; + + if (edev->addrlen == 7) { + cmd_addr |= off & 0x7f; + bits = 10; + data_bit = 8; + if (has_quirk_single_word_read(edev)) + nbytes = 1; + } else { + cmd_addr |= (off >> 1) & 0x3f; + bits = 9; + data_bit = 16; + if (has_quirk_single_word_read(edev)) + nbytes = 2; + } + + dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n", + cmd_addr, edev->spi->max_speed_hz); + + spi_message_init(&m); + + t[0].tx_buf = (char *)&cmd_addr; + t[0].len = 2; + t[0].bits_per_word = bits; + spi_message_add_tail(&t[0], &m); + + t[1].rx_buf = buf; + t[1].len = nbytes; + t[1].bits_per_word = data_bit; + spi_message_add_tail(&t[1], &m); + + err = spi_sync(edev->spi, &m); + /* have to wait at least Tcsl ns */ + ndelay(250); + + if (err) { + dev_err(&edev->spi->dev, "read %zu bytes at %d: err. %d\n", + nbytes, (int)off, err); + break; + } + + buf += nbytes; + off += nbytes; + count -= nbytes; + } + + if (edev->pdata->finish) + edev->pdata->finish(edev); + + mutex_unlock(&edev->lock); + + return err; +} + +static int eeprom_93xx46_ew(struct eeprom_93xx46_dev *edev, int is_on) +{ + struct spi_message m; + struct spi_transfer t; + int bits, ret; + u16 cmd_addr; + + cmd_addr = OP_START << edev->addrlen; + if (edev->addrlen == 7) { + cmd_addr |= (is_on ? ADDR_EWEN : ADDR_EWDS) << 1; + bits = 10; + } else { + cmd_addr |= (is_on ? ADDR_EWEN : ADDR_EWDS); + bits = 9; + } + + if (has_quirk_instruction_length(edev)) { + cmd_addr <<= 2; + bits += 2; + } + + dev_dbg(&edev->spi->dev, "ew%s cmd 0x%04x, %d bits\n", + is_on ? "en" : "ds", cmd_addr, bits); + + spi_message_init(&m); + memset(&t, 0, sizeof(t)); + + t.tx_buf = &cmd_addr; + t.len = 2; + t.bits_per_word = bits; + spi_message_add_tail(&t, &m); + + mutex_lock(&edev->lock); + + if (edev->pdata->prepare) + edev->pdata->prepare(edev); + + ret = spi_sync(edev->spi, &m); + /* have to wait at least Tcsl ns */ + ndelay(250); + if (ret) + dev_err(&edev->spi->dev, "erase/write %sable error %d\n", + is_on ? "en" : "dis", ret); + + if (edev->pdata->finish) + edev->pdata->finish(edev); + + mutex_unlock(&edev->lock); + return ret; +} + +static ssize_t +eeprom_93xx46_write_word(struct eeprom_93xx46_dev *edev, + char *buf, unsigned off) +{ + struct spi_message m; + struct spi_transfer t[2]; + int bits, data_len, ret; + u16 cmd_addr; + int data_bit; + + cmd_addr = OP_WRITE << edev->addrlen; + + if (edev->addrlen == 7) { + cmd_addr |= off & 0x7f; + bits = 10; + data_len = 1; + data_bit = 8; + } else { + cmd_addr |= (off >> 1) & 0x3f; + bits = 9; + data_len = 2; + data_bit = 16; + } + + dev_dbg(&edev->spi->dev, "write cmd 0x%x\n", cmd_addr); + + spi_message_init(&m); + memset(t, 0, sizeof(t)); + + t[0].tx_buf = (char *)&cmd_addr; + t[0].len = 2; + t[0].bits_per_word = bits; + spi_message_add_tail(&t[0], &m); + + t[1].tx_buf = buf; + t[1].len = data_len; + t[1].bits_per_word = data_bit; + spi_message_add_tail(&t[1], &m); + + ret = spi_sync(edev->spi, &m); + /* have to wait program cycle time Twc ms */ + mdelay(6); + return ret; +} + +static int eeprom_93xx46_write(void *priv, unsigned int off, + void *val, size_t count) +{ + struct eeprom_93xx46_dev *edev = priv; + char *buf = val; + int i, ret, step = 1; + + if (unlikely(off >= edev->size)) + return -EFBIG; + if ((off + count) > edev->size) + count = edev->size - off; + if (unlikely(!count)) + return count; + + /* only write even number of bytes on 16-bit devices */ + if (edev->addrlen == 6) { + step = 2; + count &= ~1; + } + + /* erase/write enable */ + ret = eeprom_93xx46_ew(edev, 1); + if (ret) + return ret; + + mutex_lock(&edev->lock); + + if (edev->pdata->prepare) + edev->pdata->prepare(edev); + + for (i = 0; i < count; i += step) { + ret = eeprom_93xx46_write_word(edev, &buf[i], off + i); + if (ret) { + dev_err(&edev->spi->dev, "write failed at %d: %d\n", + (int)off + i, ret); + break; + } + } + + if (edev->pdata->finish) + edev->pdata->finish(edev); + + mutex_unlock(&edev->lock); + + /* erase/write disable */ + eeprom_93xx46_ew(edev, 0); + return ret; +} + +static int eeprom_93xx46_eral(struct eeprom_93xx46_dev *edev) +{ + struct eeprom_93xx46_platform_data *pd = edev->pdata; + struct spi_message m; + struct spi_transfer t; + int bits, ret; + u16 cmd_addr; + + cmd_addr = OP_START << edev->addrlen; + if (edev->addrlen == 7) { + cmd_addr |= ADDR_ERAL << 1; + bits = 10; + } else { + cmd_addr |= ADDR_ERAL; + bits = 9; + } + + if (has_quirk_instruction_length(edev)) { + cmd_addr <<= 2; + bits += 2; + } + + dev_dbg(&edev->spi->dev, "eral cmd 0x%04x, %d bits\n", cmd_addr, bits); + + spi_message_init(&m); + memset(&t, 0, sizeof(t)); + + t.tx_buf = &cmd_addr; + t.len = 2; + t.bits_per_word = bits; + spi_message_add_tail(&t, &m); + + mutex_lock(&edev->lock); + + if (edev->pdata->prepare) + edev->pdata->prepare(edev); + + ret = spi_sync(edev->spi, &m); + if (ret) + dev_err(&edev->spi->dev, "erase error %d\n", ret); + /* have to wait erase cycle time Tec ms */ + mdelay(6); + + if (pd->finish) + pd->finish(edev); + + mutex_unlock(&edev->lock); + return ret; +} + +static ssize_t eeprom_93xx46_store_erase(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct eeprom_93xx46_dev *edev = dev_get_drvdata(dev); + int erase = 0, ret; + + sscanf(buf, "%d", &erase); + if (erase) { + ret = eeprom_93xx46_ew(edev, 1); + if (ret) + return ret; + ret = eeprom_93xx46_eral(edev); + if (ret) + return ret; + ret = eeprom_93xx46_ew(edev, 0); + if (ret) + return ret; + } + return count; +} +static DEVICE_ATTR(erase, S_IWUSR, NULL, eeprom_93xx46_store_erase); + +static void select_assert(void *context) +{ + struct eeprom_93xx46_dev *edev = context; + + gpiod_set_value_cansleep(edev->pdata->select, 1); +} + +static void select_deassert(void *context) +{ + struct eeprom_93xx46_dev *edev = context; + + gpiod_set_value_cansleep(edev->pdata->select, 0); +} + +static const struct of_device_id eeprom_93xx46_of_table[] = { + { .compatible = "eeprom-93xx46", }, + { .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, }, + {} +}; +MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table); + +static int eeprom_93xx46_probe_dt(struct spi_device *spi) +{ + const struct of_device_id *of_id = + of_match_device(eeprom_93xx46_of_table, &spi->dev); + struct device_node *np = spi->dev.of_node; + struct eeprom_93xx46_platform_data *pd; + u32 tmp; + int gpio; + enum of_gpio_flags of_flags; + int ret; + + pd = devm_kzalloc(&spi->dev, sizeof(*pd), GFP_KERNEL); + if (!pd) + return -ENOMEM; + + ret = of_property_read_u32(np, "data-size", &tmp); + if (ret < 0) { + dev_err(&spi->dev, "data-size property not found\n"); + return ret; + } + + if (tmp == 8) { + pd->flags |= EE_ADDR8; + } else if (tmp == 16) { + pd->flags |= EE_ADDR16; + } else { + dev_err(&spi->dev, "invalid data-size (%d)\n", tmp); + return -EINVAL; + } + + if (of_property_read_bool(np, "read-only")) + pd->flags |= EE_READONLY; + + gpio = of_get_named_gpio_flags(np, "select-gpios", 0, &of_flags); + if (gpio_is_valid(gpio)) { + unsigned long flags = + of_flags == OF_GPIO_ACTIVE_LOW ? GPIOF_ACTIVE_LOW : 0; + + ret = devm_gpio_request_one(&spi->dev, gpio, flags, + "eeprom_93xx46_select"); + if (ret) + return ret; + + pd->select = gpio_to_desc(gpio); + pd->prepare = select_assert; + pd->finish = select_deassert; + + gpiod_direction_output(pd->select, 0); + } + + if (of_id) { + if (of_id->data) { + const struct eeprom_93xx46_devtype_data *data = of_id->data; + + pd->quirks = data->quirks; + } + } + + spi->dev.platform_data = pd; + + return 0; +} + +static int eeprom_93xx46_probe(struct spi_device *spi) +{ + struct eeprom_93xx46_platform_data *pd; + struct eeprom_93xx46_dev *edev; + int err; + + if (spi->dev.of_node) { + err = eeprom_93xx46_probe_dt(spi); + if (err < 0) + return err; + } + + pd = spi->dev.platform_data; + if (!pd) { + dev_err(&spi->dev, "missing platform data\n"); + return -ENODEV; + } + + edev = kzalloc(sizeof(*edev), GFP_KERNEL); + if (!edev) + return -ENOMEM; + + if (pd->flags & EE_ADDR8) + edev->addrlen = 7; + else if (pd->flags & EE_ADDR16) + edev->addrlen = 6; + else { + dev_err(&spi->dev, "unspecified address type\n"); + err = -EINVAL; + goto fail; + } + + mutex_init(&edev->lock); + + edev->spi = spi; + edev->pdata = pd; + + edev->size = 128; + edev->nvmem_config.name = dev_name(&spi->dev); + edev->nvmem_config.dev = &spi->dev; + edev->nvmem_config.read_only = pd->flags & EE_READONLY; + edev->nvmem_config.root_only = true; + edev->nvmem_config.owner = THIS_MODULE; + edev->nvmem_config.compat = true; + edev->nvmem_config.base_dev = &spi->dev; + edev->nvmem_config.reg_read = eeprom_93xx46_read; + edev->nvmem_config.reg_write = eeprom_93xx46_write; + edev->nvmem_config.priv = edev; + edev->nvmem_config.stride = 4; + edev->nvmem_config.word_size = 1; + edev->nvmem_config.size = edev->size; + + edev->nvmem = nvmem_register(&edev->nvmem_config); + if (IS_ERR(edev->nvmem)) { + err = PTR_ERR(edev->nvmem); + goto fail; + } + + if (g_rg_eeprom_93xx46_debug) { + dev_info(&spi->dev, "%d-bit eeprom %s\n", + (pd->flags & EE_ADDR8) ? 8 : 16, + (pd->flags & EE_READONLY) ? "(readonly)" : ""); + } + + if (!(pd->flags & EE_READONLY)) { + if (device_create_file(&spi->dev, &dev_attr_erase)) + dev_err(&spi->dev, "can't create erase interface\n"); + } + + spi_set_drvdata(spi, edev); + return 0; +fail: + kfree(edev); + return err; +} + +static int eeprom_93xx46_remove(struct spi_device *spi) +{ + struct eeprom_93xx46_dev *edev = spi_get_drvdata(spi); + + nvmem_unregister(edev->nvmem); + + if (!(edev->pdata->flags & EE_READONLY)) + device_remove_file(&spi->dev, &dev_attr_erase); + + kfree(edev); + return 0; +} + +static struct spi_driver rg_eeprom_93xx46_driver = { + .driver = { + .name = "rg_93xx46", + .of_match_table = of_match_ptr(eeprom_93xx46_of_table), + }, + .probe = eeprom_93xx46_probe, + .remove = eeprom_93xx46_remove, +}; + +module_spi_driver(rg_eeprom_93xx46_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Driver for 93xx46 EEPROMs"); +MODULE_AUTHOR("Anatolij Gustschin "); +MODULE_ALIAS("spi:93xx46"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_i2c_bus_drv.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_i2c_bus_drv.c new file mode 100644 index 000000000000..18b2b341fe9b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_i2c_bus_drv.c @@ -0,0 +1,1106 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * fpga_i2c_bus_drv.c + * ko to create fpga i2c adapter + * Original Author: sonic_rd@ruijie.com.cn 2020-08-10 + */ +#include +#include +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) +#include +#endif +#include +#include +#include +#include +#include +#include +#include "fpga_i2c.h" + +#include +#include + +#define DRV_NAME "rg-fpga-i2c" +#define DRV_VERSION "1.0" +#define DTS_NO_CFG_FLAG (0) + +extern int i2c_device_func_write(const char *path, uint32_t pos, uint8_t *val, size_t size); +extern int i2c_device_func_read(const char *path, uint32_t pos, uint8_t *val, size_t size); +extern int pcie_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int pcie_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); + +#define FPGA_I2C_STRETCH_TIMEOUT (0x01) +#define FPGA_I2C_DEADLOCK_FAILED (0x02) +#define FPGA_I2C_SLAVE_NO_RESPOND (0x03) +#define FPGA_I2C_STA_FAIL (0x01) +#define FPGA_I2C_STA_BUSY (0x02) +#define FPGA_I2C_CTL_BG (0x01 << 1) +#define FPGA_I2C_CTL_NO_REG (0x01 << 2) +#define FPGA_I2C_CTL_RD (0x01) +#define FPGA_I2C_CTL_WR (0x00) +#define I2C_READ_MSG_NUM (0x02) +#define I2C_WRITE_MSG_NUM (0x01) +#define FPGA_REG_WIDTH (4) + +#define SYMBOL_I2C_DEV_MODE (1) +#define FILE_MODE (2) +#define SYMBOL_PCIE_DEV_MODE (3) +#define SYMBOL_IO_DEV_MODE (4) + +int g_rg_fpga_i2c_debug = 0; +int g_rg_fpga_i2c_error = 0; + +module_param(g_rg_fpga_i2c_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_i2c_error, int, S_IRUGO | S_IWUSR); + +#define FPGA_I2C_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_i2c_debug) { \ + printk(KERN_INFO "[FPFA_I2C_BUS][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_I2C_ERROR(fmt, args...) do { \ + if (g_rg_fpga_i2c_error) { \ + printk(KERN_ERR "[FPFA_I2C_BUS][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static int fpga_file_read(const char *path, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDONLY, 0); + if (IS_ERR(filp)) { + FPGA_I2C_ERROR("read open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_read(filp, val, size, &tmp_pos); + if (ret < 0) { + FPGA_I2C_ERROR("kernel_read failed, path=%s, addr=0x%x, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; +} + +static int fpga_file_write(const char *path, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDWR, 777); + if (IS_ERR(filp)) { + FPGA_I2C_ERROR("write open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_write(filp, val, size, &tmp_pos); + if (ret < 0) { + FPGA_I2C_ERROR("kernel_write failed, path=%s, addr=0x%x, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + vfs_fsync(filp, 1); + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; +} + +static int fpga_device_write(fpga_i2c_dev_t *fpga_i2c, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + + switch (fpga_i2c->i2c_func_mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_write(fpga_i2c->dev_name, pos, val, size); + break; + case FILE_MODE: + ret = fpga_file_write(fpga_i2c->dev_name, pos, val, size); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_write(fpga_i2c->dev_name, pos, val, size); + break; + default: + FPGA_I2C_ERROR("err func_mode, write failed.\n"); + return -EINVAL; + } + return ret; + +} + +static int fpga_device_read(fpga_i2c_dev_t *fpga_i2c, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + + switch (fpga_i2c->i2c_func_mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_read(fpga_i2c->dev_name, pos, val, size); + break; + case FILE_MODE: + ret = fpga_file_read(fpga_i2c->dev_name, pos, val, size); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_read(fpga_i2c->dev_name, pos, val, size); + break; + default: + FPGA_I2C_ERROR("err func_mode, read failed.\n"); + return -EINVAL; + } + + return ret; +} + +static int little_endian_dword_to_buf(uint8_t *buf, int len, uint32_t dword) +{ + uint8_t tmp_buf[FPGA_REG_WIDTH]; + + if (len < 4) { + FPGA_I2C_ERROR("Not enough buf, dword to buf: len[%d], dword[0x%x]\n", len, dword); + return -1; + } + + memset(tmp_buf, 0, sizeof(tmp_buf)); + tmp_buf[0] = dword & 0xff; + tmp_buf[1] = (dword >> 8) & 0xff; + tmp_buf[2] = (dword >> 16) & 0xff; + tmp_buf[3] = (dword >> 24) & 0xff; + + memcpy(buf, tmp_buf, sizeof(tmp_buf)); + + return 0; +} + +static int little_endian_buf_to_dword(uint8_t *buf, int len, uint32_t *dword) +{ + int i; + uint32_t dword_tmp; + + if (len != FPGA_REG_WIDTH) { + FPGA_I2C_ERROR("buf length %d error, can't convert to dowrd.\n", len); + return -1; + } + dword_tmp = 0; + for (i = 0; i < FPGA_REG_WIDTH; i++) { + dword_tmp |= (buf[i] << (i * 8)); + } + *dword = dword_tmp; + return 0; +} + +static int fpga_reg_write(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t val) +{ + int ret; + + ret = fpga_device_write(fpga_i2c, addr, &val, sizeof(uint8_t)); + if (ret < 0) { + FPGA_I2C_ERROR("fpga reg write failed, dev name:%s, offset:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, val); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga reg write success, dev name:%s, offset:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, val); + return 0; +} + +static int fpga_reg_read(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t *val) +{ + int ret; + + ret = fpga_device_read(fpga_i2c, addr, val, sizeof(uint8_t)); + if (ret < 0) { + FPGA_I2C_ERROR("fpga reg read failed, dev name:%s, offset:0x%x\n", + fpga_i2c->dev_name, addr); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga reg read success, dev name:%s, offset:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, *val); + return 0; +} + +static int fpga_data_write(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t *val, size_t size) +{ + int ret; + + ret = fpga_device_write(fpga_i2c, addr, val, size); + if (ret < 0) { + FPGA_I2C_ERROR("fpga data write failed, dev name:%s, offset:0x%x, size:%lu.\n", + fpga_i2c->dev_name, addr, size); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga data write success, dev name:%s, offset:0x%x, size:%lu.\n", + fpga_i2c->dev_name, addr, size); + return 0; +} + +static int fpga_data_read(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t *val, size_t size) +{ + int ret; + + ret = fpga_device_read(fpga_i2c, addr, val, size); + if (ret < 0) { + FPGA_I2C_ERROR("fpga data read failed, dev name:%s, offset:0x%x, size:%lu.\n", + fpga_i2c->dev_name, addr, size); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga data read success, dev name:%s, offset:0x%x, size:%lu.\n", + fpga_i2c->dev_name, addr, size); + return 0; +} + +static int fpga_reg_write_32(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint32_t val) +{ + int ret; + uint8_t buf[FPGA_REG_WIDTH]; + + memset(buf, 0, sizeof(buf)); + little_endian_dword_to_buf(buf, sizeof(buf), val); + ret = fpga_device_write(fpga_i2c, addr, buf, sizeof(buf)); + if (ret < 0) { + FPGA_I2C_ERROR("fpga reg write failed, dev name: %s, offset: 0x%x, value: 0x%x.\n", + fpga_i2c->dev_name, addr, val); + return -EIO; + } + + FPGA_I2C_VERBOSE("fpga reg write success, dev name: %s, offset: 0x%x, value: 0x%x.\n", + fpga_i2c->dev_name, addr, val); + return 0; +} + +static int fpga_reg_read_32(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint32_t *val) +{ + int ret; + uint8_t buf[FPGA_REG_WIDTH]; + + memset(buf, 0, sizeof(buf)); + ret = fpga_device_read(fpga_i2c, addr, buf, sizeof(buf)); + if (ret < 0) { + FPGA_I2C_ERROR("fpga reg read failed, dev name: %s, offset: 0x%x, ret: %d\n", + fpga_i2c->dev_name, addr, ret); + return -EIO; + } + little_endian_buf_to_dword(buf, sizeof(buf), val); + FPGA_I2C_VERBOSE("fpga reg read success, dev name: %s, offset: 0x%x, value: 0x%x.\n", + fpga_i2c->dev_name, addr, *val); + return 0; +} + +static int fpga_i2c_is_busy(fpga_i2c_dev_t *fpga_i2c) +{ + uint8_t val; + int ret; + fpga_i2c_reg_t *reg; + + reg = &fpga_i2c->reg; + ret = fpga_reg_read(fpga_i2c, reg->i2c_status, &val); + if (ret < 0 ) { + FPGA_I2C_ERROR("read fpga i2c status reg failed, reg addr:0x%x, ret:%d.\n", + reg->i2c_status, ret); + return 1; + } + if (val & FPGA_I2C_STA_BUSY) { + FPGA_I2C_ERROR("fpga i2c status busy, reg addr:0x%x, value:0x%x.\n", + reg->i2c_status, val); + return 1; + } else { + return 0; + } +} + +static int fpga_i2c_wait(fpga_i2c_dev_t *fpga_i2c) +{ + int retry_cnt; + + retry_cnt = FPGA_I2C_XFER_TIME_OUT/FPGA_I2C_SLEEP_TIME; + while (retry_cnt--) { + if (fpga_i2c_is_busy(fpga_i2c)) { + usleep_range(FPGA_I2C_SLEEP_TIME, FPGA_I2C_SLEEP_TIME + 1); + } else { + return 0; + } + } + + return -EBUSY; +} + +static int fpga_i2c_check_status(fpga_i2c_dev_t *fpga_i2c) +{ + uint8_t data; + int ret; + fpga_i2c_reg_t *reg; + + reg = &fpga_i2c->reg; + + ret = fpga_reg_read(fpga_i2c, reg->i2c_status, &data); + if (ret) { + FPGA_I2C_ERROR("read fpga i2c status reg failed, reg addr:0x%x, ret:%d.\n", + reg->i2c_status, ret); + return ret; + } + + if (data & FPGA_I2C_STA_FAIL) { + FPGA_I2C_ERROR("fpga i2c status error, reg addr:0x%x, value:%d.\n", + reg->i2c_status, data); + + /* read i2c_err_vec to confirm err type*/ + if (reg->i2c_err_vec != DTS_NO_CFG_FLAG) { + /* read i2c_err_vec reg */ + ret = fpga_reg_read(fpga_i2c, reg->i2c_err_vec, &data); + if (ret) { + FPGA_I2C_ERROR("read fpga i2c err vec reg failed, reg addr:0x%x, ret:%d.\n", + reg->i2c_err_vec, ret); + return ret; + } + FPGA_I2C_VERBOSE("get i2c err vec, reg addr:0x%x, read value:0x%x\n", reg->i2c_err_vec, data); + + /* match i2c_err_vec reg value and err type*/ + switch (data) { + case FPGA_I2C_STRETCH_TIMEOUT: + ret = -ETIMEDOUT; + break; + case FPGA_I2C_DEADLOCK_FAILED: + ret = -EDEADLK; + break; + case FPGA_I2C_SLAVE_NO_RESPOND: + ret = -ENXIO; + break; + default: + FPGA_I2C_ERROR("get i2c err vec value out of range, reg addr:0x%x, read value:0x%x\n", + reg->i2c_err_vec, data); + ret = -EREMOTEIO; + break; + } + return ret; + } else { + FPGA_I2C_VERBOSE("i2c err vec not config, fpga i2c status check return -1\n"); + return -EREMOTEIO; + } + } + return 0; +} + +static int fpga_i2c_do_work(fpga_i2c_dev_t *fpga_i2c, int i2c_addr, + unsigned char *data, uint32_t length, int is_read) +{ + int ret, i; + uint8_t op, i2c_reg_addr_len; + uint8_t *i2c_read_addr_buf; + fpga_i2c_reg_t *reg; + fpga_i2c_reg_addr_t *i2c_addr_desc; + + reg = &fpga_i2c->reg; + + ret = fpga_reg_write(fpga_i2c, reg->i2c_slave, i2c_addr); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c slave reg failed, reg addr:0x%x, value:0x%x, ret:%d.\n", + reg->i2c_slave, i2c_addr, ret); + goto exit; + } + + i2c_addr_desc = &fpga_i2c->i2c_addr_desc; + i2c_reg_addr_len = i2c_addr_desc->reg_addr_len; + i2c_read_addr_buf = &i2c_addr_desc->read_reg_addr[0]; + + if (i2c_reg_addr_len > 0 && i2c_reg_addr_len <= I2C_REG_MAX_WIDTH) { + ret = fpga_data_write(fpga_i2c, reg->i2c_reg, i2c_read_addr_buf, i2c_reg_addr_len); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c offset reg failed, fpga addr:0x%x, reg len:%d, ret:%d\n", + reg->i2c_reg, i2c_reg_addr_len, ret); + for (i = 0; i < i2c_reg_addr_len; i++) { + FPGA_I2C_ERROR("%02d : %02x\n", i, i2c_read_addr_buf[i]); + } + goto exit; + } + } + + ret = fpga_reg_write_32(fpga_i2c, reg->i2c_data_len, length); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c date len reg failed, reg addr:0x%x, value:0x%x, ret:%d.\n", + reg->i2c_data_len, length, ret); + goto exit; + } + + ret = fpga_reg_write(fpga_i2c, reg->i2c_reg_len, i2c_reg_addr_len); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c reg len reg failed, reg addr:0x%x, value:0x%x, ret:%d.\n", + reg->i2c_reg_len, i2c_reg_addr_len, ret); + goto exit; + } + + if (is_read) { + op = FPGA_I2C_CTL_RD | FPGA_I2C_CTL_BG; + } else { + + ret = fpga_data_write(fpga_i2c, reg->i2c_data_buf, data, length); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c date buf failed, reg addr:0x%x, write len:%d, ret:%d.\n", + reg->i2c_data_buf, length, ret); + goto exit; + } + op = FPGA_I2C_CTL_WR | FPGA_I2C_CTL_BG ; + } + + ret = fpga_reg_write(fpga_i2c, reg->i2c_ctrl, op); + if (ret) { + FPGA_I2C_ERROR("write fpga i2c control reg failed, reg addr:0x%x, value:%d, ret:%d.\n", + reg->i2c_ctrl, op, ret); + goto exit; + } + + ret = fpga_i2c_wait(fpga_i2c); + if (ret) { + FPGA_I2C_ERROR("wait fpga i2c status timeout.\n"); + goto exit; + } + + ret = fpga_i2c_check_status(fpga_i2c); + if (ret) { + FPGA_I2C_ERROR("check fpga i2c status error.\n"); + goto exit; + } + + if (is_read) { + + ret = fpga_data_read(fpga_i2c, reg->i2c_data_buf, data, length); + if (ret) { + FPGA_I2C_ERROR("read fpga i2c data buf failed, reg addr:0x%x, read len:%d, ret:%d.\n", + reg->i2c_data_buf, length, ret); + goto exit; + } + } + +exit: + return ret; +} + +static int fpga_i2c_write(fpga_i2c_dev_t *fpga_i2c, int target, + u8 *data, int length, int i2c_msg_num) +{ + int ret, i; + fpga_i2c_reg_addr_t *i2c_addr_desc; + + if (i2c_msg_num == I2C_READ_MSG_NUM) { + + if (length > I2C_REG_MAX_WIDTH) { + FPGA_I2C_ERROR("read reg addr len %d, more than max length.\n", length); + return -EINVAL; + } + + i2c_addr_desc = &fpga_i2c->i2c_addr_desc; + for (i = 0; i < length; i++) { + i2c_addr_desc->read_reg_addr[i] = data[length -i -1]; + FPGA_I2C_VERBOSE("%02d : %02x\n", i, i2c_addr_desc->read_reg_addr[i]); + } + i2c_addr_desc->reg_addr_len = length; + ret = 0; + } else { + + ret = fpga_i2c_do_work(fpga_i2c, target, data, length, 0); + } + + return ret; +} + +/** + * fpga_i2c_read - receive data from the bus. + * @i2c: The struct fpga_i2c_dev_t. + * @target: Target address. + * @data: Pointer to the location to store the datae . + * @length: Length of the data. + * + * The address is sent over the bus, then the data is read. + * + * Returns 0 on success, otherwise a negative errno. + */ +static int fpga_i2c_read(fpga_i2c_dev_t *fpga_i2c, int target, + u8 *data, int length) +{ + int ret, offset_size; + int i, tmp_val; + fpga_i2c_reg_addr_t *i2c_addr_desc; + uint8_t i2c_reg_addr_len; + uint8_t *i2c_read_addr_buf; + + offset_size = 0; + i2c_addr_desc = &fpga_i2c->i2c_addr_desc; + i2c_reg_addr_len = i2c_addr_desc->reg_addr_len; + i2c_read_addr_buf = &i2c_addr_desc->read_reg_addr[0]; + + while (1) { + if (length <= fpga_i2c->reg.i2c_data_buf_len) { + return fpga_i2c_do_work(fpga_i2c, target, data + offset_size, length, 1); + } + + ret = fpga_i2c_do_work(fpga_i2c, target, data + offset_size, fpga_i2c->reg.i2c_data_buf_len, 1); + if (ret != 0) { + FPGA_I2C_ERROR("fpga_i2c_read failed, i2c addr:0x%x, offset:0x%x, ret:%d.\n", + target, offset_size, ret); + return ret; + } + + tmp_val = i2c_read_addr_buf[0]; + tmp_val += fpga_i2c->reg.i2c_data_buf_len; + if (tmp_val > 0xff) { + i2c_read_addr_buf[0] = tmp_val & 0xff; + for (i = 1; i < i2c_reg_addr_len; i++) { + if (i2c_read_addr_buf[i] == 0xff) { + i2c_read_addr_buf[i] = 0; + } else { + i2c_read_addr_buf[i]++; + break; + } + } + } else { + i2c_read_addr_buf[0] = tmp_val & 0xff; + } + offset_size += fpga_i2c->reg.i2c_data_buf_len; + length -= fpga_i2c->reg.i2c_data_buf_len; + } + + return ret; +} + +static void fpga_i2c_reset(fpga_i2c_dev_t *fpga_i2c) { + fpga_i2c_reset_cfg_t *reset_cfg; + uint32_t reset_addr; + + reset_cfg = &fpga_i2c->reset_cfg; + reset_addr = reset_cfg->reset_addr; + if (reset_cfg->reset_delay_b) { + usleep_range(reset_cfg->reset_delay_b, reset_cfg->reset_delay_b + 1); + } + + fpga_reg_write_32(fpga_i2c, reset_addr, reset_cfg->reset_on); + if (reset_cfg->reset_delay) { + usleep_range(reset_cfg->reset_delay, reset_cfg->reset_delay + 1); + } + + fpga_reg_write_32(fpga_i2c, reset_addr, reset_cfg->reset_off); + if (reset_cfg->reset_delay_a) { + usleep_range(reset_cfg->reset_delay_a, reset_cfg->reset_delay_a + 1); + } + + return; +} + +/** + * fpga_i2c_xfer - The driver's master_xfer function. + * @adap: Pointer to the i2c_adapter structure. + * @msgs: Pointer to the messages to be processed. + * @num: Length of the MSGS array. + * + * Returns the number of messages processed, or a negative errno on + * failure. + */ +static int fpga_i2c_adapter_init(fpga_i2c_dev_t *fpga_i2c) +{ + int ret; + fpga_i2c_reg_t *reg; + + reg = &fpga_i2c->reg; + + ret = 0; + ret += fpga_reg_write(fpga_i2c, reg->i2c_scale, fpga_i2c->i2c_scale_value); + ret += fpga_reg_write(fpga_i2c, reg->i2c_filter, fpga_i2c->i2c_filter_value); + ret += fpga_reg_write(fpga_i2c, reg->i2c_stretch, fpga_i2c->i2c_stretch_value); + if (ret < 0) { + FPGA_I2C_ERROR("fpga_i2c_init failed.\n"); + return ret; + } + + FPGA_I2C_VERBOSE("fpga_i2c_init ok.\n"); + return 0; +} + +static int fpga_i2c_params_check(fpga_i2c_dev_t *fpga_i2c) +{ + int ret; + fpga_i2c_reg_t *reg; + uint8_t i2c_scale_value, i2c_filter_value, i2c_stretch_value; + + reg = &fpga_i2c->reg; + ret = 0; + ret += fpga_reg_read(fpga_i2c, reg->i2c_scale, &i2c_scale_value); + ret += fpga_reg_read(fpga_i2c, reg->i2c_filter, &i2c_filter_value); + ret += fpga_reg_read(fpga_i2c, reg->i2c_stretch, &i2c_stretch_value); + if (ret < 0) { + FPGA_I2C_ERROR("read fpga i2c params failed.\n"); + return 1; + } + + if ((i2c_scale_value != fpga_i2c->i2c_scale_value) + || (i2c_filter_value != fpga_i2c->i2c_filter_value) + || (i2c_stretch_value != fpga_i2c->i2c_stretch_value)) { + FPGA_I2C_ERROR("fpga i2c params check error, read value: i2c_scale 0x%x, i2c_filter:0x%x, i2c_stretch:0x%x.\n", + i2c_scale_value, i2c_filter_value, i2c_stretch_value); + FPGA_I2C_ERROR("fpga i2c params check error, config value: i2c_scale 0x%x, i2c_filter:0x%x, i2c_stretch:0x%x.\n", + fpga_i2c->i2c_scale_value, fpga_i2c->i2c_filter_value, fpga_i2c->i2c_stretch_value); + return 1; + } + + FPGA_I2C_VERBOSE("fpga i2c params check ok.\n"); + return 0; +} + +static int fpga_i2c_xfer(struct i2c_adapter *adap, + struct i2c_msg *msgs, int num) +{ + struct i2c_msg *pmsg; + int i; + int ret; + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_addr_t *i2c_addr_desc; + + fpga_i2c = i2c_get_adapdata(adap); + + if (num != I2C_READ_MSG_NUM && num != I2C_WRITE_MSG_NUM) { + FPGA_I2C_ERROR("unsupport i2c_msg len:%d.\n", num); + return -EINVAL; + } + + if ((num == I2C_WRITE_MSG_NUM) && (msgs[0].len > fpga_i2c->reg.i2c_data_buf_len)) { + FPGA_I2C_ERROR("unsupport i2c_msg type:msg[0].flag:0x%x, buf len:0x%x.\n", + msgs[0].flags, msgs[0].len); + return -EINVAL; + } + + if (num == I2C_READ_MSG_NUM ) { + if ((msgs[0].flags & I2C_M_RD) ||!(msgs[1].flags & I2C_M_RD)) { + FPGA_I2C_ERROR("unsupport i2c_msg type:msg[0].flag:0x%x, msg[1].flag:0x%x.\n", + msgs[0].flags, msgs[1].flags); + return -EINVAL; + } + } + + if (fpga_i2c_is_busy(fpga_i2c)) { + FPGA_I2C_ERROR("fpga i2c adapter %d is busy, do reset.\n", adap->nr); + if (fpga_i2c->reset_cfg.i2c_adap_reset_flag == 1) { + + fpga_i2c_reset(fpga_i2c); + + fpga_i2c_adapter_init(fpga_i2c); + } + return -EAGAIN; + } + + if (fpga_i2c->i2c_params_check && fpga_i2c_params_check(fpga_i2c)) { + FPGA_I2C_ERROR("fpga i2c params check failed, try to reinitialize.\n"); + fpga_i2c_adapter_init(fpga_i2c); + } + + ret = 0; + i2c_addr_desc = &fpga_i2c->i2c_addr_desc; + i2c_addr_desc->reg_addr_len = 0; + memset(i2c_addr_desc->read_reg_addr , 0, sizeof(i2c_addr_desc->read_reg_addr)); + + for (i = 0; ret == 0 && i < num; i++) { + pmsg = &msgs[i]; + FPGA_I2C_VERBOSE("Doing %s %d byte(s) to/from 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) { + ret = fpga_i2c_read(fpga_i2c, pmsg->addr, pmsg->buf, pmsg->len); + + if ((pmsg->len == 1) && (pmsg->flags & I2C_M_RECV_LEN)) { + if ((ret != 0) || (pmsg->buf[0] > I2C_SMBUS_BLOCK_MAX)) { + FPGA_I2C_ERROR("smbus block data read failed, ret:%d, read len:%u.\n", + ret, pmsg->buf[0]); + return -EPROTO; + } + pmsg->len = 1 + pmsg->buf[0]; + FPGA_I2C_VERBOSE("smbus block data read, read len:%d.\n", pmsg->len); + ret = fpga_i2c_read(fpga_i2c, pmsg->addr, pmsg->buf, pmsg->len); + } + } else { + ret = fpga_i2c_write(fpga_i2c, pmsg->addr, pmsg->buf, pmsg->len, num); + } + } + + return (ret != 0) ? ret : num; +} + +static u32 fpga_i2c_functionality(struct i2c_adapter *adap) +{ + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA; +} + +static const struct i2c_algorithm fpga_i2c_algo = { + .master_xfer = fpga_i2c_xfer, + .functionality = fpga_i2c_functionality, +}; + +static struct i2c_adapter fpga_i2c_ops = { + .owner = THIS_MODULE, + .name = "rg_fpga_i2c", + .algo = &fpga_i2c_algo, +}; + +static int fpga_i2c_config_init(fpga_i2c_dev_t *fpga_i2c) +{ + int ret = 0, rv = 0; + fpga_i2c_reg_t *reg; + fpga_i2c_reset_cfg_t *reset_cfg; + struct device *dev; + uint32_t i2c_offset_reg, i2c_data_buf_len_reg; + int32_t i2c_offset_val; + + fpga_i2c_bus_device_t *fpga_i2c_bus_device; + + dev = fpga_i2c->dev; + reg = &fpga_i2c->reg; + reset_cfg = &fpga_i2c->reset_cfg; + + i2c_offset_val = 0; + + if (dev->of_node) { + ret = 0; + ret += of_property_read_u32(dev->of_node, "i2c_ext_9548_addr", ®->i2c_ext_9548_addr); + ret += of_property_read_u32(dev->of_node, "i2c_ext_9548_chan", ®->i2c_ext_9548_chan); + ret += of_property_read_u32(dev->of_node, "i2c_slave", ®->i2c_slave); + ret += of_property_read_u32(dev->of_node, "i2c_reg", ®->i2c_reg); + ret += of_property_read_u32(dev->of_node, "i2c_data_len", ®->i2c_data_len); + ret += of_property_read_u32(dev->of_node, "i2c_ctrl", ®->i2c_ctrl); + ret += of_property_read_u32(dev->of_node, "i2c_status", ®->i2c_status); + ret += of_property_read_u32(dev->of_node, "i2c_scale", ®->i2c_scale); + ret += of_property_read_u32(dev->of_node, "i2c_filter", ®->i2c_filter); + ret += of_property_read_u32(dev->of_node, "i2c_stretch", ®->i2c_stretch); + ret += of_property_read_u32(dev->of_node, "i2c_ext_9548_exits_flag", ®->i2c_ext_9548_exits_flag); + ret += of_property_read_u32(dev->of_node, "i2c_reg_len", ®->i2c_reg_len); + ret += of_property_read_u32(dev->of_node, "i2c_in_9548_chan", ®->i2c_in_9548_chan); + ret += of_property_read_u32(dev->of_node, "i2c_data_buf", ®->i2c_data_buf); + ret += of_property_read_string(dev->of_node, "dev_name", &fpga_i2c->dev_name); + ret += of_property_read_u32(dev->of_node, "i2c_scale_value", &fpga_i2c->i2c_scale_value); + ret += of_property_read_u32(dev->of_node, "i2c_filter_value", &fpga_i2c->i2c_filter_value); + ret += of_property_read_u32(dev->of_node, "i2c_stretch_value", &fpga_i2c->i2c_stretch_value); + ret += of_property_read_u32(dev->of_node, "i2c_timeout", &fpga_i2c->i2c_timeout); + ret += of_property_read_u32(dev->of_node, "i2c_func_mode", &fpga_i2c->i2c_func_mode); + ret += of_property_read_u32(dev->of_node, "i2c_reset_addr", &reset_cfg->reset_addr); + ret += of_property_read_u32(dev->of_node, "i2c_reset_on", &reset_cfg->reset_on); + ret += of_property_read_u32(dev->of_node, "i2c_reset_off", &reset_cfg->reset_off); + ret += of_property_read_u32(dev->of_node, "i2c_rst_delay_b", &reset_cfg->reset_delay_b); + ret += of_property_read_u32(dev->of_node, "i2c_rst_delay", &reset_cfg->reset_delay); + ret += of_property_read_u32(dev->of_node, "i2c_rst_delay_a", &reset_cfg->reset_delay_a); + ret += of_property_read_u32(dev->of_node, "i2c_adap_reset_flag", &reset_cfg->i2c_adap_reset_flag); + + if (ret != 0) { + FPGA_I2C_ERROR("dts config error, ret:%d.\n", ret); + ret = -ENXIO; + return ret; + } + + rv = of_property_read_u32(dev->of_node, "i2c_data_buf_len_reg", &i2c_data_buf_len_reg); + if (rv == 0) { + ret = fpga_reg_read_32(fpga_i2c, i2c_data_buf_len_reg, ®->i2c_data_buf_len); + if (ret < 0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c data buf length, reg addr: 0x%x, ret: %d\n", + i2c_data_buf_len_reg, ret); + return ret; + } + FPGA_I2C_VERBOSE("fpga i2c data buf length reg addr: 0x%x, value: %d\n", + i2c_data_buf_len_reg, reg->i2c_data_buf_len); + if (reg->i2c_data_buf_len == 0) { + reg->i2c_data_buf_len = FPGA_I2C_RDWR_MAX_LEN_DEFAULT; + } + } else { + ret = of_property_read_u32(dev->of_node, "i2c_data_buf_len", ®->i2c_data_buf_len); + if (ret != 0) { + reg->i2c_data_buf_len = FPGA_I2C_RDWR_MAX_LEN_DEFAULT; + ret = 0; + } + } + + rv = of_property_read_u32(dev->of_node, "i2c_offset_reg", &i2c_offset_reg); + if (rv == 0) { + ret = fpga_reg_read_32(fpga_i2c, i2c_offset_reg, &i2c_offset_val); + if (ret < 0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c adapter offset value, reg addr: 0x%x, ret: %d\n", + i2c_offset_reg, ret); + return ret; + } + FPGA_I2C_VERBOSE("fpga i2c adapter offset reg addr: 0x%x, value: %d\n", + i2c_offset_reg, i2c_offset_val); + reg->i2c_scale +=i2c_offset_val; + reg->i2c_filter += i2c_offset_val; + reg->i2c_stretch += i2c_offset_val; + reg->i2c_ext_9548_exits_flag += i2c_offset_val; + reg->i2c_ext_9548_addr += i2c_offset_val; + reg->i2c_ext_9548_chan += i2c_offset_val; + reg->i2c_in_9548_chan += i2c_offset_val; + reg->i2c_slave += i2c_offset_val; + reg->i2c_reg += i2c_offset_val; + reg->i2c_reg_len += i2c_offset_val; + reg->i2c_data_len += i2c_offset_val; + reg->i2c_ctrl += i2c_offset_val; + reg->i2c_status += i2c_offset_val; + reg->i2c_data_buf += i2c_offset_val; + } + + ret = of_property_read_u32(dev->of_node, "i2c_err_vec", ®->i2c_err_vec); + if (ret != 0) { + reg->i2c_err_vec = DTS_NO_CFG_FLAG; + FPGA_I2C_VERBOSE("not support i2c_err_vec cfg. ret: %d, set DTS_NO_CFG_FLAG: %d\n", + ret, reg->i2c_err_vec); + ret = 0; /* Not configuring i2c_err_vec is not an error */ + } else { + if (i2c_offset_val != 0) { + reg->i2c_err_vec += i2c_offset_val; + } + } + } else { + if (dev->platform_data == NULL) { + dev_err(fpga_i2c->dev, "Failed to get platform data config.\n"); + ret = -ENXIO; + return ret; + } + fpga_i2c_bus_device = dev->platform_data; + fpga_i2c->dev_name = fpga_i2c_bus_device->dev_name; + fpga_i2c->adap_nr = fpga_i2c_bus_device->adap_nr; + fpga_i2c->i2c_scale_value = fpga_i2c_bus_device->i2c_scale_value; + fpga_i2c->i2c_filter_value = fpga_i2c_bus_device->i2c_filter_value; + fpga_i2c->i2c_stretch_value = fpga_i2c_bus_device->i2c_stretch_value; + fpga_i2c->i2c_timeout = fpga_i2c_bus_device->i2c_timeout; + fpga_i2c->i2c_func_mode = fpga_i2c_bus_device->i2c_func_mode; + fpga_i2c->i2c_params_check = fpga_i2c_bus_device->i2c_func_mode; + + reset_cfg->reset_addr = fpga_i2c_bus_device->i2c_reset_addr; + reset_cfg->reset_on = fpga_i2c_bus_device->i2c_reset_on; + reset_cfg->reset_off = fpga_i2c_bus_device->i2c_reset_off; + reset_cfg->reset_delay_b = fpga_i2c_bus_device->i2c_rst_delay_b; + reset_cfg->reset_delay = fpga_i2c_bus_device->i2c_rst_delay; + reset_cfg->reset_delay_a = fpga_i2c_bus_device->i2c_rst_delay_a; + reset_cfg->i2c_adap_reset_flag = fpga_i2c_bus_device->i2c_adap_reset_flag; + + reg->i2c_ext_9548_addr = fpga_i2c_bus_device->i2c_ext_9548_addr; + reg->i2c_ext_9548_chan = fpga_i2c_bus_device->i2c_ext_9548_chan; + reg->i2c_slave = fpga_i2c_bus_device->i2c_slave; + reg->i2c_reg = fpga_i2c_bus_device->i2c_reg; + reg->i2c_data_len = fpga_i2c_bus_device->i2c_data_len; + reg->i2c_ctrl = fpga_i2c_bus_device->i2c_ctrl; + reg->i2c_status = fpga_i2c_bus_device->i2c_status; + reg->i2c_scale = fpga_i2c_bus_device->i2c_scale; + reg->i2c_filter = fpga_i2c_bus_device->i2c_filter; + reg->i2c_stretch = fpga_i2c_bus_device->i2c_stretch; + reg->i2c_ext_9548_exits_flag = fpga_i2c_bus_device->i2c_ext_9548_exits_flag; + reg->i2c_reg_len = fpga_i2c_bus_device->i2c_reg_len; + reg->i2c_in_9548_chan = fpga_i2c_bus_device->i2c_in_9548_chan; + reg->i2c_data_buf = fpga_i2c_bus_device->i2c_data_buf; + + i2c_data_buf_len_reg = fpga_i2c_bus_device->i2c_data_buf_len_reg; + if (i2c_data_buf_len_reg > 0) { + ret = fpga_reg_read_32(fpga_i2c, i2c_data_buf_len_reg, ®->i2c_data_buf_len); + if (ret < 0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c data buf length, reg addr: 0x%x, ret: %d\n", + i2c_data_buf_len_reg, ret); + return ret; + } + FPGA_I2C_VERBOSE("fpga i2c data buf length reg addr: 0x%x, value: %d\n", + i2c_data_buf_len_reg, reg->i2c_data_buf_len); + if (reg->i2c_data_buf_len == 0) { + reg->i2c_data_buf_len = FPGA_I2C_RDWR_MAX_LEN_DEFAULT; + } + } else { + if (fpga_i2c_bus_device->i2c_data_buf_len == 0) { + reg->i2c_data_buf_len = FPGA_I2C_RDWR_MAX_LEN_DEFAULT; + FPGA_I2C_VERBOSE("not support i2c_data_buf_len cfg, set default_val:%d\n", + reg->i2c_data_buf_len); + } else { + reg->i2c_data_buf_len = fpga_i2c_bus_device->i2c_data_buf_len; + } + } + + i2c_offset_reg = fpga_i2c_bus_device->i2c_offset_reg; + if (i2c_offset_reg > 0) { + rv = fpga_reg_read_32(fpga_i2c, i2c_offset_reg, &i2c_offset_val); + if (rv < 0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c adapter offset value, reg addr: 0x%x, rv: %d\n", + i2c_offset_reg, rv); + return rv; + } + FPGA_I2C_VERBOSE("fpga i2c adapter offset reg addr: 0x%x, value: %d\n", + i2c_offset_reg, i2c_offset_val); + reg->i2c_scale +=i2c_offset_val; + reg->i2c_filter += i2c_offset_val; + reg->i2c_stretch += i2c_offset_val; + reg->i2c_ext_9548_exits_flag += i2c_offset_val; + reg->i2c_ext_9548_addr += i2c_offset_val; + reg->i2c_ext_9548_chan += i2c_offset_val; + reg->i2c_in_9548_chan += i2c_offset_val; + reg->i2c_slave += i2c_offset_val; + reg->i2c_reg += i2c_offset_val; + reg->i2c_reg_len += i2c_offset_val; + reg->i2c_data_len += i2c_offset_val; + reg->i2c_ctrl += i2c_offset_val; + reg->i2c_status += i2c_offset_val; + reg->i2c_data_buf += i2c_offset_val; + } + + if (fpga_i2c_bus_device->i2c_err_vec == 0) { + reg->i2c_err_vec = DTS_NO_CFG_FLAG; + FPGA_I2C_VERBOSE("not support i2c_err_vec cfg, set DTS_NO_CFG_FLAG:%d\n", + reg->i2c_err_vec); + } else { + reg->i2c_err_vec = fpga_i2c_bus_device->i2c_err_vec; + if (i2c_offset_val != 0) { + reg->i2c_err_vec += i2c_offset_val; + } + } + } + + FPGA_I2C_VERBOSE("i2c_ext_9548_addr:0x%x, i2c_ext_9548_chan:0x%x, i2c_slave:0x%x, i2c_reg:0x%x, i2c_data_len:0x%x.\n", + reg->i2c_ext_9548_addr, reg->i2c_ext_9548_chan, reg->i2c_slave, reg->i2c_reg, reg->i2c_data_len); + FPGA_I2C_VERBOSE("i2c_ctrl:0x%x, i2c_status:0x%x, i2c_scale:0x%x, i2c_filter:0x%x, i2c_stretch:0x%x.\n", + reg->i2c_ctrl, reg->i2c_status, reg->i2c_scale, reg->i2c_filter, reg->i2c_stretch); + FPGA_I2C_VERBOSE("i2c_ext_9548_exits_flag:0x%x, i2c_in_9548_chan:0x%x, i2c_data_buf:0x%x, i2c_reg_len:0x%x, i2c_data_buf_len:0x%x.\n", + reg->i2c_ext_9548_exits_flag, reg->i2c_in_9548_chan, reg->i2c_data_buf, reg->i2c_reg_len, reg->i2c_data_buf_len); + FPGA_I2C_VERBOSE("dev_name:%s, i2c_scale_value:0x%x, i2c_filter_value:0x%x, i2c_stretch_value:0x%x, i2c_timeout:0x%x.\n", + fpga_i2c->dev_name, fpga_i2c->i2c_scale_value, fpga_i2c->i2c_filter_value, fpga_i2c->i2c_stretch_value, fpga_i2c->i2c_timeout); + FPGA_I2C_VERBOSE("i2c_reset_addr:0x%x, i2c_reset_on:0x%x, i2c_reset_off:0x%x, i2c_rst_delay_b:0x%x, i2c_rst_delay:0x%x, i2c_rst_delay_a:0x%x.\n", + reset_cfg->reset_addr, reset_cfg->reset_on, reset_cfg->reset_off, reset_cfg->reset_delay_b, reset_cfg->reset_delay, reset_cfg->reset_delay_a); + FPGA_I2C_VERBOSE("i2c_adap_reset_flag:0x%x.\n", reset_cfg->i2c_adap_reset_flag); + FPGA_I2C_VERBOSE("i2c_err_vec:0x%x\n", reg->i2c_err_vec); + + return ret; +} + +static int fpga_i2c_probe(struct platform_device *pdev) +{ + int ret; + fpga_i2c_dev_t *fpga_i2c; + struct device *dev; + + fpga_i2c = devm_kzalloc(&pdev->dev, sizeof(fpga_i2c_dev_t), GFP_KERNEL); + if (!fpga_i2c) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + ret = -ENOMEM; + goto out; + } + + fpga_i2c->dev = &pdev->dev; + + ret = fpga_i2c_config_init(fpga_i2c); + if (ret !=0) { + dev_err(fpga_i2c->dev, "Failed to get fpga i2c dts config.\n"); + goto out; + } + + ret = fpga_i2c_adapter_init(fpga_i2c); + if (ret !=0) { + dev_err(fpga_i2c->dev, "Failed to init fpga i2c adapter.\n"); + goto out; + } + + if (fpga_i2c->dev->of_node) { + fpga_i2c->i2c_params_check = of_property_read_bool(fpga_i2c->dev->of_node, "i2c_params_check"); + } + FPGA_I2C_VERBOSE("fpga i2c params check flag:%d.\n", fpga_i2c->i2c_params_check); + + init_waitqueue_head(&fpga_i2c->queue); + + dev = fpga_i2c->dev; + fpga_i2c->adap = fpga_i2c_ops; + fpga_i2c->adap.timeout = msecs_to_jiffies(fpga_i2c->i2c_timeout); + fpga_i2c->adap.dev.parent = &pdev->dev; + fpga_i2c->adap.dev.of_node = pdev->dev.of_node; + i2c_set_adapdata(&fpga_i2c->adap, fpga_i2c); + platform_set_drvdata(pdev, fpga_i2c); + + if (fpga_i2c->dev->of_node) { + /* adap.nr get from dts aliases */ + ret = i2c_add_adapter(&fpga_i2c->adap); + } else { + fpga_i2c->adap.nr = fpga_i2c->adap_nr; + ret = i2c_add_numbered_adapter(&fpga_i2c->adap); + } + + if (ret < 0) { + dev_info(fpga_i2c->dev, "Failed to add adapter.\n"); + goto fail_add; + } + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) + of_i2c_register_devices(&fpga_i2c->adap); +#endif + dev_info(fpga_i2c->dev, "registered i2c-%d for %s using mode %d with base address:0x%x, data buf len: %d success.\n", + fpga_i2c->adap.nr, fpga_i2c->dev_name, fpga_i2c->i2c_func_mode, fpga_i2c->reg.i2c_scale, + fpga_i2c->reg.i2c_data_buf_len); + return 0; + +fail_add: + platform_set_drvdata(pdev, NULL); +out: + return ret; +}; + +static int fpga_i2c_remove(struct platform_device *pdev) +{ + fpga_i2c_dev_t *fpga_i2c; + + fpga_i2c = platform_get_drvdata(pdev); + i2c_del_adapter(&fpga_i2c->adap); + platform_set_drvdata(pdev, NULL); + return 0; +}; + +static struct of_device_id fpga_i2c_match[] = { + { + .compatible = "ruijie,rg-fpga-i2c", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, fpga_i2c_match); + +static struct platform_driver rg_fpga_i2c_driver = { + .probe = fpga_i2c_probe, + .remove = fpga_i2c_remove, + .driver = { + .owner = THIS_MODULE, + .name = DRV_NAME, + .of_match_table = fpga_i2c_match, + }, +}; + +static int __init rg_fpga_i2c_init(void) +{ + return platform_driver_register(&rg_fpga_i2c_driver); +} + +static void __exit rg_fpga_i2c_exit(void) +{ + platform_driver_unregister(&rg_fpga_i2c_driver); +} + +module_init(rg_fpga_i2c_init); +module_exit(rg_fpga_i2c_exit); +MODULE_DESCRIPTION("fpga i2c adapter driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pca954x_drv.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pca954x_drv.c new file mode 100644 index 000000000000..5f25012d446f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pca954x_drv.c @@ -0,0 +1,531 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * fpga_pca954x_drv.c + * Original Author: sonic_rd@ruijie.com.cn 2020-08-10 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fpga_i2c.h" + +extern int i2c_device_func_write(const char *path, uint32_t pos, uint8_t *val, size_t size); +extern int pcie_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); + +#define PCA954X_MAX_NCHANS (8) +#define FPGA_INTERNAL_PCA9548 (1) +#define FPGA_EXTERNAL_PCA9548 (2) +#define FPGA_I2C_EXT_9548_EXITS (0x01 << 0) +#define FPGA_I2C_9548_NO_RESET (0x01 << 1) + +#define SYMBOL_I2C_DEV_MODE (1) +#define FILE_MODE (2) +#define SYMBOL_PCIE_DEV_MODE (3) +#define SYMBOL_IO_DEV_MODE (4) + +int g_fpga_pca954x_debug = 0; +int g_fpga_pca954x_error = 0; + +module_param(g_fpga_pca954x_debug, int, S_IRUGO | S_IWUSR); +module_param(g_fpga_pca954x_error, int, S_IRUGO | S_IWUSR); + +#define FPGA_PCA954X_VERBOSE(fmt, args...) do { \ + if (g_fpga_pca954x_debug) { \ + printk(KERN_INFO "[FPGA_PCA954X][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_PCA954X_ERROR(fmt, args...) do { \ + if (g_fpga_pca954x_error) { \ + printk(KERN_ERR "[FPGA_PCA954X][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +enum pca_type { + pca_9540, + pca_9541, + pca_9542, + pca_9543, + pca_9544, + pca_9545, + pca_9546, + pca_9547, + pca_9548, +}; + +struct pca954x { + enum pca_type type; + struct i2c_adapter *virt_adaps[PCA954X_MAX_NCHANS]; + u8 last_chan; /* last register value */ + uint32_t fpga_9548_flag; + uint32_t fpga_9548_reset_flag; + uint32_t pca9548_base_nr; + struct i2c_client *client; +}; + +struct chip_desc { + u8 nchans; + u8 enable; /* used for muxes only */ + enum muxtype { + pca954x_ismux = 0, + pca954x_isswi + } muxtype; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [pca_9540] = { + .nchans = 2, + .enable = 0x4, + .muxtype = pca954x_ismux, + }, + [pca_9541] = { + .nchans = 1, + .muxtype = pca954x_isswi, + }, + [pca_9543] = { + .nchans = 2, + .muxtype = pca954x_isswi, + }, + [pca_9544] = { + .nchans = 4, + .enable = 0x4, + .muxtype = pca954x_ismux, + }, + [pca_9545] = { + .nchans = 4, + .muxtype = pca954x_isswi, + }, + [pca_9547] = { + .nchans = 8, + .enable = 0x8, + .muxtype = pca954x_ismux, + }, + [pca_9548] = { + .nchans = 8, + .muxtype = pca954x_isswi, + }, +}; + +static const struct i2c_device_id fpga_pca954x_id[] = { + { "rg_fpga_pca9540", pca_9540 }, + { "rg_fpga_pca9541", pca_9541 }, + { "rg_fpga_pca9542", pca_9543 }, + { "rg_fpga_pca9543", pca_9543 }, + { "rg_fpga_pca9544", pca_9544 }, + { "rg_fpga_pca9545", pca_9545 }, + { "rg_fpga_pca9546", pca_9545 }, + { "rg_fpga_pca9547", pca_9547 }, + { "rg_fpga_pca9548", pca_9548 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, fpga_pca954x_id); + +static int fpga_file_write(const char *path, int pos, unsigned char *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDWR, 777); + if (IS_ERR(filp)) { + FPGA_PCA954X_ERROR("write open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_write(filp, val, size, &tmp_pos); + if (ret < 0) { + FPGA_PCA954X_ERROR("kernel_write failed, path=%s, addr=%d, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + + vfs_fsync(filp, 1); + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; + +} +static int fpga_device_write(fpga_i2c_dev_t *fpga_i2c, int pos, unsigned char *val, size_t size) +{ + int ret; + + switch (fpga_i2c->i2c_func_mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_write(fpga_i2c->dev_name, pos, val, size); + break; + case FILE_MODE: + ret = fpga_file_write(fpga_i2c->dev_name, pos, val, size); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_write(fpga_i2c->dev_name, pos, val, size); + break; + default: + FPGA_PCA954X_ERROR("err func mode, write failed.\n"); + return -EINVAL; + } + + return ret; +} + +static int fpga_reg_write(fpga_i2c_dev_t *fpga_i2c, uint32_t addr, uint8_t val) +{ + int ret; + + ret = fpga_device_write(fpga_i2c, addr, &val, sizeof(uint8_t)); + if (ret < 0) { + FPGA_PCA954X_ERROR("fpga_device_write failed. name:%s, addr:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, val); + return ret; + } + + FPGA_PCA954X_VERBOSE("fpga reg write success, dev name:%s, offset:0x%x, value:0x%x.\n", + fpga_i2c->dev_name, addr, val); + return 0; +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,7) +static int pca954x_select_chan(struct i2c_adapter *adap, void *client, u32 chan) +{ + struct pca954x *data = i2c_get_clientdata(client); + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_t *reg; + int ret; + u8 regval, i2c_9548_opt; + + while(i2c_parent_is_i2c_adapter(adap)){ + adap = to_i2c_adapter(adap->dev.parent); + } + + FPGA_PCA954X_VERBOSE("root bus:%d, chan:0x%x, 9548 flag:0x%x, 9548 addr:0x%x.\n", + adap->nr, chan, data->fpga_9548_flag, client->addr); + fpga_i2c = i2c_get_adapdata(adap); + reg = &fpga_i2c->reg; + + regval = 1 << chan; + if (data->fpga_9548_flag == FPGA_INTERNAL_PCA9548) { + ret = fpga_reg_write(fpga_i2c, reg->i2c_in_9548_chan, regval); + } else { + if (data->fpga_9548_reset_flag == 1) { + i2c_9548_opt = FPGA_I2C_EXT_9548_EXITS & ~(FPGA_I2C_9548_NO_RESET); + } else { + i2c_9548_opt = FPGA_I2C_EXT_9548_EXITS | FPGA_I2C_9548_NO_RESET; + } + FPGA_PCA954X_VERBOSE("fpga pca9548 reset flag:0x%x, opt:0x%x.\n", + data->fpga_9548_reset_flag, i2c_9548_opt); + ret = fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_exits_flag, i2c_9548_opt); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_addr, client->addr); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_chan, regval); + } + + return ret; +} + +static int pca954x_deselect_mux(struct i2c_adapter *adap, void *client, u32 chan) +{ + struct pca954x *data = i2c_get_clientdata(client); + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_t *reg; + int ret; + + while(i2c_parent_is_i2c_adapter(adap)){ + adap = to_i2c_adapter(adap->dev.parent); + } + + fpga_i2c = i2c_get_adapdata(adap); + reg = &fpga_i2c->reg; + /* Deselect active channel */ + data->last_chan = 0; + if (data->fpga_9548_flag == FPGA_INTERNAL_PCA9548) { + ret = fpga_reg_write(fpga_i2c, reg->i2c_in_9548_chan, 0); + } else { + + ret = fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_exits_flag, FPGA_I2C_9548_NO_RESET); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_chan, 0); + } + + return ret; +} +#else +static int pca954x_select_chan(struct i2c_mux_core *muxc, u32 chan) +{ + struct pca954x *data = i2c_mux_priv(muxc); + struct i2c_client *client = data->client; + struct i2c_adapter *adap; + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_t *reg; + int ret; + u8 regval, i2c_9548_opt; + + adap = muxc->parent; + while(i2c_parent_is_i2c_adapter(adap)){ + adap = to_i2c_adapter(adap->dev.parent); + } + + FPGA_PCA954X_VERBOSE("root bus:%d, chan:0x%x, 9548 flag:0x%x, 9548 addr:0x%x.\n", + adap->nr, chan, data->fpga_9548_flag, client->addr); + fpga_i2c = i2c_get_adapdata(adap); + reg = &fpga_i2c->reg; + + regval = 1 << chan; + if (data->fpga_9548_flag == FPGA_INTERNAL_PCA9548) { + ret = fpga_reg_write(fpga_i2c, reg->i2c_in_9548_chan, regval); + } else { + if (data->fpga_9548_reset_flag == 1) { + i2c_9548_opt = FPGA_I2C_EXT_9548_EXITS & ~(FPGA_I2C_9548_NO_RESET); + } else { + i2c_9548_opt = FPGA_I2C_EXT_9548_EXITS | FPGA_I2C_9548_NO_RESET; + } + FPGA_PCA954X_VERBOSE("fpga pca9548 reset flag:0x%x, opt:0x%x.\n", + data->fpga_9548_reset_flag, i2c_9548_opt); + ret = fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_exits_flag, i2c_9548_opt); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_addr, client->addr); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_chan, regval); + } + + return ret; +} + +static int pca954x_deselect_mux(struct i2c_mux_core *muxc, u32 chan) +{ + struct pca954x *data = i2c_mux_priv(muxc); + struct i2c_adapter *adap; + fpga_i2c_dev_t *fpga_i2c; + fpga_i2c_reg_t *reg; + int ret; + + adap = muxc->parent; + while(i2c_parent_is_i2c_adapter(adap)){ + adap = to_i2c_adapter(adap->dev.parent); + } + + fpga_i2c = i2c_get_adapdata(adap); + reg = &fpga_i2c->reg; + ret = 0; + /* Deselect active channel */ + data->last_chan = 0; + + if (data->fpga_9548_flag == FPGA_INTERNAL_PCA9548) { + ret = fpga_reg_write(fpga_i2c, reg->i2c_in_9548_chan, 0); + } else { + + ret = fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_exits_flag, FPGA_I2C_9548_NO_RESET); + ret += fpga_reg_write(fpga_i2c, reg->i2c_ext_9548_chan, 0); + } + + return ret; +} +#endif +/* + * I2C init/probing/exit functions + */ +static int fpga_i2c_pca954x_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + int num, force, class; + struct pca954x *data; + int ret = -ENODEV; + struct device *dev; + int dynamic_nr = 1; + fpga_pca954x_device_t *fpga_pca954x_device; + +#if LINUX_VERSION_CODE > KERNEL_VERSION(4,6,7) + struct i2c_mux_core *muxc; +#endif + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) { + dev_err(&client->dev, "i2c adapter:%d, unsupport I2C_FUNC_SMBUS_BYTE.\n", adap->nr); + goto err; + } + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) + data = kzalloc(sizeof(struct pca954x), GFP_KERNEL); + if (!data) { + dev_err(&client->dev, "kzalloc failed.\n"); + ret = -ENOMEM; + goto err; + } + + i2c_set_clientdata(client, data); +#else + muxc = i2c_mux_alloc(adap, &client->dev, + PCA954X_MAX_NCHANS, sizeof(*data), 0, + pca954x_select_chan, pca954x_deselect_mux); + if (!muxc) { + dev_err(&client->dev, "i2c_mux_alloc failed.\n"); + return -ENOMEM; + } + data = i2c_mux_priv(muxc); + i2c_set_clientdata(client, muxc); + data->client = client; +#endif + + dev = &client->dev; + if (dev == NULL) { + dev_err(&client->dev, "dev is NULL.\n"); + ret = -ENODEV; + goto exit_free; + } + + if (dev->of_node == NULL) { + if (client->dev.platform_data == NULL) { + dev_err(&client->dev, "Failed to get 954x platform data config.\n"); + ret = -EINVAL; + goto exit_free; + } + fpga_pca954x_device = client->dev.platform_data; + data->fpga_9548_flag = fpga_pca954x_device->fpga_9548_flag; + data->fpga_9548_reset_flag = fpga_pca954x_device->fpga_9548_reset_flag; + data->pca9548_base_nr = fpga_pca954x_device->pca9548_base_nr; + if (data->pca9548_base_nr == 0) { + + dynamic_nr = 1; + } else { + dynamic_nr = 0; + FPGA_PCA954X_VERBOSE("pca9548_base_nr:%u.\n", data->pca9548_base_nr); + } + } else { + data->type = id->driver_data; + /* BUS ID */ + ret = of_property_read_u32(dev->of_node, "fpga_9548_flag", &data->fpga_9548_flag); + ret += of_property_read_u32(dev->of_node, "fpga_9548_reset_flag", &data->fpga_9548_reset_flag); + if (ret != 0) { + dev_err(&client->dev, "Failed to get 954x dts config, ret:%d.\n", ret); + ret = -EINVAL; + goto exit_free; + } + if (of_property_read_u32(dev->of_node, "pca9548_base_nr", &data->pca9548_base_nr)) { + + dynamic_nr = 1; + FPGA_PCA954X_VERBOSE("pca9548_base_nr not found, use dynamic adap number"); + } else { + dynamic_nr = 0; + FPGA_PCA954X_VERBOSE("pca9548_base_nr:%u.\n", data->pca9548_base_nr); + } + } + + if (data->fpga_9548_flag != FPGA_EXTERNAL_PCA9548 && data->fpga_9548_flag != FPGA_INTERNAL_PCA9548) { + dev_err(&client->dev, "Error: fpga 954x flag config error, value:0x%x.\n", data->fpga_9548_flag); + ret = -EINVAL; + goto exit_free; + } + + data->type = id->driver_data; + data->last_chan = 0; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (num = 0; num < chips[data->type].nchans; num++) { + if (dynamic_nr == 1) { + force = 0; /* dynamic adap number */ + } else { + force = data->pca9548_base_nr + num; + } + class = 0; /* no class by default */ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) + data->virt_adaps[num] = + i2c_add_mux_adapter(adap, &client->dev, client, + force, num, class, pca954x_select_chan, pca954x_deselect_mux); + + if (data->virt_adaps[num] == NULL) { + ret = -ENODEV; + dev_err(&client->dev, "Failed to register multiplexed adapter %d as bus %d\n", + num, force); + goto virt_reg_failed; + } +#else + ret = i2c_mux_add_adapter(muxc, force, num, class); + if (ret) { + dev_err(&client->dev, "Failed to register multiplexed adapter %d as bus %d\n", + num, force); + goto virt_reg_failed; + } +#endif + } /* end for num = 0; num < chips[data->type].nchans... */ + + dev_info(&client->dev, "registered %d multiplexed busses for I2C %s %s\n", + num, chips[data->type].muxtype == pca954x_ismux ? "mux" : "switch", client->name); + + return 0; + +virt_reg_failed: +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) + for (num--; num >= 0; num--) + i2c_del_mux_adapter(data->virt_adaps[num]); +exit_free: + kfree(data); +#else +exit_free: + i2c_mux_del_adapters(muxc); +#endif +err: + return ret; +} + +static int fpga_i2c_pca954x_remove(struct i2c_client *client) +{ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,7) + struct pca954x *data = i2c_get_clientdata(client); + const struct chip_desc *chip = &chips[data->type]; + int i; + + for (i = 0; i < chip->nchans; ++i) + if (data->virt_adaps[i]) { + i2c_del_mux_adapter(data->virt_adaps[i]); + data->virt_adaps[i] = NULL; + } + + kfree(data); +#else + struct i2c_mux_core *muxc = i2c_get_clientdata(client); + + i2c_mux_del_adapters(muxc); +#endif + + return 0; +} + +static struct i2c_driver fpga_i2c_pca954x_driver = { + .driver = { + .name = "rg_fpga_pca954x", + .owner = THIS_MODULE, + }, + .probe = fpga_i2c_pca954x_probe, + .remove = fpga_i2c_pca954x_remove, + .id_table = fpga_pca954x_id, +}; + +static int __init fpga_i2c_pca954x_init(void) +{ + int ret; + + ret = i2c_add_driver(&fpga_i2c_pca954x_driver); + return ret; +} + +static void __exit fpga_i2c_pca954x_exit(void) +{ + i2c_del_driver(&fpga_i2c_pca954x_driver); +} + +module_init(fpga_i2c_pca954x_init); +module_exit(fpga_i2c_pca954x_exit); +MODULE_DESCRIPTION("fpga pca954x driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pcie.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pcie.c new file mode 100644 index 000000000000..d644d973e1b4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_fpga_pcie.c @@ -0,0 +1,167 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * rg_fpga_pcie.c + * ko to enable fpga pcie + * Original Author: sonic_rd@ruijie.com.cn 2020-08-10 + */ +#include +#include +#include +#include +#include + +#define FPGA_MSI_IRQ_NUM (14) +#define FPGA_MSI_IRQ_BEGIN (0) +#define XILINX_FPGA_USE_MSI (0) +#define XILINX_FPGA_NUSE_MSI (1) + +int g_fpga_pcie_dev_debug = 0; +int g_fpga_pcie_dev_error = 0; +module_param(g_fpga_pcie_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_fpga_pcie_dev_error, int, S_IRUGO | S_IWUSR); + +#define FPGA_PCIE_DEV_VERBOSE(fmt, args...) do { \ + if (g_fpga_pcie_dev_debug) { \ + printk(KERN_INFO "[FPGA_PCIE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_PCIE_DEV_ERROR(fmt, args...) do { \ + if (g_fpga_pcie_dev_error) { \ + printk(KERN_ERR "[FPGA_PCIE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef struct rg_fpga_pcie_s { + struct pci_dev *pci_dev; + int driver_data; +} rg_fpga_pcie_t; + +static void fpga_pcie_recover(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct resource *mem_base; + u32 bar0_val; + int ret; + + mem_base = &pdev->resource[0]; + ret = pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &bar0_val); + if (ret) { + FPGA_PCIE_DEV_ERROR("pci_read_config_dword failed ret %d.\n", ret); + return; + } + FPGA_PCIE_DEV_VERBOSE("mem_base->start[0x%llx], bar0_val[0x%x], ret %d.\n", + mem_base->start, bar0_val, ret); + + if (bar0_val != mem_base->start) { + ret = pci_write_config_dword(pdev, PCI_BASE_ADDRESS_0, mem_base->start); + if (ret) { + FPGA_PCIE_DEV_ERROR("pci_write_config_dword mem_base->start[0x%llx], failed ret %d.\n", mem_base->start, ret); + return; + } + FPGA_PCIE_DEV_VERBOSE("pci_write_config_dword mem_base->start[0x%llx] success.\n", mem_base->start); + } else { + FPGA_PCIE_DEV_VERBOSE("mem_base->start[0x%llx], bar0_val[0x%x], do nothing.\n", + mem_base->start, bar0_val); + } +} + +static int fpga_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + int err; + rg_fpga_pcie_t *rg_fpga_pcie; + + FPGA_PCIE_DEV_VERBOSE("Enter vendor 0x%x, subsystem_vendor 0x%x.\n", pdev->vendor, pdev->subsystem_vendor); + + rg_fpga_pcie = devm_kzalloc(&pdev->dev, sizeof(rg_fpga_pcie_t), GFP_KERNEL); + if (!rg_fpga_pcie) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + return -ENOMEM; + } + + fpga_pcie_recover(pdev, id); + + /* enable device: ask low-level code to enable I/O and memory */ + FPGA_PCIE_DEV_VERBOSE("start pci_enable_device!\n"); + err = pci_enable_device(pdev); + if (err) { + dev_err(&pdev->dev, "Failed to enable pci device, ret:%d.\n", err); + return err; + } + + FPGA_PCIE_DEV_VERBOSE("start pci_set_master!\n"); + pci_set_master(pdev); + + rg_fpga_pcie->driver_data = id->driver_data; + rg_fpga_pcie->pci_dev = pdev; + pci_set_drvdata(pdev, rg_fpga_pcie); + + if (rg_fpga_pcie->driver_data == XILINX_FPGA_USE_MSI) { + FPGA_PCIE_DEV_VERBOSE("start pci_enable_msi_range!\n"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,152) + err = pci_enable_msi_range(pdev, FPGA_MSI_IRQ_BEGIN + 1, FPGA_MSI_IRQ_NUM); +#else + err = pci_alloc_irq_vectors_affinity(pdev, FPGA_MSI_IRQ_BEGIN + 1, + FPGA_MSI_IRQ_NUM, PCI_IRQ_MSI, NULL); +#endif + if (err != FPGA_MSI_IRQ_NUM) { + FPGA_PCIE_DEV_ERROR("pci_enable_msi_block err %d FPGA_MSI_IRQ_NUM %d.\n", err, + FPGA_MSI_IRQ_NUM); + dev_err(&pdev->dev, "Failed to enable pci msi, ret:%d.\n", err); + return -EINVAL; + } + } + + dev_info(&pdev->dev, "fpga pci device init success.\n"); + return 0; +} + +static void fpga_pcie_remove(struct pci_dev *pdev) +{ + rg_fpga_pcie_t *rg_fpga_pcie; + + FPGA_PCIE_DEV_VERBOSE("fpga_pcie_remove.\n"); + + rg_fpga_pcie = pci_get_drvdata(pdev); + if (rg_fpga_pcie->driver_data == XILINX_FPGA_USE_MSI) { + FPGA_PCIE_DEV_VERBOSE("start pci_disable_msi!\n"); + pci_disable_msi(pdev); + } + + pci_disable_device(pdev); + return; +} + +static const struct pci_device_id fpga_pci_ids[] = { + { PCI_DEVICE(0x10ee, 0x7022), .driver_data = XILINX_FPGA_USE_MSI}, + { PCI_DEVICE(0x10ee, 0x7011), .driver_data = XILINX_FPGA_NUSE_MSI}, + {0} +}; +MODULE_DEVICE_TABLE(pci, fpga_pci_ids); + +static struct pci_driver rg_fpga_pcie_driver = { + .name = "rg_fpga_pcie", + .id_table = fpga_pci_ids,/* only dynamic id's */ + .probe = fpga_pcie_probe, + .remove = fpga_pcie_remove, +}; + +static int __init rg_fpga_pcie_init(void) +{ + + FPGA_PCIE_DEV_VERBOSE("rg_fpga_pcie_init enter!\n"); + return pci_register_driver(&rg_fpga_pcie_driver); +} + +static void __exit rg_fpga_pcie_exit(void) +{ + FPGA_PCIE_DEV_VERBOSE("rg_fpga_pcie_exit enter!\n"); + pci_unregister_driver(&rg_fpga_pcie_driver); + return; +} + +module_init(rg_fpga_pcie_init); +module_exit(rg_fpga_pcie_exit); +MODULE_DESCRIPTION("fpga pcie driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_d1500.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_d1500.c new file mode 100644 index 000000000000..41c63ec195ce --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_d1500.c @@ -0,0 +1,367 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (C) 2011, 2012 Cavium Inc. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define GPIO_NAME "rg_gpio_d1500" + +#define GPIO_BASE (0x500) +#define GP_IO_SEL (GPIO_BASE + 0x4) +#define GP_LVL (GPIO_BASE + 0xC) +#define GPI_NMI_EN (GPIO_BASE + 0x28) +#define GPI_NMI_STS (GPIO_BASE + 0x2a) +#define GPI_INV (GPIO_BASE + 0x2c) +#define GPIO_USE_SEL2 (GPIO_BASE + 0x30) +#define GP_IO_SEL2 (GPIO_BASE + 0x34) +#define GP_LVL2 (GPIO_BASE + 0x38) +#define GPI_NMI_EN_2 (GPIO_BASE + 0x3c) +#define GPI_NMI_STS_2 (GPIO_BASE + 0x3e) +#define GPIO_USE_SEL3 (GPIO_BASE + 0x40) +#define GP_IO_SEL3 (GPIO_BASE + 0x44) +#define GP_LVL3 (GPIO_BASE + 0x48) +#define GPI_NMI_EN_3 (GPIO_BASE + 0x50) +#define GPI_NMI_STS_3 (GPIO_BASE + 0x54) + +#define GPIO_BASE_ID (0) +#define BANKSIZE (32) +#define D1500_GPIO_PIN_NUM (96) +#define CELL_NUM (2) + +int g_gpio_d1500_debug = 0; +int g_gpio_d1500_error = 0; +module_param(g_gpio_d1500_debug, int, S_IRUGO | S_IWUSR); +module_param(g_gpio_d1500_error, int, S_IRUGO | S_IWUSR); + +#define GPIO_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_gpio_d1500_debug) { \ + printk(KERN_ERR "[GPIO-D1500][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define GPIO_DEBUG_ERROR(fmt, args...) do { \ + if (g_gpio_d1500_error) { \ + printk(KERN_ERR "[GPIO-D1500][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static DEFINE_SPINLOCK(sio_lock); + +struct gpio_d1500_t { + struct gpio_chip chip; + u64 register_base; +}; + +static int rg_gpio_get(struct gpio_chip *gc, unsigned gpio_num) +{ + u32 data = 0; + unsigned int bank, offset; + unsigned long flags; + + bank = gpio_num / BANKSIZE; + offset = gpio_num % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GP_LVL) & (1 << offset); + if (data) { + data = 1; + } + } else if (bank == 1) { + data = inl(GP_LVL2) & (1 << offset); + if (data) { + data = 1; + } + } else if (bank == 2) { + data = inl(GP_LVL3) & (1 << offset); + if (data) { + data = 1; + } + } + spin_unlock_irqrestore(&sio_lock, flags); + + return data; +} + +static int rg_gpio_direction_in(struct gpio_chip *gc, unsigned gpio_num) +{ + u32 data; + unsigned int bank, offset; + unsigned long flags; + + bank = gpio_num / BANKSIZE; + offset = gpio_num % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GP_IO_SEL); + data = data | (1 << offset); + outl(data, GP_IO_SEL); + } else if (bank == 1) { + data = inl(GP_IO_SEL2); + data = data | (1 << offset); + outl(data, GP_IO_SEL2); + } else if (bank == 2) { + data = inl(GP_IO_SEL3); + data = data | (1 << offset); + outl(data, GP_IO_SEL3); + } + spin_unlock_irqrestore(&sio_lock, flags); + + return 0; +} + +static void rg_gpio_set(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u32 data; + unsigned int bank, offset; + unsigned long flags; + + bank = gpio_num / BANKSIZE; + offset = gpio_num % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GP_LVL); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL); + } else if (bank == 1) { + data = inl(GP_LVL2); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL2); + } else if (bank == 2) { + data = inl(GP_LVL3); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL3); + } + spin_unlock_irqrestore(&sio_lock, flags); + + return; +} + +static int rg_gpio_direction_out(struct gpio_chip *gc, + unsigned gpio_num, int val) +{ + u32 data; + unsigned int bank, offset; + unsigned long flags; + + bank = gpio_num / BANKSIZE; + offset = gpio_num % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GP_IO_SEL); + data = data & ~(1 << offset); + outl(data, GP_IO_SEL); + + data = inl(GP_LVL); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL); + } else if (bank == 1) { + data = inl(GP_IO_SEL2); + data = data & ~(1 << offset); + outl(data, GP_IO_SEL2); + + data = inl(GP_LVL2); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL2); + } else if (bank == 2) { + data = inl(GP_IO_SEL3); + data = data & ~(1 << offset); + outl(data, GP_IO_SEL3); + + data = inl(GP_LVL3); + if (val) { + data = data | (1 << offset); + } else { + data = data & ~(1 << offset); + } + outl(data, GP_LVL3); + } + spin_unlock_irqrestore(&sio_lock, flags); + + return 0; +} + +#ifdef CONFIG_OF +static int rg_gpio_of_xlate(struct gpio_chip *chip, + const struct of_phandle_args *gpio_desc, + u32 *flags) +{ + if (chip->of_gpio_n_cells < 2) { + return -EINVAL; + } + + if (flags) { + *flags = gpio_desc->args[1]; + } + + return gpio_desc->args[0]; +} +#endif + +static int rg_gpio_request(struct gpio_chip *chip, unsigned int offset) +{ + u32 data; + unsigned int bank, tmp_offset; + unsigned long flags; + + bank = offset / BANKSIZE; + tmp_offset = offset % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GPIO_BASE); + data = data | (1 << tmp_offset); + outl(data, GPIO_BASE); + } else if (bank == 1) { + data = inl(GPIO_USE_SEL2); + data = data | (1 << tmp_offset); + outl(data, GPIO_USE_SEL2); + } else if (bank == 2) { + data = inl(GPIO_USE_SEL3); + data = data | (1 << tmp_offset); + outl(data, GPIO_USE_SEL3); + } + spin_unlock_irqrestore(&sio_lock, flags); + + return 0; +} + +#if 0 +static void rg_gpio_free(struct gpio_chip *chip, unsigned int offset) +{ + u32 data; + unsigned int bank, tmp_offset; + unsigned long flags; + + bank = offset / BANKSIZE; + tmp_offset = offset % BANKSIZE; + + spin_lock_irqsave(&sio_lock, flags); + if (bank == 0) { + data = inl(GPIO_BASE); + data = data & ~(1 << tmp_offset); + outl(data, GPIO_BASE); + } else if (bank == 1) { + data = inl(GPIO_USE_SEL2); + data = data & ~(1 << tmp_offset); + outl(data, GPIO_USE_SEL2); + } else if (bank == 2) { + data = inl(GPIO_USE_SEL3); + data = data & ~(1 << tmp_offset); + outl(data, GPIO_USE_SEL3); + } + + spin_unlock_irqrestore(&sio_lock, flags); + + return; +} +#endif + +static struct gpio_chip rg_gpio_chip = { + .label = GPIO_NAME, + .owner = THIS_MODULE, + .base = GPIO_BASE_ID, + .get = rg_gpio_get, + .direction_input = rg_gpio_direction_in, + .set = rg_gpio_set, + .direction_output = rg_gpio_direction_out, +#ifdef CONFIG_OF + .of_xlate = rg_gpio_of_xlate, +#endif + .request = rg_gpio_request, + .ngpio = D1500_GPIO_PIN_NUM, +#ifdef CONFIG_OF + .of_gpio_n_cells = CELL_NUM, +#endif + .can_sleep = false, +}; + +static int rg_gpio_probe(struct platform_device *pdev) +{ + struct gpio_d1500_t *gpio; + int err; + + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); + if (!gpio) { + dev_err(&pdev->dev, "gpio kzalloc failed\n"); + return -ENOMEM; + } + + rg_gpio_chip.parent = &pdev->dev; + gpio->register_base = GPIO_BASE; + gpio->chip = rg_gpio_chip; + pdev->dev.platform_data = &rg_gpio_chip; + err = devm_gpiochip_add_data(&pdev->dev, &rg_gpio_chip, gpio); + if (err) { + dev_err(&pdev->dev, "gpiochip add failed\n"); + return err; + } + + dev_info(&pdev->dev, "register %llu gpio success.\n", gpio->register_base); + + return 0; +} + +static int rg_gpio_remove(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "unregister d1500 gpio success\n"); + return 0; +} + +static const struct of_device_id gpio_d1500_match[] = { + { + .compatible = "ruijie,rg_gpio_d1500", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, gpio_d1500_match); + +static struct platform_driver rg_gpio_driver = { + .driver = { + .name = GPIO_NAME, + .of_match_table = gpio_d1500_match, + }, + .probe = rg_gpio_probe, + .remove = rg_gpio_remove, +}; + +module_platform_driver(rg_gpio_driver); + +MODULE_DESCRIPTION("d1500 gpio driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_device.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_device.c new file mode 100644 index 000000000000..fccb813bbd2d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_gpio_device.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include + +static int g_rg_gpio_device_debug = 0; +static int g_rg_gpio_device_error = 0; + +module_param(g_rg_gpio_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_gpio_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_GPIO_DEVICE_VERBOSE(fmt, args...) do { \ + if (g_rg_gpio_device_debug) { \ + printk(KERN_INFO "[RG_GPIO_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_GPIO_DEVICE_ERROR(fmt, args...) do { \ + if (g_rg_gpio_device_error) { \ + printk(KERN_ERR "[RG_GPIO_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static void rg_gpio_device_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_gpio_d1500_device = { + .name = "rg_gpio_d1500", + .id = -1, + .dev = { + .release = rg_gpio_device_release, + }, +}; + +static int __init rg_gpio_device_init(void) +{ + RG_GPIO_DEVICE_VERBOSE("rg_gpio_device_init enter!\n"); + return platform_device_register(&rg_gpio_d1500_device); +} + +static void __exit rg_gpio_device_exit(void) +{ + RG_GPIO_DEVICE_VERBOSE("rg_gpio_device_exit enter!\n"); + return platform_device_unregister(&rg_gpio_d1500_device); +} + +module_init(rg_gpio_device_init); +module_exit(rg_gpio_device_exit); +MODULE_DESCRIPTION("GPIO Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.c new file mode 100644 index 000000000000..8fb1c75dfee4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.c @@ -0,0 +1,777 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + * + * rg_io_dev.c + * ko to read/write i2c client through /dev/XXX device + * Original Author: sonic_rd@ruijie.com.cn 2022-09-09 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_i2c_dev.h" + +#define MAX_I2C_DEV_NUM (256) +#define FPGA_MAX_LEN (256) +#define MAX_NAME_SIZE (20) +#define MAX_BUS_WIDTH (16) +#define TRANSFER_WRITE_BUFF (FPGA_MAX_LEN + MAX_BUS_WIDTH) + +#define WIDTH_1Byte (1) +#define WIDTH_2Byte (2) +#define WIDTH_4Byte (4) + +static int g_i2c_dev_debug = 0; +static int g_i2c_dev_error = 0; + +module_param(g_i2c_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_i2c_dev_error, int, S_IRUGO | S_IWUSR); + +#define I2C_DEV_DEBUG_DMESG(fmt, args...) do { \ + if (g_i2c_dev_debug) { \ + printk(KERN_ERR "[I2C_DEV][DEBUG][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define I2C_DEV_DEBUG_ERROR(fmt, args...) do { \ + if (g_i2c_dev_error) { \ + printk(KERN_ERR "[I2C_DEV][ERR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static struct i2c_dev_info* i2c_dev_arry[MAX_I2C_DEV_NUM]; + +struct i2c_dev_info { + const char *name; + uint32_t data_bus_width; + uint32_t addr_bus_width; + uint32_t per_rd_len; + uint32_t per_wr_len; + uint32_t i2c_len; + struct miscdevice misc; + struct i2c_client *client; +}; + +static int transfer_read(struct i2c_client *client, u8 *buf, loff_t regaddr, size_t count) +{ + struct i2c_adapter *adap; + int i; + u8 offset_buf[MAX_BUS_WIDTH]; + struct i2c_msg msgs[2]; + int msgs_num, ret; + struct i2c_dev_info *i2c_dev; + + if (!client) { + I2C_DEV_DEBUG_ERROR("can't get read client\n"); + return -ENODEV; + } + + adap = client->adapter; + if (!adap) { + I2C_DEV_DEBUG_ERROR("can't get read adap\n"); + return -ENODEV; + } + + i2c_dev = i2c_get_clientdata(client); + if (!i2c_dev) { + I2C_DEV_DEBUG_ERROR("can't get read i2c_dev\n"); + return -ENODEV; + } + + i = 0; + + memset(offset_buf, 0, sizeof(offset_buf)); + + switch (i2c_dev->addr_bus_width) { + case WIDTH_4Byte: + offset_buf[i++] = (regaddr >> 24) & 0xFF; + offset_buf[i++] = (regaddr >> 16) & 0xFF; + offset_buf[i++] = (regaddr >> 8) & 0xFF; + offset_buf[i++] = regaddr & 0xFF; + break; + case WIDTH_2Byte: + offset_buf[i++] = (regaddr >> 8) & 0xFF; + offset_buf[i++] = regaddr & 0xFF; + break; + case WIDTH_1Byte: + offset_buf[i++] = regaddr & 0xFF; + break; + default: + I2C_DEV_DEBUG_ERROR("Only support 1,2,4 Byte Address Width,but set width = %u\n", + i2c_dev->addr_bus_width); + return -EINVAL; + } + + if (adap->algo->master_xfer) { + memset(msgs, 0, sizeof(msgs)); + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = i2c_dev->addr_bus_width; + msgs[0].buf = offset_buf; + + msgs[1].addr = client->addr; + msgs[1].flags = I2C_M_RD; + msgs[1].len = count; + msgs[1].buf = buf; + + msgs_num = 2; + ret = i2c_transfer(client->adapter, msgs, msgs_num); + if (ret != msgs_num) { + I2C_DEV_DEBUG_ERROR("i2c_transfer read error\n"); + return -EINVAL; + } + } else { + I2C_DEV_DEBUG_ERROR("don't find read master_xfer\n"); + return -EINVAL; + + } + return 0; +} + +static int transfer_write(struct i2c_client *client, u8 *buf, loff_t regaddr, size_t count) +{ + struct i2c_adapter *adap; + int i; + u8 offset_buf[TRANSFER_WRITE_BUFF]; + struct i2c_msg msgs[1]; + int msgs_num, ret; + struct i2c_dev_info *i2c_dev; + + if (!client) { + I2C_DEV_DEBUG_ERROR("can't get write client\n"); + return -ENODEV; + } + + adap = client->adapter; + if (!adap) { + I2C_DEV_DEBUG_ERROR("can't get write adap\n"); + return -ENODEV; + } + + i2c_dev = i2c_get_clientdata(client); + if (!i2c_dev) { + I2C_DEV_DEBUG_ERROR("can't get read i2c_dev\n"); + return -ENODEV; + } + + i = 0; + + memset(offset_buf, 0, sizeof(offset_buf)); + + switch (i2c_dev->addr_bus_width) { + case WIDTH_4Byte: + offset_buf[i++] = (regaddr >> 24) & 0xFF; + offset_buf[i++] = (regaddr >> 16) & 0xFF; + offset_buf[i++] = (regaddr >> 8) & 0xFF; + offset_buf[i++] = regaddr & 0xFF; + break; + case WIDTH_2Byte: + offset_buf[i++] = (regaddr >> 8) & 0xFF; + offset_buf[i++] = regaddr & 0xFF; + break; + case WIDTH_1Byte: + offset_buf[i++] = regaddr & 0xFF; + break; + default: + I2C_DEV_DEBUG_ERROR("Only support 1,2,4 Byte Address Width,but set width = %u\n", + i2c_dev->addr_bus_width); + return -EINVAL; + } + + memcpy(offset_buf + i2c_dev->addr_bus_width, buf, count); + + if (adap->algo->master_xfer) { + memset(msgs, 0, sizeof(msgs)); + + msgs[0].addr = client->addr; + msgs[0].flags = 0; + msgs[0].len = i2c_dev->addr_bus_width + count; + msgs[0].buf = offset_buf; + + msgs_num = 1; + ret = i2c_transfer(adap, msgs, msgs_num); + if (ret != msgs_num) { + I2C_DEV_DEBUG_ERROR("i2c_transfer write error\n"); + return -EINVAL; + } + } else { + I2C_DEV_DEBUG_ERROR("don't find write master_xfer\n"); + return -EINVAL; + } + + return 0; +} + +static long i2c_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + return 0; +} + +static int i2c_dev_open(struct inode *inode, struct file *file) +{ + unsigned int minor = iminor(inode); + struct i2c_dev_info *i2c_dev; + + i2c_dev = i2c_dev_arry[minor]; + if (i2c_dev == NULL) { + return -ENODEV; + } + + file->private_data = i2c_dev; + + return 0; +} + +static int i2c_dev_release(struct inode *inode, struct file *file) +{ + file->private_data = NULL; + + return 0; +} + +static int device_read(struct i2c_dev_info *i2c_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int i, j, ret; + u8 tmp_offset; + u8 val[FPGA_MAX_LEN]; + u32 width, rd_len, per_len, tmp; + u32 max_per_len; + + if (offset > i2c_dev->i2c_len) { + I2C_DEV_DEBUG_DMESG("offset: 0x%x, i2c len: 0x%x, count: %lu, EOF.\n", + offset, i2c_dev->i2c_len, count); + return 0; + } + + if (count > (i2c_dev->i2c_len - offset)) { + I2C_DEV_DEBUG_DMESG("read count out of range. input len:%lu, read len:%u.\n", + count, i2c_dev->i2c_len - offset); + count = i2c_dev->i2c_len - offset; + } + + if (count == 0) { + I2C_DEV_DEBUG_DMESG("offset: 0x%x, i2c len: 0x%x, read len: %lu, EOF.\n", + offset, i2c_dev->i2c_len, count); + return 0; + } + + width = i2c_dev->data_bus_width; + switch (width) { + case WIDTH_4Byte: + tmp_offset = offset & 0x3; + if (tmp_offset) { + I2C_DEV_DEBUG_ERROR("data bus width:%u, offset:%u, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + break; + case WIDTH_2Byte: + tmp_offset = offset & 0x1; + if (tmp_offset) { + I2C_DEV_DEBUG_ERROR("data bus width:%u, offset:%u, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + break; + case WIDTH_1Byte: + break; + default: + I2C_DEV_DEBUG_ERROR("Only support 1,2,4 Byte Data Width,but set width = %u\n", width); + return -EINVAL; + } + + max_per_len = i2c_dev->per_rd_len; + tmp = (width - 1) & count; + rd_len = (tmp == 0) ? count : count + width - tmp; + per_len = (rd_len > max_per_len) ? (max_per_len) : (rd_len); + + memset(val, 0, sizeof(val)); + for (i = 0; i < rd_len; i += per_len) { + ret = transfer_read(i2c_dev->client, val + i, offset + i, per_len); + if (ret < 0) { + I2C_DEV_DEBUG_ERROR("read error.read offset = %u\n", (offset + i)); + return -EFAULT; + } + } + + if (width == WIDTH_1Byte) { + memcpy(buf, val, count); + } else { + for (i = 0; i < count; i += width) { + for (j = 0; (j < width) && (i + j < count); j++) { + buf[i + j] = val[i + width - j - 1]; + } + } + } + + return count; +} + +static int device_write(struct i2c_dev_info *i2c_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int i, j, ret; + u8 tmp_offset; + u32 width; + u8 val[FPGA_MAX_LEN]; + u32 wr_len, per_len, tmp; + u32 max_per_len; + + if (offset > i2c_dev->i2c_len) { + I2C_DEV_DEBUG_DMESG("offset: 0x%x, i2c len: 0x%x, count: %lu, EOF.\n", + offset, i2c_dev->i2c_len, count); + return 0; + } + + if (count > (i2c_dev->i2c_len - offset)) { + I2C_DEV_DEBUG_DMESG("read count out of range. input len:%lu, read len:%u.\n", + count, i2c_dev->i2c_len - offset); + count = i2c_dev->i2c_len - offset; + } + + if (count == 0) { + I2C_DEV_DEBUG_DMESG("offset: 0x%x, i2c len: 0x%x, read len: %lu, EOF.\n", + offset, i2c_dev->i2c_len, count); + return 0; + } + + width = i2c_dev->data_bus_width; + switch (width) { + case WIDTH_4Byte: + tmp_offset = offset & 0x3; + if (tmp_offset) { + I2C_DEV_DEBUG_ERROR("data bus width:%u, offset:%u, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + break; + case WIDTH_2Byte: + tmp_offset = offset & 0x1; + if (tmp_offset) { + I2C_DEV_DEBUG_ERROR("data bus width:%u, offset:%u, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + break; + case WIDTH_1Byte: + break; + default: + I2C_DEV_DEBUG_ERROR("Only support 1,2,4 Byte Data Width,but set width = %u\n", width); + return -EINVAL; + } + + memset(val, 0, sizeof(val)); + + if (width == WIDTH_1Byte) { + memcpy(val, buf, count); + } else { + for (i = 0; i < count; i += width) { + for (j = 0; (j < width) && (i + j < count); j++) { + val[i + width - j - 1] = buf[i + j]; + } + } + } + + max_per_len = i2c_dev->per_wr_len; + tmp = (width - 1) & count; + wr_len = (tmp == 0) ? count : count + width - tmp; + per_len = (wr_len > max_per_len) ? (max_per_len) : (wr_len); + + for (i = 0; i < wr_len; i += per_len) { + ret = transfer_write(i2c_dev->client, val + i, offset + i, per_len); + if (ret < 0) { + I2C_DEV_DEBUG_ERROR("write error.offset = %u\n", (offset + i)); + return -EFAULT; + } + } + return count; +} + +static ssize_t i2c_dev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +{ + u8 val[FPGA_MAX_LEN]; + int ret, read_len; + struct i2c_dev_info *i2c_dev; + + i2c_dev = file->private_data; + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("can't get read private_data.n"); + return -EINVAL; + } + + if (count == 0) { + I2C_DEV_DEBUG_ERROR("Invalid params, read count is 0.n"); + return -EINVAL; + } + + if (count > sizeof(val)) { + I2C_DEV_DEBUG_DMESG("read conut %lu exceed max %lu.\n", count, sizeof(val)); + count = sizeof(val); + } + + memset(val, 0, sizeof(val)); + read_len = device_read(i2c_dev, (uint32_t)*offset, val, count); + if (read_len < 0) { + I2C_DEV_DEBUG_ERROR("i2c dev read failed, dev name:%s, offset:0x%x, len:%lu.\n", + i2c_dev->name, (uint32_t)*offset, count); + return read_len; + } + + if (access_ok(buf, read_len)) { + I2C_DEV_DEBUG_DMESG("user space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + if (copy_to_user(buf, val, read_len)) { + I2C_DEV_DEBUG_ERROR("copy_to_user failed.\n"); + return -EFAULT; + } + } else { + I2C_DEV_DEBUG_DMESG("kernel space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + memcpy(buf, val, read_len); + } + + *offset += read_len; + ret = read_len; + return ret; +} + +static ssize_t i2c_dev_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + int ret; + + I2C_DEV_DEBUG_DMESG("i2c_dev_read_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, to->count, iocb->ki_pos); + ret = i2c_dev_read(iocb->ki_filp, to->kvec->iov_base, to->count, &iocb->ki_pos); + return ret; +} + +static ssize_t i2c_dev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) +{ + u8 val[FPGA_MAX_LEN]; + int write_len; + struct i2c_dev_info *i2c_dev; + + i2c_dev = file->private_data; + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("get write private_data error.\n"); + return -EINVAL; + } + + if (count == 0) { + I2C_DEV_DEBUG_ERROR("Invalid params, write count is 0.\n"); + return -EINVAL; + } + + if (count > sizeof(val)) { + I2C_DEV_DEBUG_DMESG("write conut %lu exceed max %lu.\n", count, sizeof(val)); + count = sizeof(val); + } + + memset(val, 0, sizeof(val)); + if (access_ok(buf, count)) { + I2C_DEV_DEBUG_DMESG("user space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + if (copy_from_user(val, buf, count)) { + I2C_DEV_DEBUG_ERROR("copy_from_user failed.\n"); + return -EFAULT; + } + } else { + I2C_DEV_DEBUG_DMESG("kernel space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + memcpy(val, buf, count); + } + + write_len = device_write(i2c_dev, (uint32_t)*offset, val, count); + if (write_len < 0) { + I2C_DEV_DEBUG_ERROR("i2c dev write failed, dev name:%s, offset:0x%llx, len:%lu.\n", + i2c_dev->name, *offset, count); + return write_len; + } + + *offset += write_len; + return write_len; +} + +static ssize_t i2c_dev_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + int ret; + + I2C_DEV_DEBUG_DMESG("i2c_dev_write_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, from->count, iocb->ki_pos); + ret = i2c_dev_write(iocb->ki_filp, from->kvec->iov_base, from->count, &iocb->ki_pos); + return ret; +} + +static loff_t i2c_dev_llseek(struct file *file, loff_t offset, int origin) +{ + loff_t ret = 0; + struct i2c_dev_info *i2c_dev; + + i2c_dev = file->private_data; + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("i2c_dev is NULL, llseek failed.\n"); + return -EINVAL; + } + + switch (origin) { + case SEEK_SET: + if (offset < 0) { + I2C_DEV_DEBUG_ERROR("SEEK_SET, offset:%lld, invalid.\n", offset); + ret = -EINVAL; + break; + } + if (offset > i2c_dev->i2c_len) { + I2C_DEV_DEBUG_ERROR("SEEK_SET out of range, offset:%lld, i2c_len:0x%x.\n", + offset, i2c_dev->i2c_len); + ret = - EINVAL; + break; + } + file->f_pos = offset; + ret = file->f_pos; + break; + case SEEK_CUR: + if (((file->f_pos + offset) > i2c_dev->i2c_len) || ((file->f_pos + offset) < 0)) { + I2C_DEV_DEBUG_ERROR("SEEK_CUR out of range, f_ops:%lld, offset:%lld, i2c_len:0x%x.\n", + file->f_pos, offset, i2c_dev->i2c_len); + ret = - EINVAL; + break; + } + file->f_pos += offset; + ret = file->f_pos; + break; + default: + I2C_DEV_DEBUG_ERROR("unsupport llseek type:%d.\n", origin); + ret = -EINVAL; + break; + } + return ret; +} + +static const struct file_operations i2c_dev_fops = { + .owner = THIS_MODULE, + .llseek = i2c_dev_llseek, + .read_iter = i2c_dev_read_iter, + .write_iter = i2c_dev_write_iter, + .unlocked_ioctl = i2c_dev_ioctl, + .open = i2c_dev_open, + .release = i2c_dev_release, +}; + +static struct i2c_dev_info * dev_match(const char *path) +{ + struct i2c_dev_info * i2c_dev; + char dev_name[MAX_NAME_SIZE]; + int i; + for (i = 0; i < MAX_I2C_DEV_NUM; i++) { + if (i2c_dev_arry[ i ] == NULL) { + continue; + } + i2c_dev = i2c_dev_arry[ i ]; + snprintf(dev_name, MAX_NAME_SIZE,"/dev/%s", i2c_dev->name); + if (!strcmp(path, dev_name)) { + I2C_DEV_DEBUG_DMESG("get dev_name = %s, minor = %d\n", dev_name, i); + return i2c_dev; + } + } + + return NULL; +} + +int i2c_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + struct i2c_dev_info *i2c_dev = NULL; + int ret; + + if(path == NULL){ + I2C_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if(buf == NULL){ + I2C_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + if (count > FPGA_MAX_LEN) { + I2C_DEV_DEBUG_ERROR("read conut %lu, beyond max:%d.\n", count, FPGA_MAX_LEN); + return -EINVAL; + } + + i2c_dev = dev_match(path); + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + ret = device_read(i2c_dev, offset, buf, count); + if (ret < 0) { + I2C_DEV_DEBUG_ERROR("fpga i2c dev read failed, dev name:%s, offset:0x%x, len:%lu.\n", + i2c_dev->name, offset, count); + return -EINVAL; + } + + return count; +} +EXPORT_SYMBOL(i2c_device_func_read); + +int i2c_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + struct i2c_dev_info *i2c_dev = NULL; + int ret; + + if(path == NULL){ + I2C_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if(buf == NULL){ + I2C_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + if (count > FPGA_MAX_LEN) { + I2C_DEV_DEBUG_ERROR("write conut %lu, beyond max:%d.\n", count, FPGA_MAX_LEN); + return -EINVAL; + } + + i2c_dev = dev_match(path); + if (i2c_dev == NULL) { + I2C_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + ret = device_write (i2c_dev, offset, buf, count); + if (ret < 0) { + I2C_DEV_DEBUG_ERROR("i2c dev write failed, dev name:%s, offset:0x%x, len:%lu.\n", + i2c_dev->name, offset, count); + return -EINVAL; + } + + return count; +} +EXPORT_SYMBOL(i2c_device_func_write); + +static int i2c_dev_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + int ret = 0; + struct i2c_dev_info *i2c_dev; + struct miscdevice *misc; + i2c_dev_device_t *i2c_dev_device; + + i2c_dev = devm_kzalloc(&client->dev, sizeof(struct i2c_dev_info), GFP_KERNEL); + if (!i2c_dev) { + dev_err(&client->dev, "devm_kzalloc error. \n"); + return -ENOMEM; + } + + i2c_set_clientdata(client, i2c_dev); + i2c_dev->client = client; + + if (client->dev.of_node) { + + ret += of_property_read_string(client->dev.of_node, "i2c_name", &i2c_dev->name); + ret += of_property_read_u32(client->dev.of_node, "data_bus_width", &i2c_dev->data_bus_width); + ret += of_property_read_u32(client->dev.of_node, "addr_bus_width", &i2c_dev->addr_bus_width); + ret += of_property_read_u32(client->dev.of_node, "per_rd_len", &i2c_dev->per_rd_len); + ret += of_property_read_u32(client->dev.of_node, "per_wr_len", &i2c_dev->per_wr_len); + ret += of_property_read_u32(client->dev.of_node, "i2c_len", &i2c_dev->i2c_len); + if (ret != 0) { + dev_err(&client->dev, "dts config error.ret:%d.\n", ret); + return -ENXIO; + } + } else { + if (client->dev.platform_data == NULL) { + dev_err(&client->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + i2c_dev_device = client->dev.platform_data; + i2c_dev->name = i2c_dev_device->i2c_name; + i2c_dev->data_bus_width = i2c_dev_device->data_bus_width; + i2c_dev->addr_bus_width = i2c_dev_device->addr_bus_width; + i2c_dev->per_rd_len = i2c_dev_device->per_rd_len; + i2c_dev->per_wr_len = i2c_dev_device->per_wr_len; + i2c_dev->i2c_len = i2c_dev_device->i2c_len; + } + + if ((i2c_dev->per_rd_len & (i2c_dev->data_bus_width - 1)) || + (i2c_dev->per_wr_len & (i2c_dev->data_bus_width - 1))) { + dev_err(&client->dev, "Invalid config per_rd_len %d per_wr_len %d data bus_width %d.\n", + i2c_dev->per_rd_len, i2c_dev->per_wr_len, i2c_dev->data_bus_width); + return -ENXIO; + } + + if ((i2c_dev->i2c_len == 0) || (i2c_dev->i2c_len & (i2c_dev->data_bus_width - 1))) { + dev_err(&client->dev, "Invalid config i2c_len %d, data bus_width %d.\n", + i2c_dev->i2c_len, i2c_dev->data_bus_width); + return -ENXIO; + } + + misc = &i2c_dev->misc; + misc->minor = MISC_DYNAMIC_MINOR; + misc->name = i2c_dev->name; + misc->fops = &i2c_dev_fops; + misc->mode = 0666; + if (misc_register(misc) != 0) { + dev_err(&client->dev, "register %s faild.\n", misc->name); + return -ENXIO; + } + + if (misc->minor >= MAX_I2C_DEV_NUM) { + dev_err(&client->dev, "minor number beyond the limit! is %d.\n", misc->minor); + misc_deregister(misc); + return -ENXIO; + } + i2c_dev_arry[misc->minor] = i2c_dev; + + dev_info(&client->dev, "register %u addr_bus_width %u data_bus_width 0x%x i2c_len device %s with %u per_rd_len %u per_wr_len success.\n", + i2c_dev->addr_bus_width, i2c_dev->data_bus_width, i2c_dev->i2c_len, i2c_dev->name, i2c_dev->per_rd_len, i2c_dev->per_wr_len); + + return 0; +} + +static int i2c_dev_remove(struct i2c_client *client) +{ + int i; + for (i = 0; i < MAX_I2C_DEV_NUM; i++) { + if (i2c_dev_arry[i] != NULL) { + misc_deregister(&i2c_dev_arry[i]->misc); + i2c_dev_arry[i] = NULL; + } + } + return 0; +} + +static const struct i2c_device_id i2c_dev_id[] = { + { "rg-i2c-dev", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, i2c_dev_id); + +static const struct of_device_id i2c_dev_of_match[] = { + { .compatible = "ruijie,rg-i2c-dev" }, + { }, +}; +MODULE_DEVICE_TABLE(of, i2c_dev_of_match); + +static struct i2c_driver i2c_dev_driver = { + .driver = { + .name = "rg-i2c-dev", + .of_match_table = i2c_dev_of_match, + }, + .probe = i2c_dev_probe, + .remove = i2c_dev_remove, + .id_table = i2c_dev_id, +}; +module_i2c_driver(i2c_dev_driver); + +MODULE_DESCRIPTION("i2c dev driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.h new file mode 100644 index 000000000000..1096a54613e7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_dev.h @@ -0,0 +1,18 @@ +#ifndef __RG_I2C_DEV_H__ +#define __RG_I2C_DEV_H__ + +#define I2C_DEV_NAME_MAX_LEN (64) + +typedef struct i2c_dev_device_s { + struct i2c_client *client; + uint32_t i2c_bus; + uint32_t i2c_addr; + char i2c_name[I2C_DEV_NAME_MAX_LEN]; + uint32_t data_bus_width; + uint32_t addr_bus_width; + uint32_t per_rd_len; + uint32_t per_wr_len; + uint32_t i2c_len; +} i2c_dev_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_gpio_device.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_gpio_device.c new file mode 100644 index 000000000000..2f81c7582260 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_i2c_gpio_device.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int gpio_sda = 17; +module_param(gpio_sda, int, S_IRUGO | S_IWUSR); + +static int gpio_scl = 1; +module_param(gpio_scl, int, S_IRUGO | S_IWUSR); + +static int gpio_udelay = 2; +module_param(gpio_udelay, int, S_IRUGO | S_IWUSR); + +static int g_rg_i2c_gpio_device_debug = 0; +static int g_rg_i2c_gpio_device_error = 0; + +module_param(g_rg_i2c_gpio_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_i2c_gpio_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_I2C_GPIO_DEVICE_VERBOSE(fmt, args...) do { \ + if (g_rg_i2c_gpio_device_debug) { \ + printk(KERN_INFO "[RG_I2C_GPIO_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_I2C_GPIO_DEVICE_ERROR(fmt, args...) do { \ + if (g_rg_i2c_gpio_device_error) { \ + printk(KERN_ERR "[RG_I2C_GPIO_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +/****************** i2c adapter with gpio ***********************/ +static struct i2c_gpio_platform_data i2c_pdata = { + .udelay = 2, + .scl_is_output_only = 0, + .sda_is_open_drain = 0, + .scl_is_open_drain = 0, +}; + +static void i2c_gpio_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_i2c_gpio_device = { + .name = "i2c-gpio", + .id = -1, + .num_resources = 0, + .resource = NULL, + .dev = { + .platform_data = &i2c_pdata, + .release = i2c_gpio_release, + }, +}; + +/* + * i2c + */ +static struct gpiod_lookup_table rg_i2c_gpio_table = { + .dev_id = "i2c-gpio", + .table = { + GPIO_LOOKUP_IDX("rg_gpio_d1500", 17, NULL, 0, + GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), + GPIO_LOOKUP_IDX("rg_gpio_d1500", 1, NULL, 1, + GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), + }, +}; + +static int __init rg_i2c_gpio_device_init(void) +{ + int err; + + RG_I2C_GPIO_DEVICE_VERBOSE("rg_i2c_gpio_device_init enter!\n"); + rg_i2c_gpio_table.table[0].chip_hwnum = gpio_sda; + rg_i2c_gpio_table.table[1].chip_hwnum = gpio_scl; + i2c_pdata.udelay = gpio_udelay; + gpiod_add_lookup_table(&rg_i2c_gpio_table); + + err = platform_device_register(&rg_i2c_gpio_device); + if (err < 0) { + printk(KERN_ERR "register i2c gpio device fail(%d). \n", err); + gpiod_remove_lookup_table(&rg_i2c_gpio_table); + return -1; + } + return 0; +} + +static void __exit rg_i2c_gpio_device_exit(void) +{ + RG_I2C_GPIO_DEVICE_VERBOSE("rg_i2c_gpio_device_exit enter!\n"); + platform_device_unregister(&rg_i2c_gpio_device); + gpiod_remove_lookup_table(&rg_i2c_gpio_table); +} + +module_init(rg_i2c_gpio_device_init); +module_exit(rg_i2c_gpio_device_exit); +MODULE_DESCRIPTION("I2C GPIO Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ina3221.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ina3221.c new file mode 100644 index 000000000000..36c8a1b26a2e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ina3221.c @@ -0,0 +1,445 @@ +/* + * INA3221 Triple Current/Voltage Monitor + * + * Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/ + * Andrew F. Davis + * + * 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. + * + * 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 + +#define INA3221_DRIVER_NAME "rg_ina3221" + +#define INA3221_CONFIG 0x00 +#define INA3221_SHUNT1 0x01 +#define INA3221_BUS1 0x02 +#define INA3221_SHUNT2 0x03 +#define INA3221_BUS2 0x04 +#define INA3221_SHUNT3 0x05 +#define INA3221_BUS3 0x06 +#define INA3221_CRIT1 0x07 +#define INA3221_WARN1 0x08 +#define INA3221_CRIT2 0x09 +#define INA3221_WARN2 0x0a +#define INA3221_CRIT3 0x0b +#define INA3221_WARN3 0x0c +#define INA3221_MASK_ENABLE 0x0f + +#define INA3221_CONFIG_MODE_SHUNT BIT(1) +#define INA3221_CONFIG_MODE_BUS BIT(2) +#define INA3221_CONFIG_MODE_CONTINUOUS BIT(3) + +#define INA3221_RSHUNT_DEFAULT 10000 + +enum ina3221_fields { + /* Configuration */ + F_RST, + + /* Alert Flags */ + F_WF3, F_WF2, F_WF1, + F_CF3, F_CF2, F_CF1, + + /* sentinel */ + F_MAX_FIELDS +}; + +static const struct reg_field ina3221_reg_fields[] = { + [F_RST] = REG_FIELD(INA3221_CONFIG, 15, 15), + + [F_WF3] = REG_FIELD(INA3221_MASK_ENABLE, 3, 3), + [F_WF2] = REG_FIELD(INA3221_MASK_ENABLE, 4, 4), + [F_WF1] = REG_FIELD(INA3221_MASK_ENABLE, 5, 5), + [F_CF3] = REG_FIELD(INA3221_MASK_ENABLE, 7, 7), + [F_CF2] = REG_FIELD(INA3221_MASK_ENABLE, 8, 8), + [F_CF1] = REG_FIELD(INA3221_MASK_ENABLE, 9, 9), +}; + +enum ina3221_channels { + INA3221_CHANNEL1, + INA3221_CHANNEL2, + INA3221_CHANNEL3, + INA3221_NUM_CHANNELS +}; + +static const unsigned int register_channel[] = { + [INA3221_SHUNT1] = INA3221_CHANNEL1, + [INA3221_SHUNT2] = INA3221_CHANNEL2, + [INA3221_SHUNT3] = INA3221_CHANNEL3, + [INA3221_CRIT1] = INA3221_CHANNEL1, + [INA3221_CRIT2] = INA3221_CHANNEL2, + [INA3221_CRIT3] = INA3221_CHANNEL3, + [INA3221_WARN1] = INA3221_CHANNEL1, + [INA3221_WARN2] = INA3221_CHANNEL2, + [INA3221_WARN3] = INA3221_CHANNEL3, +}; + +/** + * struct ina3221_data - device specific information + * @regmap: Register map of the device + * @fields: Register fields of the device + * @shunt_resistors: Array of resistor values per channel + */ +struct ina3221_data { + struct regmap *regmap; + struct regmap_field *fields[F_MAX_FIELDS]; + int shunt_resistors[INA3221_NUM_CHANNELS]; +}; + +static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg, + int *val) +{ + unsigned int regval; + int ret; + + ret = regmap_read(ina->regmap, reg, ®val); + if (ret) + return ret; + + *val = sign_extend32(regval >> 3, 12); + + return 0; +} + +static ssize_t ina3221_show_bus_voltage(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int reg = sd_attr->index; + int val, voltage_mv, ret; + + ret = ina3221_read_value(ina, reg, &val); + if (ret) + return ret; + + voltage_mv = val * 8; + + return snprintf(buf, PAGE_SIZE, "%d\n", voltage_mv); +} + +static ssize_t ina3221_show_shunt_voltage(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int reg = sd_attr->index; + int val, voltage_uv, ret; + + ret = ina3221_read_value(ina, reg, &val); + if (ret) + return ret; + voltage_uv = val * 40; + + return snprintf(buf, PAGE_SIZE, "%d\n", voltage_uv); +} + +static ssize_t ina3221_show_current(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int reg = sd_attr->index; + unsigned int channel = register_channel[reg]; + int resistance_uo = ina->shunt_resistors[channel]; + int val, current_ma, voltage_nv, ret; + + ret = ina3221_read_value(ina, reg, &val); + if (ret) + return ret; + voltage_nv = val * 40000; + + current_ma = DIV_ROUND_CLOSEST(voltage_nv, resistance_uo); + + return snprintf(buf, PAGE_SIZE, "%d\n", current_ma); +} + +static ssize_t ina3221_set_current(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int reg = sd_attr->index; + unsigned int channel = register_channel[reg]; + int resistance_uo = ina->shunt_resistors[channel]; + int val, current_ma, voltage_uv, ret; + + ret = kstrtoint(buf, 0, ¤t_ma); + if (ret) + return ret; + + /* clamp current */ + current_ma = clamp_val(current_ma, + INT_MIN / resistance_uo, + INT_MAX / resistance_uo); + + voltage_uv = DIV_ROUND_CLOSEST(current_ma * resistance_uo, 1000); + + /* clamp voltage */ + voltage_uv = clamp_val(voltage_uv, -163800, 163800); + + /* 1 / 40uV(scale) << 3(register shift) = 5 */ + val = DIV_ROUND_CLOSEST(voltage_uv, 5) & 0xfff8; + + ret = regmap_write(ina->regmap, reg, val); + if (ret) + return ret; + + return count; +} + +static ssize_t ina3221_show_shunt(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int channel = sd_attr->index; + unsigned int resistance_uo; + + resistance_uo = ina->shunt_resistors[channel]; + + return snprintf(buf, PAGE_SIZE, "%d\n", resistance_uo); +} + +static ssize_t ina3221_set_shunt(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int channel = sd_attr->index; + int val; + int ret; + + ret = kstrtoint(buf, 0, &val); + if (ret) + return ret; + + val = clamp_val(val, 1, INT_MAX); + + ina->shunt_resistors[channel] = val; + + return count; +} + +static ssize_t ina3221_show_alert(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); + struct ina3221_data *ina = dev_get_drvdata(dev); + unsigned int field = sd_attr->index; + unsigned int regval; + int ret; + + ret = regmap_field_read(ina->fields[field], ®val); + if (ret) + return ret; + + return snprintf(buf, PAGE_SIZE, "%d\n", regval); +} + +/* bus voltage */ +static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, + ina3221_show_bus_voltage, NULL, INA3221_BUS1); +static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, + ina3221_show_bus_voltage, NULL, INA3221_BUS2); +static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, + ina3221_show_bus_voltage, NULL, INA3221_BUS3); + +/* calculated current */ +static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, + ina3221_show_current, NULL, INA3221_SHUNT1); +static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, + ina3221_show_current, NULL, INA3221_SHUNT2); +static SENSOR_DEVICE_ATTR(curr3_input, S_IRUGO, + ina3221_show_current, NULL, INA3221_SHUNT3); + +/* shunt resistance */ +static SENSOR_DEVICE_ATTR(shunt1_resistor, S_IRUGO | S_IWUSR, + ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL1); +static SENSOR_DEVICE_ATTR(shunt2_resistor, S_IRUGO | S_IWUSR, + ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL2); +static SENSOR_DEVICE_ATTR(shunt3_resistor, S_IRUGO | S_IWUSR, + ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL3); + +/* critical current */ +static SENSOR_DEVICE_ATTR(curr1_crit, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_CRIT1); +static SENSOR_DEVICE_ATTR(curr2_crit, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_CRIT2); +static SENSOR_DEVICE_ATTR(curr3_crit, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_CRIT3); + +/* critical current alert */ +static SENSOR_DEVICE_ATTR(curr1_crit_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_CF1); +static SENSOR_DEVICE_ATTR(curr2_crit_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_CF2); +static SENSOR_DEVICE_ATTR(curr3_crit_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_CF3); + +/* warning current */ +static SENSOR_DEVICE_ATTR(curr1_max, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_WARN1); +static SENSOR_DEVICE_ATTR(curr2_max, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_WARN2); +static SENSOR_DEVICE_ATTR(curr3_max, S_IRUGO | S_IWUSR, + ina3221_show_current, ina3221_set_current, INA3221_WARN3); + +/* warning current alert */ +static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_WF1); +static SENSOR_DEVICE_ATTR(curr2_max_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_WF2); +static SENSOR_DEVICE_ATTR(curr3_max_alarm, S_IRUGO, + ina3221_show_alert, NULL, F_WF3); + +/* shunt voltage */ +static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, + ina3221_show_shunt_voltage, NULL, INA3221_SHUNT1); +static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, + ina3221_show_shunt_voltage, NULL, INA3221_SHUNT2); +static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, + ina3221_show_shunt_voltage, NULL, INA3221_SHUNT3); + +static struct attribute *ina3221_attrs[] = { + /* channel 1 */ + &sensor_dev_attr_in1_input.dev_attr.attr, + &sensor_dev_attr_curr1_input.dev_attr.attr, + &sensor_dev_attr_shunt1_resistor.dev_attr.attr, + &sensor_dev_attr_curr1_crit.dev_attr.attr, + &sensor_dev_attr_curr1_crit_alarm.dev_attr.attr, + &sensor_dev_attr_curr1_max.dev_attr.attr, + &sensor_dev_attr_curr1_max_alarm.dev_attr.attr, + &sensor_dev_attr_in4_input.dev_attr.attr, + + /* channel 2 */ + &sensor_dev_attr_in2_input.dev_attr.attr, + &sensor_dev_attr_curr2_input.dev_attr.attr, + &sensor_dev_attr_shunt2_resistor.dev_attr.attr, + &sensor_dev_attr_curr2_crit.dev_attr.attr, + &sensor_dev_attr_curr2_crit_alarm.dev_attr.attr, + &sensor_dev_attr_curr2_max.dev_attr.attr, + &sensor_dev_attr_curr2_max_alarm.dev_attr.attr, + &sensor_dev_attr_in5_input.dev_attr.attr, + + /* channel 3 */ + &sensor_dev_attr_in3_input.dev_attr.attr, + &sensor_dev_attr_curr3_input.dev_attr.attr, + &sensor_dev_attr_shunt3_resistor.dev_attr.attr, + &sensor_dev_attr_curr3_crit.dev_attr.attr, + &sensor_dev_attr_curr3_crit_alarm.dev_attr.attr, + &sensor_dev_attr_curr3_max.dev_attr.attr, + &sensor_dev_attr_curr3_max_alarm.dev_attr.attr, + &sensor_dev_attr_in6_input.dev_attr.attr, + + NULL, +}; +ATTRIBUTE_GROUPS(ina3221); + +static const struct regmap_range ina3221_yes_ranges[] = { + regmap_reg_range(INA3221_SHUNT1, INA3221_BUS3), + regmap_reg_range(INA3221_MASK_ENABLE, INA3221_MASK_ENABLE), +}; + +static const struct regmap_access_table ina3221_volatile_table = { + .yes_ranges = ina3221_yes_ranges, + .n_yes_ranges = ARRAY_SIZE(ina3221_yes_ranges), +}; + +static const struct regmap_config ina3221_regmap_config = { + .reg_bits = 8, + .val_bits = 16, + + .cache_type = REGCACHE_RBTREE, + .volatile_table = &ina3221_volatile_table, +}; + +static int ina3221_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct device *dev = &client->dev; + struct ina3221_data *ina; + struct device *hwmon_dev; + int i, ret; + + ina = devm_kzalloc(dev, sizeof(*ina), GFP_KERNEL); + if (!ina) + return -ENOMEM; + + ina->regmap = devm_regmap_init_i2c(client, &ina3221_regmap_config); + if (IS_ERR(ina->regmap)) { + dev_err(dev, "Unable to allocate register map\n"); + return PTR_ERR(ina->regmap); + } + + for (i = 0; i < F_MAX_FIELDS; i++) { + ina->fields[i] = devm_regmap_field_alloc(dev, + ina->regmap, + ina3221_reg_fields[i]); + if (IS_ERR(ina->fields[i])) { + dev_err(dev, "Unable to allocate regmap fields\n"); + return PTR_ERR(ina->fields[i]); + } + } + + for (i = 0; i < INA3221_NUM_CHANNELS; i++) + ina->shunt_resistors[i] = INA3221_RSHUNT_DEFAULT; + + ret = regmap_field_write(ina->fields[F_RST], true); + if (ret) { + dev_err(dev, "Unable to reset device\n"); + return ret; + } + + hwmon_dev = devm_hwmon_device_register_with_groups(dev, + client->name, + ina, ina3221_groups); + if (IS_ERR(hwmon_dev)) { + dev_err(dev, "Unable to register hwmon device\n"); + return PTR_ERR(hwmon_dev); + } + + return 0; +} + +static const struct of_device_id ina3221_of_match_table[] = { + { .compatible = "ruijie,rg_ina3221", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ina3221_of_match_table); + +static const struct i2c_device_id ina3221_ids[] = { + { "rg_ina3221", 0 }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(i2c, ina3221_ids); + +static struct i2c_driver ina3221_i2c_driver = { + .probe = ina3221_probe, + .driver = { + .name = INA3221_DRIVER_NAME, + .of_match_table = ina3221_of_match_table, + }, + .id_table = ina3221_ids, +}; +module_i2c_driver(ina3221_i2c_driver); + +MODULE_AUTHOR("Andrew F. Davis "); +MODULE_DESCRIPTION("Texas Instruments INA3221 HWMon Driver"); +MODULE_LICENSE("GPL v2"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.c new file mode 100644 index 000000000000..5fa050a7dc7a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.c @@ -0,0 +1,574 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + * + * rg_io_dev.c + * ko to read/write ioports through /dev/XXX device + * Original Author: sonic_rd@ruijie.com.cn 2022-09-09 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_io_dev.h" + +#define PROXY_NAME "rg-io-dev" +#define MAX_IO_DEV_NUM (256) +#define IO_RDWR_MAX_LEN (256) +#define MAX_NAME_SIZE (20) +#define IO_INDIRECT_ADDR_H(addr) ((addr >> 8) & 0xff) +#define IO_INDIRECT_ADDR_L(addr) ((addr) & 0xff) +#define IO_INDIRECT_OP_WRITE (0x2) +#define IO_INDIRECT_OP_READ (0X3) + +static int g_io_dev_debug = 0; +static int g_io_dev_error = 0; + +module_param(g_io_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_io_dev_error, int, S_IRUGO | S_IWUSR); + +#define IO_DEV_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_io_dev_debug) { \ + printk(KERN_INFO "[IO_DEV][VER][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define IO_DEV_DEBUG_ERROR(fmt, args...) do { \ + if (g_io_dev_error) { \ + printk(KERN_ERR "[IO_DEV][ERR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef struct rg_io_dev_s { + const char *name; + uint32_t io_base; + uint32_t io_len; + uint32_t indirect_addr; + uint32_t wr_data; + uint32_t addr_low; + uint32_t addr_high; + uint32_t rd_data; + uint32_t opt_ctl; + spinlock_t io_dev_lock; + struct miscdevice misc; +} rg_io_dev_t; + +static rg_io_dev_t* io_dev_arry[MAX_IO_DEV_NUM]; + +static int io_dev_open(struct inode *inode, struct file *file) +{ + unsigned int minor = iminor(inode); + rg_io_dev_t *rg_io_dev; + + if (minor >= MAX_IO_DEV_NUM) { + IO_DEV_DEBUG_ERROR("minor out of range, minor = %d.\n", minor); + return -ENODEV; + } + + rg_io_dev = io_dev_arry[minor]; + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("rg_io_dev is NULL, open failed, minor = %d\n", minor); + return -ENODEV; + } + + file->private_data = rg_io_dev; + return 0; +} + +static int io_dev_release(struct inode *inode, struct file *file) +{ + file->private_data = NULL; + return 0; +} + +uint8_t io_indirect_addressing_read(rg_io_dev_t *rg_io_dev, uint32_t address) +{ + uint8_t addr_l, addr_h, value; + unsigned long flags; + + addr_h = IO_INDIRECT_ADDR_H(address); + addr_l = IO_INDIRECT_ADDR_L(address); + IO_DEV_DEBUG_VERBOSE("read one count, addr = 0x%x\n", address); + + spin_lock_irqsave(&rg_io_dev->io_dev_lock, flags); + + outb(addr_l, rg_io_dev->io_base + rg_io_dev->addr_low); + + outb(addr_h, rg_io_dev->io_base + rg_io_dev->addr_high); + + outb(IO_INDIRECT_OP_READ, rg_io_dev->io_base + rg_io_dev->opt_ctl); + + value = inb(rg_io_dev->io_base + rg_io_dev->rd_data); + + spin_unlock_irqrestore(&rg_io_dev->io_dev_lock, flags); + + return value; +} + +static int io_dev_read_tmp(rg_io_dev_t *rg_io_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int i; + + if (offset > rg_io_dev->io_len) { + IO_DEV_DEBUG_VERBOSE("offset:0x%x, io len:0x%x, EOF.\n", offset, rg_io_dev->io_len); + return 0; + } + + if (count > rg_io_dev->io_len - offset) { + IO_DEV_DEBUG_VERBOSE("read count out of range. input len:%lu, read len:%u.\n", + count, rg_io_dev->io_len - offset); + count = rg_io_dev->io_len - offset; + } + if (rg_io_dev->indirect_addr) { + for (i = 0; i < count; i++) { + buf[i] = io_indirect_addressing_read(rg_io_dev, offset + i); + } + } else { + for (i = 0; i < count; i++) { + buf[i] = inb(rg_io_dev->io_base + offset + i); + } + } + + return count; +} + +static ssize_t io_dev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +{ + rg_io_dev_t *rg_io_dev; + int ret, read_len; + u8 buf_tmp[IO_RDWR_MAX_LEN]; + + rg_io_dev = file->private_data; + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("rg_io_dev is NULL, read failed.\n"); + return -EINVAL; + } + + if (count == 0) { + IO_DEV_DEBUG_ERROR("Invalid params, read count is 0.n"); + return -EINVAL; + } + + if (count > sizeof(buf_tmp)) { + IO_DEV_DEBUG_VERBOSE("read conut %lu exceed max %lu.\n", count, sizeof(buf_tmp)); + count = sizeof(buf_tmp); + } + + memset(buf_tmp, 0, sizeof(buf_tmp)); + read_len = io_dev_read_tmp(rg_io_dev, *offset, buf_tmp, count); + if (read_len < 0) { + IO_DEV_DEBUG_ERROR("io_dev_read_tmp failed, ret:%d.\n", read_len); + return read_len; + } + + if (access_ok(buf, read_len)) { + IO_DEV_DEBUG_VERBOSE("user space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + if (copy_to_user(buf, buf_tmp, read_len)) { + IO_DEV_DEBUG_ERROR("copy_to_user failed.\n"); + return -EFAULT; + } + } else { + IO_DEV_DEBUG_VERBOSE("kernel space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + memcpy(buf, buf_tmp, read_len); + } + *offset += read_len; + ret = read_len; + return ret; +} + +static ssize_t io_dev_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + int ret; + + IO_DEV_DEBUG_VERBOSE("io_dev_read_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, to->count, iocb->ki_pos); + ret = io_dev_read(iocb->ki_filp, to->kvec->iov_base, to->count, &iocb->ki_pos); + return ret; +} + +void io_indirect_addressing_write(rg_io_dev_t *rg_io_dev, uint32_t address, uint8_t reg_val) +{ + uint8_t addr_l, addr_h; + unsigned long flags; + + addr_h = IO_INDIRECT_ADDR_H(address); + addr_l = IO_INDIRECT_ADDR_L(address); + IO_DEV_DEBUG_VERBOSE("write one count, addr = 0x%x\n", address); + + spin_lock_irqsave(&rg_io_dev->io_dev_lock, flags); + + outb(reg_val, rg_io_dev->io_base + rg_io_dev->wr_data); + + outb(addr_l, rg_io_dev->io_base + rg_io_dev->addr_low); + + outb(addr_h, rg_io_dev->io_base + rg_io_dev->addr_high); + + outb(IO_INDIRECT_OP_WRITE, rg_io_dev->io_base + rg_io_dev->opt_ctl); + + spin_unlock_irqrestore(&rg_io_dev->io_dev_lock, flags); + + return; +} + +static int io_dev_write_tmp(rg_io_dev_t *rg_io_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int i; + + if (offset > rg_io_dev->io_len) { + IO_DEV_DEBUG_VERBOSE("offset:0x%x, io len:0x%x, EOF.\n", offset, rg_io_dev->io_len); + return 0; + } + + if (count > rg_io_dev->io_len - offset) { + IO_DEV_DEBUG_VERBOSE("write count out of range. input len:%lu, write len:%u.\n", + count, rg_io_dev->io_len - offset); + count = rg_io_dev->io_len - offset; + } + if (rg_io_dev->indirect_addr) { + for (i = 0; i < count; i++) { + io_indirect_addressing_write(rg_io_dev, offset + i, buf[i]); + } + } else { + for (i = 0; i < count; i++) { + outb(buf[i], rg_io_dev->io_base + offset + i); + } + } + + return count; +} + +static ssize_t io_dev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) +{ + rg_io_dev_t *rg_io_dev; + int write_len; + u8 buf_tmp[IO_RDWR_MAX_LEN]; + + rg_io_dev = file->private_data; + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("rg_io_dev is NULL, write failed.\n"); + return -EINVAL; + } + + if (count == 0) { + IO_DEV_DEBUG_ERROR("Invalid params, write count is 0.\n"); + return -EINVAL; + } + + if (count > sizeof(buf_tmp)) { + IO_DEV_DEBUG_VERBOSE("write conut %lu exceed max %lu.\n", count, sizeof(buf_tmp)); + count = sizeof(buf_tmp); + } + + memset(buf_tmp, 0, sizeof(buf_tmp)); + if (access_ok(buf, count)) { + IO_DEV_DEBUG_VERBOSE("user space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + if (copy_from_user(buf_tmp, buf, count)) { + IO_DEV_DEBUG_ERROR("copy_from_user failed.\n"); + return -EFAULT; + } + } else { + IO_DEV_DEBUG_VERBOSE("kernel space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + memcpy(buf_tmp, buf, count); + } + + write_len = io_dev_write_tmp(rg_io_dev, *offset, buf_tmp, count); + if (write_len < 0) { + IO_DEV_DEBUG_ERROR("io_dev_write_tmp failed, ret:%d.\n", write_len); + return write_len; + } + + *offset += write_len; + return write_len; +} + +static ssize_t io_dev_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + int ret; + + IO_DEV_DEBUG_VERBOSE("io_dev_write_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, from->count, iocb->ki_pos); + ret = io_dev_write(iocb->ki_filp, from->kvec->iov_base, from->count, &iocb->ki_pos); + return ret; +} + +static loff_t io_dev_llseek(struct file *file, loff_t offset, int origin) +{ + loff_t ret = 0; + rg_io_dev_t *rg_io_dev; + + rg_io_dev = file->private_data; + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("rg_io_dev is NULL, llseek failed.\n"); + return -EINVAL; + } + + switch (origin) { + case SEEK_SET: + if (offset < 0) { + IO_DEV_DEBUG_ERROR("SEEK_SET, offset:%lld, invalid.\n", offset); + ret = -EINVAL; + break; + } + if (offset > rg_io_dev->io_len) { + IO_DEV_DEBUG_ERROR("SEEK_SET out of range, offset:%lld, io_len:0x%x.\n", + offset, rg_io_dev->io_len); + ret = - EINVAL; + break; + } + file->f_pos = offset; + ret = file->f_pos; + break; + case SEEK_CUR: + if (((file->f_pos + offset) > rg_io_dev->io_len) || ((file->f_pos + offset) < 0)) { + IO_DEV_DEBUG_ERROR("SEEK_CUR out of range, f_ops:%lld, offset:%lld, io_len:0x%x.\n", + file->f_pos, offset, rg_io_dev->io_len); + ret = - EINVAL; + break; + } + file->f_pos += offset; + ret = file->f_pos; + break; + default: + IO_DEV_DEBUG_ERROR("unsupport llseek type:%d.\n", origin); + ret = -EINVAL; + break; + } + return ret; +} + +static long io_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + return 0; +} + +static const struct file_operations io_dev_fops = { + .owner = THIS_MODULE, + .llseek = io_dev_llseek, + .read_iter = io_dev_read_iter, + .write_iter = io_dev_write_iter, + .unlocked_ioctl = io_dev_ioctl, + .open = io_dev_open, + .release = io_dev_release, +}; + +static rg_io_dev_t *dev_match(const char *path) +{ + rg_io_dev_t *rg_io_dev; + char dev_name[MAX_NAME_SIZE]; + int i; + + for (i = 0; i < MAX_IO_DEV_NUM; i++) { + if (io_dev_arry[i] == NULL) { + continue; + } + rg_io_dev = io_dev_arry[i]; + snprintf(dev_name, MAX_NAME_SIZE,"/dev/%s", rg_io_dev->name); + if (!strcmp(path, dev_name)) { + IO_DEV_DEBUG_VERBOSE("get dev_name = %s, minor = %d\n", dev_name, i); + return rg_io_dev; + } + } + + return NULL; +} + +int io_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + rg_io_dev_t *rg_io_dev; + int read_len; + + if (path == NULL) { + IO_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if (buf == NULL) { + IO_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + rg_io_dev = dev_match(path); + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("io_dev match failed. dev path = %s", path); + return -EINVAL; + } + + read_len = io_dev_read_tmp(rg_io_dev, offset, buf, count); + if (read_len < 0) { + IO_DEV_DEBUG_ERROR("io_dev_read_tmp failed, ret:%d.\n", read_len); + } + return read_len; +} +EXPORT_SYMBOL(io_device_func_read); + +int io_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + rg_io_dev_t *rg_io_dev; + int write_len; + + if (path == NULL) { + IO_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if (buf == NULL) { + IO_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + rg_io_dev = dev_match(path); + if (rg_io_dev == NULL) { + IO_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + write_len = io_dev_write_tmp(rg_io_dev, offset, buf, count); + if (write_len < 0) { + IO_DEV_DEBUG_ERROR("io_dev_write_tmp failed, ret:%d.\n", write_len); + } + return write_len; +} +EXPORT_SYMBOL(io_device_func_write); + +static int io_dev_probe(struct platform_device *pdev) +{ + int ret; + rg_io_dev_t *rg_io_dev; + struct miscdevice *misc; + io_dev_device_t *io_dev_device; + + rg_io_dev = devm_kzalloc(&pdev->dev, sizeof(rg_io_dev_t), GFP_KERNEL); + if (!rg_io_dev) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + ret = -ENOMEM; + return ret; + } + spin_lock_init(&rg_io_dev->io_dev_lock); + + if (pdev->dev.of_node) { + ret = 0; + ret += of_property_read_string(pdev->dev.of_node, "io_dev_name", &rg_io_dev->name); + ret += of_property_read_u32(pdev->dev.of_node, "io_base", &rg_io_dev->io_base); + ret += of_property_read_u32(pdev->dev.of_node, "io_len", &rg_io_dev->io_len); + if (of_property_read_bool(pdev->dev.of_node, "indirect_addr")) { + + rg_io_dev->indirect_addr = 1; + ret += of_property_read_u32(pdev->dev.of_node, "wr_data", &rg_io_dev->wr_data); + ret += of_property_read_u32(pdev->dev.of_node, "addr_low", &rg_io_dev->addr_low); + ret += of_property_read_u32(pdev->dev.of_node, "addr_high", &rg_io_dev->addr_high); + ret += of_property_read_u32(pdev->dev.of_node, "rd_data", &rg_io_dev->rd_data); + ret += of_property_read_u32(pdev->dev.of_node, "opt_ctl", &rg_io_dev->opt_ctl); + } else { + + rg_io_dev->indirect_addr = 0; + } + if (ret != 0) { + dev_err(&pdev->dev, "Failed to get dts config, ret:%d.\n", ret); + return -ENXIO; + } + } else { + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + io_dev_device = pdev->dev.platform_data; + rg_io_dev->name = io_dev_device->io_dev_name; + rg_io_dev->io_base = io_dev_device->io_base; + rg_io_dev->io_len = io_dev_device->io_len; + rg_io_dev->indirect_addr = io_dev_device->indirect_addr; + if (rg_io_dev->indirect_addr == 1) { + rg_io_dev->wr_data = io_dev_device->wr_data; + rg_io_dev->addr_low = io_dev_device->addr_low; + rg_io_dev->addr_high = io_dev_device->addr_high; + rg_io_dev->rd_data = io_dev_device->rd_data; + rg_io_dev->opt_ctl = io_dev_device->opt_ctl; + } + } + + IO_DEV_DEBUG_VERBOSE("name:%s, io base:0x%x, io len:0x%x, addressing type:%s.\n", + rg_io_dev->name, rg_io_dev->io_base, rg_io_dev->io_len, + rg_io_dev->indirect_addr ? "indirect" : "direct"); + + misc = &rg_io_dev->misc; + misc->minor = MISC_DYNAMIC_MINOR; + misc->name = rg_io_dev->name; + misc->fops = &io_dev_fops; + misc->mode = 0666; + if (misc_register(misc) != 0) { + dev_err(&pdev->dev, "Failed to register %s device.\n", misc->name); + return -ENXIO; + } + if (misc->minor >= MAX_IO_DEV_NUM) { + dev_err(&pdev->dev, "Error: device minor[%d] more than max io device num[%d].\n", + misc->minor, MAX_IO_DEV_NUM); + misc_deregister(misc); + return -EINVAL; + } + io_dev_arry[misc->minor] = rg_io_dev; + dev_info(&pdev->dev, "register %s device [0x%x][0x%x] with minor %d using %s addressing success.\n", + misc->name, rg_io_dev->io_base, rg_io_dev->io_len, misc->minor, + rg_io_dev->indirect_addr ? "indirect" : "direct"); + + return 0; +} + +static int io_dev_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < MAX_IO_DEV_NUM ; i++) { + if (io_dev_arry[i] != NULL) { + misc_deregister(&io_dev_arry[i]->misc); + io_dev_arry[i] = NULL; + } + } + + return 0; +} + +static struct of_device_id io_dev_match[] = { + { + .compatible = "ruijie,rg-io-dev", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, io_dev_match); + +static struct platform_driver rg_io_dev_driver = { + .probe = io_dev_probe, + .remove = io_dev_remove, + .driver = { + .owner = THIS_MODULE, + .name = PROXY_NAME, + .of_match_table = io_dev_match, + }, +}; + +static int __init rg_io_dev_init(void) +{ + return platform_driver_register(&rg_io_dev_driver); +} + +static void __exit rg_io_dev_exit(void) +{ + platform_driver_unregister(&rg_io_dev_driver); +} + +module_init(rg_io_dev_init); +module_exit(rg_io_dev_exit); +MODULE_DESCRIPTION("IO device driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.h new file mode 100644 index 000000000000..6414fd112a30 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_io_dev.h @@ -0,0 +1,19 @@ +#ifndef __RG_IO_DEV_H__ +#define __RG_IO_DEV_H__ + +#define IO_DEV_NAME_MAX_LEN (64) + +typedef struct io_dev_device_s { + char io_dev_name[IO_DEV_NAME_MAX_LEN]; + uint32_t io_base; + uint32_t io_len; + uint32_t indirect_addr; + uint32_t wr_data; + uint32_t addr_low; + uint32_t addr_high; + uint32_t rd_data; + uint32_t opt_ctl; + int device_flag; +} io_dev_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.c new file mode 100644 index 000000000000..40841ccae8fc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.c @@ -0,0 +1,169 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * rg_lpc_drv.c + * ko to set lpc pcie config io addr and enable lpc + * Original Author: sonic_rd@ruijie.com.cn 2020-08-14 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_lpc_drv.h" + +#define LPC_DRIVER_NAME "rg-lpc" +#define LPC_MAKE_PCI_IO_RANGE(__base) ((0xfc0001) | ((__base) & (0xFFFC))) + +int g_lpc_dev_debug = 0; +int g_lpc_dev_error = 0; + +module_param(g_lpc_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_lpc_dev_error, int, S_IRUGO | S_IWUSR); + +#define LPC_DEV_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_lpc_dev_debug) { \ + printk(KERN_INFO "[LPC_DEV][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define LPC_DEV_DEBUG_ERROR(fmt, args...) do { \ + if (g_lpc_dev_error) { \ + printk(KERN_ERR "[LPC_DEV][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef struct rg_lpc_dev_s { + const char *lpc_io_name; + uint32_t domain; + uint32_t bus; + uint32_t slot; + uint32_t fn; + uint32_t lpc_io_base; + uint32_t lpc_io_size; + uint32_t lpc_gen_dec; +} rg_lpc_dev_t; + +static int rg_lpc_probe(struct platform_device *pdev) +{ + int ret, devfn; + rg_lpc_dev_t *rg_lpc_dev; + struct pci_dev *pci_dev; + lpc_drv_device_t *lpc_drv_device; + + rg_lpc_dev = devm_kzalloc(&pdev->dev, sizeof(rg_lpc_dev_t), GFP_KERNEL); + if (!rg_lpc_dev) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + ret = -ENOMEM; + return ret; + } + + if (pdev->dev.of_node) { + ret = 0; + ret += of_property_read_string(pdev->dev.of_node, "lpc_io_name", &rg_lpc_dev->lpc_io_name); + ret += of_property_read_u32(pdev->dev.of_node, "pci_domain", &rg_lpc_dev->domain); + ret += of_property_read_u32(pdev->dev.of_node, "pci_bus", &rg_lpc_dev->bus); + ret += of_property_read_u32(pdev->dev.of_node, "pci_slot", &rg_lpc_dev->slot); + ret += of_property_read_u32(pdev->dev.of_node, "pci_fn", &rg_lpc_dev->fn); + ret += of_property_read_u32(pdev->dev.of_node, "lpc_io_base", &rg_lpc_dev->lpc_io_base); + ret += of_property_read_u32(pdev->dev.of_node, "lpc_io_size", &rg_lpc_dev->lpc_io_size); + ret += of_property_read_u32(pdev->dev.of_node, "lpc_gen_dec", &rg_lpc_dev->lpc_gen_dec); + if (ret != 0) { + dev_err(&pdev->dev, "Failed to get dts config, ret:%d.\n", ret); + return -ENXIO; + } + } else { + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + lpc_drv_device = pdev->dev.platform_data; + rg_lpc_dev->lpc_io_name = lpc_drv_device->lpc_io_name; + rg_lpc_dev->domain = lpc_drv_device->pci_domain; + rg_lpc_dev->bus = lpc_drv_device->pci_bus; + rg_lpc_dev->slot = lpc_drv_device->pci_slot; + rg_lpc_dev->fn = lpc_drv_device->pci_fn; + rg_lpc_dev->lpc_io_base = lpc_drv_device->lpc_io_base; + rg_lpc_dev->lpc_io_size = lpc_drv_device->lpc_io_size; + rg_lpc_dev->lpc_gen_dec = lpc_drv_device->lpc_gen_dec; + } + + LPC_DEV_DEBUG_VERBOSE("domain:0x%04x, bus:0x%02x, slot:0x%02x, fn:%u\n", + rg_lpc_dev->domain,rg_lpc_dev->bus, rg_lpc_dev->slot, rg_lpc_dev->fn); + LPC_DEV_DEBUG_VERBOSE("lpc_io_name:%s, lpc_io_base:0x%x, lpc_io_size:%u, lpc_gen_dec:0x%x.\n", + rg_lpc_dev->lpc_io_name, rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size, rg_lpc_dev->lpc_gen_dec); + + devfn = PCI_DEVFN(rg_lpc_dev->slot, rg_lpc_dev->fn); + pci_dev = pci_get_domain_bus_and_slot(rg_lpc_dev->domain, rg_lpc_dev->bus, devfn); + if (pci_dev == NULL) { + dev_err(&pdev->dev, "Failed to find pci_dev, domain:0x%04x, bus:0x%02x, devfn:0x%x\n", + rg_lpc_dev->domain, rg_lpc_dev->bus, devfn); + return -ENXIO; + } + + pci_write_config_dword(pci_dev, rg_lpc_dev->lpc_gen_dec, LPC_MAKE_PCI_IO_RANGE(rg_lpc_dev->lpc_io_base)); + if (!request_region(rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size, rg_lpc_dev->lpc_io_name)) { + dev_err(&pdev->dev, "Failed to request_region [0x%x][0x%x].\n", rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size); + return -EBUSY; + } + + platform_set_drvdata(pdev, rg_lpc_dev); + + dev_info(&pdev->dev, "lpc request_region [0x%x][0x%x] success.\n", rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size); + + return 0; +} + +static int rg_lpc_remove(struct platform_device *pdev) +{ + rg_lpc_dev_t *rg_lpc_dev; + + rg_lpc_dev = platform_get_drvdata(pdev); + if (rg_lpc_dev) { + release_region(rg_lpc_dev->lpc_io_base , rg_lpc_dev->lpc_io_size); + LPC_DEV_DEBUG_VERBOSE("lpc base:0x%x, len:0x%x.\n", rg_lpc_dev->lpc_io_base, rg_lpc_dev->lpc_io_size); + } + LPC_DEV_DEBUG_VERBOSE("lpc remove.\n"); + + return 0; +} + +static struct of_device_id lpc_dev_match[] = { + { + .compatible = "ruijie,rg-lpc", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, lpc_dev_match); + +static struct platform_driver rg_lpc_driver = { + .probe = rg_lpc_probe, + .remove = rg_lpc_remove, + .driver = { + .owner = THIS_MODULE, + .name = LPC_DRIVER_NAME, + .of_match_table = lpc_dev_match, + }, +}; + +static int __init rg_lpc_init(void) +{ + return platform_driver_register(&rg_lpc_driver); +} + +static void __exit rg_lpc_exit(void) +{ + platform_driver_unregister(&rg_lpc_driver); +} + +module_init(rg_lpc_init); +module_exit(rg_lpc_exit); +MODULE_DESCRIPTION("lpc driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.h new file mode 100644 index 000000000000..ed978c728296 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_lpc_drv.h @@ -0,0 +1,18 @@ +#ifndef __RG_LPC_DRV_H__ +#define __RG_LPC_DRV_H__ + +#define LPC_IO_NAME_MAX_LEN (64) + +typedef struct lpc_drv_device_s { + char lpc_io_name[LPC_IO_NAME_MAX_LEN]; + int pci_domain; + int pci_bus; + int pci_slot; + int pci_fn; + int lpc_io_base; + int lpc_io_size; + int lpc_gen_dec; + int device_flag; +} lpc_drv_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_mac_bsc.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_mac_bsc.c new file mode 100644 index 000000000000..e148a709d699 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_mac_bsc.c @@ -0,0 +1,658 @@ +/* + * rg_mac_th3.c - A driver for control rg_mac_th3 base on rg_mac.c + * + * Copyright (c) 1998, 1999 Frodo Looijaard + * Copyright (c) 2018 ruijie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAC_TEMP_INVALID (99999999) + +#define MAC_SIZE (256) +#define MAC_TEMP_NUM (16) + +#define MAC_ID_REG (0x02000000) + +typedef enum { + DBG_START, + DBG_VERBOSE, + DBG_KEY, + DBG_WARN, + DBG_ERROR, + DBG_END, +} dbg_level_t; + +typedef enum{ + MAC_TYPE_START, + TD4_X9 = 0xb780, + TD4_X9_8 = 0xb788, + TH3 = 0xb980, + TD3 = 0xb870, + TD4 = 0xb880, + TH4 = 0xb990, + MAC_TYPE_END, +} mac_type; + +typedef struct sensor_regs_s { + int id; + u32 reg; +} sensor_reg_t; + +typedef struct mac_temp_regs_s { + int mac_type; + sensor_reg_t sensor_reg[MAC_TEMP_NUM]; +} mac_temp_reg_t; + +typedef enum { + MAC_TEMP_START, + MAC_TEMP_INDEX1, + MAC_TEMP_INDEX2, + MAC_TEMP_INDEX3, + MAC_TEMP_INDEX4, + MAC_TEMP_INDEX5, + MAC_TEMP_INDEX6, + MAC_TEMP_INDEX7, + MAC_TEMP_INDEX8, + MAC_TEMP_INDEX9, + MAC_TEMP_INDEX10, + MAC_TEMP_INDEX11, + MAC_TEMP_INDEX12, + MAC_TEMP_INDEX13, + MAC_TEMP_INDEX14, + MAC_TEMP_INDEX15, + MAC_TEMP_END, +} mac_hwmon_index; + +static mac_temp_reg_t mac_temp_reg[] = { + { + /* TD3 */ + .mac_type = TD3, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02004700}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02004800}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02004900}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02004a00}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02004b00}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02004c00}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02004d00}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02004e00}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02005200}, + {.id = MAC_TEMP_INDEX10, .reg = 0x02005100}, + {.id = MAC_TEMP_INDEX11, .reg = 0x02005000}, + {.id = MAC_TEMP_INDEX12, .reg = 0x02004f00}, + }, + }, + { + /* TD4 */ + .mac_type = TD4, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02004900}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02004b00}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02004d00}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02004f00}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02005100}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02005300}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02005500}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02005700}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02005900}, + {.id = MAC_TEMP_INDEX10, .reg = 0x02005b00}, + {.id = MAC_TEMP_INDEX11, .reg = 0x02005d00}, + {.id = MAC_TEMP_INDEX12, .reg = 0x02005f00}, + {.id = MAC_TEMP_INDEX13, .reg = 0x02006100}, + {.id = MAC_TEMP_INDEX14, .reg = 0x02006300}, + {.id = MAC_TEMP_INDEX15, .reg = 0x02006500}, + }, + }, + { + /* TD4_X9 */ + .mac_type = TD4_X9, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02005a00}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02005c00}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02005e00}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02006000}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02006200}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02006400}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02006600}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02006800}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02006a00}, + }, + }, + { + /* TD4_X9_8 */ + .mac_type = TD4_X9_8, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02005a00}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02005c00}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02005e00}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02006000}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02006200}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02006400}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02006600}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02006800}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02006a00}, + }, + }, + { + /* TH3 */ + .mac_type = TH3, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x02004a00}, + {.id = MAC_TEMP_INDEX2, .reg = 0x02004b00}, + {.id = MAC_TEMP_INDEX3, .reg = 0x02004c00}, + {.id = MAC_TEMP_INDEX4, .reg = 0x02004d00}, + {.id = MAC_TEMP_INDEX5, .reg = 0x02004e00}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02004f00}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02005000}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02005100}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02005200}, + {.id = MAC_TEMP_INDEX10, .reg = 0x02005300}, + {.id = MAC_TEMP_INDEX11, .reg = 0x02005400}, + {.id = MAC_TEMP_INDEX12, .reg = 0x02005500}, + {.id = MAC_TEMP_INDEX13, .reg = 0x02005600}, + {.id = MAC_TEMP_INDEX14, .reg = 0x02005700}, + {.id = MAC_TEMP_INDEX15, .reg = 0x02005800}, + }, + }, + { + /* TH4 */ + .mac_type = TH4, + .sensor_reg = { + {.id = MAC_TEMP_INDEX1, .reg = 0x0201d800}, + {.id = MAC_TEMP_INDEX2, .reg = 0x0201e000}, + {.id = MAC_TEMP_INDEX3, .reg = 0x0201e800}, + {.id = MAC_TEMP_INDEX4, .reg = 0x0201f000}, + {.id = MAC_TEMP_INDEX5, .reg = 0x0201f800}, + {.id = MAC_TEMP_INDEX6, .reg = 0x02020000}, + {.id = MAC_TEMP_INDEX7, .reg = 0x02020800}, + {.id = MAC_TEMP_INDEX8, .reg = 0x02021000}, + {.id = MAC_TEMP_INDEX9, .reg = 0x02021800}, + {.id = MAC_TEMP_INDEX10, .reg = 0x02022000}, + {.id = MAC_TEMP_INDEX11, .reg = 0x02022800}, + {.id = MAC_TEMP_INDEX12, .reg = 0x02023000}, + {.id = MAC_TEMP_INDEX13, .reg = 0x02023800}, + {.id = MAC_TEMP_INDEX14, .reg = 0x02024000}, + {.id = MAC_TEMP_INDEX15, .reg = 0x02024800}, + }, + }, +}; + +static int debuglevel = 0; +module_param(debuglevel, int, S_IRUGO | S_IWUSR); + +static int mac_pcie_id = MAC_TYPE_START; +module_param(mac_pcie_id, int, S_IRUGO | S_IWUSR); + +#define DBG_DEBUG(fmt, arg...) do { \ + if ( debuglevel > DBG_START && debuglevel < DBG_ERROR) { \ + printk(KERN_INFO "[DEBUG]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } else if ( debuglevel >= DBG_ERROR ) { \ + printk(KERN_ERR "[DEBUG]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } else { } \ +} while (0) + +#define DBG_ERROR(fmt, arg...) do { \ + if ( debuglevel > DBG_START) { \ + printk(KERN_ERR "[ERROR]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } \ + } while (0) + +struct mac_data { + struct i2c_client *client; + struct device *hwmon_dev; + struct mutex update_lock; + u8 data[MAC_SIZE]; /* Register value */ +}; + +static int rg_i2c_read_one_time(struct i2c_client *client, u8 *recv_buf, int size) +{ + struct i2c_msg msgs[2]; + int ret = 0; + + if ((client == NULL) || (recv_buf == NULL)) { + DBG_DEBUG("i2c_client || recv_buf = NULL\r\n"); + return -1; + } + + memset(msgs, 0, sizeof(msgs)); + + msgs[0].buf = recv_buf; + msgs[0].len = size; + msgs[0].addr = client->addr; + msgs[0].flags |= I2C_M_RD; + + ret = i2c_transfer(client->adapter, msgs, 1); + if (ret < 0) { + return ret; + } + DBG_DEBUG("i2c_transfer, dev_addr 0x%x, size %d.\n", client->addr, size); + + return 0; +} + +static int rg_i2c_write_one_time(struct i2c_client *client, u8 *write_buf, int size) +{ + struct i2c_msg msgs[2]; + int ret = 0; + + if ((client == NULL) || (write_buf == NULL)) { + DBG_DEBUG("i2c_client || write_buf = NULL\r\n"); + return -1; + } + + if ((size <= 0)) { + DBG_DEBUG("size invalid, size %d\n", size); + return -1; + } + + memset(msgs, 0, sizeof(msgs)); + + msgs[0].len = size; + msgs[0].buf = write_buf; + msgs[0].addr = client->addr; + + ret = i2c_transfer(client->adapter, msgs, 1); + if (ret < 0) { + return ret; + } + DBG_DEBUG("i2c_transfer, dev_addr 0x%x, size %d\n", client->addr, size); + + return 0; +} + +static u8 step2_buf1[8] = {0x03, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00}; +static u8 step2_buf2[8] = {0x03, 0x21, 0x04, 0x0c, 0x2c, 0x38, 0x02, 0x00}; +static u8 step2_buf3[8] = {0x03, 0x21, 0x04, 0x10, 0x02, 0x00, 0x4a, 0x00}; +static u8 step2_buf4[8] = {0x03, 0x21, 0x04, 0x00, 0x00, 0x00, 0x00, 0x01}; +static u8 step2_buf5[4] = {0x03, 0x21, 0x04, 0x08}; +static u8 step2_buf6[4] = {0x03, 0x21, 0x04, 0x10}; + +static int getmac_register(struct i2c_client *client, u32 index, int *reg_value) +{ + int i; + int ret = 0; + int value = 0; + unsigned char read_buf[8]; + + if (index == 0) { + DBG_ERROR("invalid index\n"); + return -1; + } + + step2_buf3[7] = index & 0xff; + step2_buf3[6] = (index >> 8) & 0xff; + step2_buf3[5] = (index >> 16) & 0xff; + step2_buf3[4] = (index >> 24) & 0xff; + + ret = rg_i2c_write_one_time(client, step2_buf1, 8); + if (ret < 0) { + DBG_ERROR("write step2_buf1 failed, ret = %d\n", ret); + } + ret = rg_i2c_write_one_time(client, step2_buf2, 8); + if (ret < 0) { + DBG_ERROR("write step2_buf2 failed, ret = %d\n", ret); + } + ret = rg_i2c_write_one_time(client, step2_buf3, 8); + if (ret < 0) { + DBG_ERROR("write step2_buf3 failed, ret = %d\n", ret); + } + ret = rg_i2c_write_one_time(client, step2_buf4, 8); + if (ret < 0) { + DBG_ERROR("write step2_buf4 failed, ret = %d\n", ret); + } + + ret = rg_i2c_write_one_time(client, step2_buf5, 4); + if (ret < 0) { + DBG_ERROR("write step2_buf5 failed, ret = %d\n", ret); + } + ret = rg_i2c_read_one_time(client, read_buf, 4); + if (ret < 0) { + DBG_ERROR("read failed, ret = %d\n", ret); + } + for (i = 0; i < 4; i++) { + DBG_DEBUG("read_buf[%d] = 0x%x \n", i, read_buf[i]); + } + + ret = rg_i2c_write_one_time(client, step2_buf6, 4); + if (ret < 0) { + DBG_ERROR("write step2_buf6 failed, ret = %d\n", ret); + } + + ret = rg_i2c_read_one_time(client, read_buf, 4); + if (ret < 0) { + DBG_ERROR("read failed, ret = %d\n", ret); + return ret; + } + + value = (read_buf[0] << 24)| (read_buf[1] << 16) | (read_buf[2] << 8) | read_buf[3]; + *reg_value = value; + + return ret; +} + +static int mac_calcute(u32 reg, int *temp) +{ + int ret = 0; + u32 tmp = 0; + + switch(mac_pcie_id) { + case TD3: + case TH3: + tmp = reg & 0x3ff; + *temp = 434100 - (tmp * 535); + break; + case TD4: + case TH4: + case TD4_X9: + case TD4_X9_8: + tmp = reg & 0x7ff; + *temp = (356070 - (tmp * 237)); + break; + default: + ret = -1; + DBG_ERROR("read failed, ret = %d\n", ret); + break; + } + + if ((*temp / 1000 < -70) || (*temp / 1000 > 200)) { + ret = -1; + DBG_ERROR("mac temp invalid, temp = %d\n", *temp ); + } + + return ret; +} + +static int find_reg_type(int type, int *type_index) +{ + int i; + int size; + + size = ARRAY_SIZE(mac_temp_reg); + for (i = 0; i < size; i++) { + if (mac_temp_reg[i].mac_type == type) { + *type_index = i; + return 0; + } + } + + return -1; +} + +static sensor_reg_t * find_reg_offset(int type, int index) +{ + int i; + int type_index; + int ret; + + ret = find_reg_type(type, &type_index); + if (ret < 0) { + DBG_ERROR("find_reg_type failed, ret = %d\n", ret); + return NULL; + } + + for (i = 0; i < MAC_TEMP_NUM; i++) { + if (mac_temp_reg[type_index].sensor_reg[i].id == index) { + return &(mac_temp_reg[type_index].sensor_reg[i]); + } + } + + return NULL; +} + +static int get_mactemp(struct i2c_client *client, int index, int *temp) +{ + int ret; + int reg_value; + + if (index == 0) { + DBG_ERROR("invalid index\n"); + return -1; + } + + ret = getmac_register(client, index, ®_value); + if (ret < 0) { + DBG_ERROR("getmac_register failed, ret = %d\n", ret); + return ret; + } + DBG_DEBUG("reg_value = 0x%x \n", reg_value); + + ret = mac_calcute(reg_value, temp); + if (ret < 0) { + DBG_ERROR("mac_calcute failed, ret = %d\n", ret); + return ret; + } + + return 0; +} + +static ssize_t show_mac_temp(struct device *dev, struct device_attribute *da, char *buf) +{ + struct mac_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; + u32 index_value = to_sensor_dev_attr_2(da)->index; + sensor_reg_t *t; + int result = 0; + int temp = -MAC_TEMP_INVALID; + + mutex_lock(&data->update_lock); + t = find_reg_offset(mac_pcie_id, index_value); + if (t == NULL) { + temp = -MAC_TEMP_INVALID; + DBG_ERROR("find_reg_offset failed, mac_pcie_id = %d, index_value = %d\n", mac_pcie_id, index_value); + } else { + result = get_mactemp(client, t->reg, &temp); + if (result < 0) { + temp = -MAC_TEMP_INVALID; + DBG_ERROR("get_mactemp failed, ret = %d\n", result); + } + } + + mutex_unlock(&data->update_lock); + return snprintf(buf, MAC_SIZE, "%d\n", temp); +} + +static ssize_t show_mac_max_temp(struct device *dev, struct device_attribute *da, char *buf) +{ + struct mac_data *data = dev_get_drvdata(dev); + struct i2c_client *client = data->client; + int i; + int result; + int temp = -MAC_TEMP_INVALID; + int type_index; + int tmp; + + mutex_lock(&data->update_lock); + + result = find_reg_type(mac_pcie_id, &type_index); + if (result < 0) { + DBG_ERROR("find_reg_type failed, ret = %d\n", result); + goto exit; + } + + for (i = 0; i < MAC_TEMP_NUM; i++) { + result = get_mactemp(client, mac_temp_reg[type_index].sensor_reg[i].reg, &tmp); + if (result < 0) { + DBG_ERROR("get_mactemp failed, ret = %d\n", result); + tmp = -MAC_TEMP_INVALID; + } + + temp = (temp > tmp) ? temp : tmp; + } + +exit: + mutex_unlock(&data->update_lock); + return snprintf(buf, MAC_SIZE, "%d\n", temp); +} + +static int mac_bsc_init(struct i2c_client *client) +{ + int ret; + int reg_value; + int mac_id = 0; + + ret = getmac_register(client, MAC_ID_REG, ®_value); + if (ret < 0) { + DBG_ERROR("getmac_register failed, ret = %d\n", ret); + return ret; + } + + DBG_DEBUG("reg_value = 0x%x \n", reg_value); + mac_id = reg_value & 0xffff; + return mac_id; +} + +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX1); +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX2); +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX3); +static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX4); +static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX5); +static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX6); +static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX7); +static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX8); +static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX9); +static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX10); +static SENSOR_DEVICE_ATTR(temp11_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX11); +static SENSOR_DEVICE_ATTR(temp12_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX12); +static SENSOR_DEVICE_ATTR(temp13_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX13); +static SENSOR_DEVICE_ATTR(temp14_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX14); +static SENSOR_DEVICE_ATTR(temp15_input, S_IRUGO, show_mac_temp, NULL, MAC_TEMP_INDEX15); +static SENSOR_DEVICE_ATTR(temp99_input, S_IRUGO, show_mac_max_temp, NULL, 0); + +static struct attribute *mac_hwmon_attrs[] = { + &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_temp7_input.dev_attr.attr, + &sensor_dev_attr_temp8_input.dev_attr.attr, + &sensor_dev_attr_temp9_input.dev_attr.attr, + &sensor_dev_attr_temp10_input.dev_attr.attr, + &sensor_dev_attr_temp11_input.dev_attr.attr, + &sensor_dev_attr_temp12_input.dev_attr.attr, + &sensor_dev_attr_temp13_input.dev_attr.attr, + &sensor_dev_attr_temp14_input.dev_attr.attr, + &sensor_dev_attr_temp15_input.dev_attr.attr, + &sensor_dev_attr_temp99_input.dev_attr.attr, + NULL +}; +ATTRIBUTE_GROUPS(mac_hwmon); + +static int init_bcs_command(int mac_type) { + int ret; + + ret = 0; + switch (mac_type) { + case TD3: + step2_buf2[5] = 0x38; + break; + case TH3: + case TH4: + case TD4: + case TD4_X9: + case TD4_X9_8: + step2_buf2[5] = 0x40; + break; + default: + ret = -1; + break; + } + return ret; +} + +static int mac_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct mac_data *data; + int mac_type; + int ret; + + mac_type = id->driver_data; + mac_pcie_id = mac_type; + if (init_bcs_command(mac_type) < 0) { + DBG_ERROR("mactype[%x] not support \n", mac_type); + return -1; + }; + + if (mac_type == TD4) { + ret = mac_bsc_init(client); + if (ret < 0) { + DBG_ERROR("mac_bsc_init failed, ret = %d\n", ret); + return -1; + } + mac_type = ret; + mac_pcie_id = mac_type; + } + + DBG_DEBUG("=========mac_probe(%x)===========\n",client->addr); + DBG_DEBUG("mac_type: %x\n", mac_type); + data = devm_kzalloc(&client->dev, sizeof(struct mac_data), GFP_KERNEL); + if (!data) { + return -ENOMEM; + } + + data->client = client; + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + + data->hwmon_dev = hwmon_device_register_with_groups(&client->dev, client->name, data, mac_hwmon_groups); + if (IS_ERR(data->hwmon_dev)) { + return PTR_ERR(data->hwmon_dev); + } + + return 0; +} + +static int mac_remove(struct i2c_client *client) +{ + struct mac_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + return 0; +} + +static const struct i2c_device_id mac_id[] = { + { "rg_mac_bsc_td3", TD3 }, + { "rg_mac_bsc_td4", TD4 }, + { "rg_mac_bsc_th3", TH3 }, + { "rg_mac_bsc_th4", TH4 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, mac_id); + +static struct i2c_driver rg_mac_bsc_driver = { + .driver = { + .name = "rg_mac_bsc", + }, + .probe = mac_probe, + .remove = mac_remove, + .id_table = mac_id, +}; + +module_i2c_driver(rg_mac_bsc_driver); + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("ruijie mac bsc driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_optoe.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_optoe.c new file mode 100644 index 000000000000..fb0e5cec8a27 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_optoe.c @@ -0,0 +1,1190 @@ +/* + * 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 = 50; + +/* + * 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[] = { + { "rg_optoe1", ONE_ADDR }, + { "rg_optoe2", TWO_ADDR }, + { "rg_optoe3", CMIS_ADDR }, + { "rg_sff8436", ONE_ADDR }, + { "rg_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; + + /* 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; + uint8_t loc; + 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); + + ret = optoe_eeprom_read(optoe, client, &loc, OPTOE_PAGE_SELECT_REG, 1); + if (ret < 0) { + dev_dbg(&client->dev, "Read page register for get now location page failed. ret:%d\n", ret); + return ret; + } + + /* Only when read and now location page is inconsistent, will doing switch page */ + if (loc != page) { + 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; + } + + 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_device(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->client[1] = NULL; + } + 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, "rg_optoe1") == 0) || + (strcmp(client->name, "rg_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, "rg_optoe2") == 0) || + (strcmp(client->name, "rg_24c04") == 0)) { + /* SFP family */ + optoe->dev_class = TWO_ADDR; + chip.byte_len = TWO_ADDR_EEPROM_SIZE; + num_addresses = 2; + } else if (strcmp(client->name, "rg_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_device(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]); + optoe->client[1] = NULL; + } + } + + 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 = "rg_optoe", + .owner = THIS_MODULE, + }, + .probe = optoe_probe, + .remove = optoe_remove, + .id_table = optoe_ids, +}; + +static int __init optoe_init(void) +{ + + if (!io_limit) { + pr_err("optoe: io_limit must not be 0!\n"); + return -EINVAL; + } + + io_limit = rounddown_pow_of_two(io_limit); + return i2c_add_driver(&optoe_driver); +} +module_init(optoe_init); + +static void __exit optoe_exit(void) +{ + i2c_del_driver(&optoe_driver); +} +module_exit(optoe_exit); + +MODULE_DESCRIPTION("Driver for optical transceiver (SFP, QSFP, ...) EEPROMs"); +MODULE_AUTHOR("DON BOLLINGER "); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.c new file mode 100644 index 000000000000..006568de5160 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.c @@ -0,0 +1,773 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + * + * rg_pcie_dev.c + * ko to read/write pcie iomem and ioports through /dev/XXX device + * Original Author: sonic_rd@ruijie.com.cn 2022-09-09 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_pcie_dev.h" + +#define PROXY_NAME "rg-pci-dev" +#define MAX_NAME_SIZE (20) +#define MAX_PCIE_NUM (256) +#define PCI_RDWR_MAX_LEN (256) +#define PCIE_BUS_WIDTH_1 (1) +#define PCIE_BUS_WIDTH_2 (2) +#define PCIE_BUS_WIDTH_4 (4) + +static int g_pcie_dev_debug = 0; +static int g_pcie_dev_error = 0; + +module_param(g_pcie_dev_debug, int, S_IRUGO | S_IWUSR); +module_param(g_pcie_dev_error, int, S_IRUGO | S_IWUSR); + +#define PCIE_DEV_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_pcie_dev_debug) { \ + printk(KERN_INFO "[PCIE_DEV][VER][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define PCIE_DEV_DEBUG_ERROR(fmt, args...) do { \ + if (g_pcie_dev_error) { \ + printk(KERN_ERR "[PCIE_DEV][ERR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef struct firmware_upg_s { + int upg_ctrl_base; + int upg_flash_base; +} firmware_upg_t; + +typedef struct rg_pci_dev_s { + const char *name; + uint32_t domain; + uint32_t bus; + uint32_t slot; + uint32_t fn; + uint32_t bar; + void __iomem *pci_mem_base; + uint32_t pci_io_base; + uint32_t bar_len; + uint32_t bar_flag; + uint32_t bus_width; + struct miscdevice misc; + void (*setreg)(struct rg_pci_dev_s *rg_pci_dev, int reg, u32 value); + u32 (*getreg)(struct rg_pci_dev_s *rg_pci_dev, int reg); + firmware_upg_t firmware_upg; +} rg_pci_dev_t; + +static rg_pci_dev_t* pcie_dev_arry[MAX_PCIE_NUM]; + +static void pci_dev_setreg_8(rg_pci_dev_t *rg_pci_dev, int reg, u32 value) +{ + u8 w_value; + + w_value = (u8)(value & 0xff); + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + writeb(w_value, rg_pci_dev->pci_mem_base + reg); + } else { + outb(w_value, rg_pci_dev->pci_io_base + reg); + } + return; +} + +static void pci_dev_setreg_16(rg_pci_dev_t *rg_pci_dev, int reg, u32 value) +{ + u16 w_value; + + w_value = (u16)(value & 0xffff); + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + writew(w_value, rg_pci_dev->pci_mem_base + reg); + } else { + outw(w_value, rg_pci_dev->pci_io_base + reg); + } + + return; +} + +static void pci_dev_setreg_32(rg_pci_dev_t *rg_pci_dev, int reg, u32 value) +{ + + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + writel(value, rg_pci_dev->pci_mem_base + reg); + } else { + outl(value, rg_pci_dev->pci_io_base + reg); + } + return; +} + +static inline u32 pci_dev_getreg_8(rg_pci_dev_t *rg_pci_dev, int reg) +{ + u32 value; + + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + value = readb(rg_pci_dev->pci_mem_base + reg); + } else { + value = inb(rg_pci_dev->pci_io_base + reg); + } + + return value; +} + +static inline u32 pci_dev_getreg_16(rg_pci_dev_t *rg_pci_dev, int reg) +{ + u32 value; + + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + value = readw(rg_pci_dev->pci_mem_base + reg); + } else { + value = inw(rg_pci_dev->pci_io_base + reg); + } + + return value; +} + +static inline u32 pci_dev_getreg_32(rg_pci_dev_t *rg_pci_dev, int reg) +{ + u32 value; + + if (rg_pci_dev->bar_flag == IORESOURCE_MEM) { + value = readl(rg_pci_dev->pci_mem_base + reg); + } else { + value = inl(rg_pci_dev->pci_io_base + reg); + } + + return value; +} + +static inline void pci_dev_setreg(rg_pci_dev_t *rg_pci_dev, int reg, u32 value) +{ + rg_pci_dev->setreg(rg_pci_dev, reg, value); +} + +static inline u32 pci_dev_getreg(rg_pci_dev_t *rg_pci_dev, int reg) +{ + return rg_pci_dev->getreg(rg_pci_dev, reg); +} + +static int pci_dev_open(struct inode *inode, struct file *file) +{ + unsigned int minor = iminor(inode); + rg_pci_dev_t *rg_pci_dev; + + PCIE_DEV_DEBUG_VERBOSE("inode: %p, file: %p, minor: %u", inode, file, minor); + + if (minor >= MAX_PCIE_NUM) { + PCIE_DEV_DEBUG_ERROR("minor out of range, minor = %d.\n", minor); + return -ENODEV; + } + + rg_pci_dev = pcie_dev_arry[minor]; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, open failed, minor = %d\n", minor); + return -ENODEV; + } + + file->private_data = rg_pci_dev; + return 0; +} + +static int pci_dev_release(struct inode *inode, struct file *file) +{ + file->private_data = NULL; + return 0; +} + +static int pci_dev_read_tmp(rg_pci_dev_t *rg_pci_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int width, i, j; + u32 val; + + if (offset > rg_pci_dev->bar_len) { + PCIE_DEV_DEBUG_VERBOSE("offset:0x%x, bar len:0x%x, EOF.\n", offset, rg_pci_dev->bar_len); + return 0; + } + + width = rg_pci_dev->bus_width; + + if (offset % width) { + PCIE_DEV_DEBUG_ERROR("pci bus width:%d, offset:0x%x, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + + if (count > rg_pci_dev->bar_len - offset) { + PCIE_DEV_DEBUG_VERBOSE("read count out of range. input len:%lu, read len:%u.\n", + count, rg_pci_dev->bar_len - offset); + count = rg_pci_dev->bar_len - offset; + } + + for (i = 0; i < count; i += width) { + val = pci_dev_getreg(rg_pci_dev, offset + i); + for (j = 0; (j < width) && (i + j < count); j++) { + buf[i + j] = (val >> (8 * j)) & 0xff; + } + } + return count; +} + +static ssize_t pci_dev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +{ + rg_pci_dev_t *rg_pci_dev; + int ret, read_len; + u8 buf_tmp[PCI_RDWR_MAX_LEN]; + + rg_pci_dev = file->private_data; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, read failed.\n"); + return -EINVAL; + } + + if (count == 0) { + PCIE_DEV_DEBUG_ERROR("Invalid params, read count is 0.n"); + return -EINVAL; + } + + if (count > sizeof(buf_tmp)) { + PCIE_DEV_DEBUG_VERBOSE("read conut %lu exceed max %lu.\n", count, sizeof(buf_tmp)); + count = sizeof(buf_tmp); + } + + memset(buf_tmp, 0, sizeof(buf_tmp)); + read_len = pci_dev_read_tmp(rg_pci_dev, *offset, buf_tmp, count); + if (read_len < 0) { + PCIE_DEV_DEBUG_ERROR("pci_dev_read_tmp failed, ret:%d.\n", read_len); + return read_len; + } + if (access_ok(buf, read_len)) { + PCIE_DEV_DEBUG_VERBOSE("user space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + if (copy_to_user(buf, buf_tmp, read_len)) { + PCIE_DEV_DEBUG_ERROR("copy_to_user failed.\n"); + return -EFAULT; + } + } else { + PCIE_DEV_DEBUG_VERBOSE("kernel space read, buf: %p, offset: %lld, read conut %lu.\n", + buf, *offset, count); + memcpy(buf, buf_tmp, read_len); + } + *offset += read_len; + ret = read_len; + return ret; +} + +static ssize_t pci_dev_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + int ret; + + PCIE_DEV_DEBUG_VERBOSE("pci_dev_read_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, to->count, iocb->ki_pos); + ret = pci_dev_read(iocb->ki_filp, to->kvec->iov_base, to->count, &iocb->ki_pos); + return ret; +} + +static int pci_dev_write_tmp(rg_pci_dev_t *rg_pci_dev, uint32_t offset, uint8_t *buf, size_t count) +{ + int width, i, j; + u32 val; + + if (offset > rg_pci_dev->bar_len) { + PCIE_DEV_DEBUG_VERBOSE("offset:0x%x, bar len:0x%x, EOF.\n", offset, rg_pci_dev->bar_len); + return 0; + } + + width = rg_pci_dev->bus_width; + + if (offset % width) { + PCIE_DEV_DEBUG_ERROR("pci bus width:%d, offset:0x%x, read size %lu invalid.\n", + width, offset, count); + return -EINVAL; + } + + if (count > rg_pci_dev->bar_len - offset) { + PCIE_DEV_DEBUG_VERBOSE("write count out of range. input len:%lu, write len:%u.\n", + count, rg_pci_dev->bar_len - offset); + count = rg_pci_dev->bar_len - offset; + } + + for (i = 0; i < count; i += width) { + val = 0; + for (j = 0; (j < width) && (i + j < count); j++) { + val |= buf[i + j] << (8 * j); + } + pci_dev_setreg(rg_pci_dev, i + offset, val); + } + + return count; +} + +static ssize_t pci_dev_write(struct file *file, const char __user *buf, size_t count, + loff_t *offset) +{ + rg_pci_dev_t *rg_pci_dev; + u8 buf_tmp[PCI_RDWR_MAX_LEN]; + int write_len; + + rg_pci_dev = file->private_data; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, write failed.\n"); + return -EINVAL; + } + + if (count == 0) { + PCIE_DEV_DEBUG_ERROR("Invalid params, write count is 0.\n"); + return -EINVAL; + } + + if (count > sizeof(buf_tmp)) { + PCIE_DEV_DEBUG_VERBOSE("write conut %lu exceed max %lu.\n", count, sizeof(buf_tmp)); + count = sizeof(buf_tmp); + } + + memset(buf_tmp, 0, sizeof(buf_tmp)); + if (access_ok(buf, count)) { + PCIE_DEV_DEBUG_VERBOSE("user space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + if (copy_from_user(buf_tmp, buf, count)) { + PCIE_DEV_DEBUG_ERROR("copy_from_user failed.\n"); + return -EFAULT; + } + } else { + PCIE_DEV_DEBUG_VERBOSE("kernel space write, buf: %p, offset: %lld, write conut %lu.\n", + buf, *offset, count); + memcpy(buf_tmp, buf, count); + } + + write_len = pci_dev_write_tmp(rg_pci_dev, *offset, buf_tmp, count); + if (write_len < 0) { + PCIE_DEV_DEBUG_ERROR("pci_dev_write_tmp failed, ret:%d.\n", write_len); + return write_len; + } + + *offset += write_len; + return write_len; +} + +static ssize_t pci_dev_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + int ret; + + PCIE_DEV_DEBUG_VERBOSE("pci_dev_write_iter, file: %p, count: %lu, offset: %lld\n", + iocb->ki_filp, from->count, iocb->ki_pos); + ret = pci_dev_write(iocb->ki_filp, from->kvec->iov_base, from->count, &iocb->ki_pos); + return ret; +} + +static loff_t pci_dev_llseek(struct file *file, loff_t offset, int origin) +{ + loff_t ret = 0; + rg_pci_dev_t *rg_pci_dev; + + rg_pci_dev = file->private_data; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, llseek failed.\n"); + return -EINVAL; + } + + switch (origin) { + case SEEK_SET: + if (offset < 0) { + PCIE_DEV_DEBUG_ERROR("SEEK_SET, offset:%lld, invalid.\n", offset); + ret = -EINVAL; + break; + } + if (offset > rg_pci_dev->bar_len) { + PCIE_DEV_DEBUG_ERROR("SEEK_SET out of range, offset:%lld, bar len:0x%x.\n", + offset, rg_pci_dev->bar_len); + ret = - EINVAL; + break; + } + file->f_pos = offset; + ret = file->f_pos; + break; + case SEEK_CUR: + if (((file->f_pos + offset) > rg_pci_dev->bar_len) || ((file->f_pos + offset) < 0)) { + PCIE_DEV_DEBUG_ERROR("SEEK_CUR out of range, f_ops:%lld, offset:%lld, bar len:0x%x.\n", + file->f_pos, offset, rg_pci_dev->bar_len); + ret = - EINVAL; + break; + } + file->f_pos += offset; + ret = file->f_pos; + break; + default: + PCIE_DEV_DEBUG_ERROR("unsupport llseek type:%d.\n", origin); + ret = -EINVAL; + break; + } + return ret; +} + +static long pci_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + rg_pci_dev_t *rg_pci_dev; + void __user *argp; + firmware_upg_t *firmware_upg; + int upg_ctrl_base; + int upg_flash_base; + + PCIE_DEV_DEBUG_VERBOSE("ioctl, cmd=0x%02x, arg=0x%02lx\n",cmd, arg); + + rg_pci_dev = file->private_data; + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("rg_pci_dev is NULL, ioctl failed.\n"); + return -EINVAL; + } + + firmware_upg = &rg_pci_dev->firmware_upg; + + argp = (void __user *)arg; + + switch (cmd) { + case GET_FPGA_UPG_CTL_BASE: + if (firmware_upg->upg_ctrl_base < 0) { + PCIE_DEV_DEBUG_ERROR("dts not adaptive upg_ctrl_base\n"); + return -EFAULT; + } else { + upg_ctrl_base = firmware_upg->upg_ctrl_base; + if (copy_to_user(argp, &upg_ctrl_base, sizeof(upg_ctrl_base))) { + PCIE_DEV_DEBUG_ERROR("upg_ctrl_base copy_from_user failed\n"); + return -EFAULT; + } + } + break; + case GET_FPGA_UPG_FLASH_BASE: + if (firmware_upg->upg_flash_base < 0) { + PCIE_DEV_DEBUG_ERROR("dts not adaptive upg_flash_base\n"); + return -EFAULT; + } else { + upg_flash_base = firmware_upg->upg_flash_base; + if (copy_to_user(argp, &upg_flash_base, sizeof(upg_flash_base))) { + PCIE_DEV_DEBUG_ERROR("upg_flash_base copy_from_user failed\n"); + return -EFAULT; + } + } + break; + default: + PCIE_DEV_DEBUG_ERROR("command unsupported \n"); + return -ENOTTY; + } + + return 0; +} + +static const struct file_operations pcie_dev_fops = { + .owner = THIS_MODULE, + .llseek = pci_dev_llseek, + .read_iter = pci_dev_read_iter, + .write_iter = pci_dev_write_iter, + .unlocked_ioctl = pci_dev_ioctl, + .open = pci_dev_open, + .release = pci_dev_release, +}; + +static rg_pci_dev_t *dev_match(const char *path) +{ + rg_pci_dev_t *rg_pci_dev; + char dev_name[MAX_NAME_SIZE]; + int i; + + for (i = 0; i < MAX_PCIE_NUM; i++) { + if (pcie_dev_arry[i] == NULL) { + continue; + } + rg_pci_dev = pcie_dev_arry[i]; + snprintf(dev_name, MAX_NAME_SIZE,"/dev/%s", rg_pci_dev->name); + if (!strcmp(path, dev_name)) { + PCIE_DEV_DEBUG_VERBOSE("get dev_name = %s, minor = %d\n", dev_name, i); + return rg_pci_dev; + } + } + + return NULL; +} + +int pcie_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + rg_pci_dev_t *rg_pci_dev; + int read_len; + + if (path == NULL) { + PCIE_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if (buf == NULL) { + PCIE_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + rg_pci_dev = dev_match(path); + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + read_len = pci_dev_read_tmp(rg_pci_dev, offset, buf, count); + if (read_len < 0) { + PCIE_DEV_DEBUG_ERROR("pci_dev_read_tmp failed, ret:%d.\n", read_len); + } + return read_len; +} +EXPORT_SYMBOL(pcie_device_func_read); + +int pcie_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count) +{ + rg_pci_dev_t *rg_pci_dev; + int write_len; + + if (path == NULL) { + PCIE_DEV_DEBUG_ERROR("path NULL"); + return -EINVAL; + } + + if (buf == NULL) { + PCIE_DEV_DEBUG_ERROR("buf NULL"); + return -EINVAL; + } + + rg_pci_dev = dev_match(path); + if (rg_pci_dev == NULL) { + PCIE_DEV_DEBUG_ERROR("i2c_dev match failed. dev path = %s", path); + return -EINVAL; + } + + write_len = pci_dev_write_tmp(rg_pci_dev, offset, buf, count); + if (write_len < 0) { + PCIE_DEV_DEBUG_ERROR("pci_dev_write_tmp failed, ret:%d.\n", write_len); + } + return write_len; +} +EXPORT_SYMBOL(pcie_device_func_write); + +static int pci_setup_bars(rg_pci_dev_t *rg_pci_dev, struct pci_dev *dev) +{ + int ret; + uint32_t addr, len, flags; + + ret = 0; + addr = pci_resource_start(dev, rg_pci_dev->bar); + len = pci_resource_len(dev, rg_pci_dev->bar); + if (addr == 0 || len == 0) { + PCIE_DEV_DEBUG_ERROR("get bar addr failed. bar:%d, addr:0x%x, len:0x%x.\n", + rg_pci_dev->bar, addr, len); + return -EFAULT; + } + rg_pci_dev->bar_len = len; + + flags = pci_resource_flags(dev, rg_pci_dev->bar); + PCIE_DEV_DEBUG_VERBOSE("bar:%d, flag:0x%08x, phys addr:0x%x, len:0x%x\n", + rg_pci_dev->bar, flags, addr, len); + if (flags & IORESOURCE_MEM) { + rg_pci_dev->bar_flag = IORESOURCE_MEM; + rg_pci_dev->pci_mem_base = ioremap(addr, len); + PCIE_DEV_DEBUG_VERBOSE("pci mem base:%p.\n", rg_pci_dev->pci_mem_base); + } else if (flags & IORESOURCE_IO) { + rg_pci_dev->bar_flag = IORESOURCE_IO; + rg_pci_dev->pci_io_base = addr; + PCIE_DEV_DEBUG_VERBOSE("pci io base:0x%x.\n", rg_pci_dev->pci_io_base); + } else { + PCIE_DEV_DEBUG_ERROR("unknow pci bar flag:0x%08x.\n", flags); + ret = -EINVAL; + } + + return ret; +} + +static int pci_dev_probe(struct platform_device *pdev) +{ + int ret, devfn; + rg_pci_dev_t *rg_pci_dev; + struct pci_dev *pci_dev; + struct miscdevice *misc; + firmware_upg_t *firmware_upg; + pci_dev_device_t *pci_dev_device; + + rg_pci_dev = devm_kzalloc(&pdev->dev, sizeof(rg_pci_dev_t), GFP_KERNEL); + if (!rg_pci_dev) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + ret = -ENOMEM; + return ret; + } + + firmware_upg = &rg_pci_dev->firmware_upg; + + if (pdev->dev.of_node) { + ret = 0; + ret += of_property_read_string(pdev->dev.of_node, "pci_dev_name", &rg_pci_dev->name); + ret += of_property_read_u32(pdev->dev.of_node, "pci_domain", &rg_pci_dev->domain); + ret += of_property_read_u32(pdev->dev.of_node, "pci_bus", &rg_pci_dev->bus); + ret += of_property_read_u32(pdev->dev.of_node, "pci_slot", &rg_pci_dev->slot); + ret += of_property_read_u32(pdev->dev.of_node, "pci_fn", &rg_pci_dev->fn); + ret += of_property_read_u32(pdev->dev.of_node, "pci_bar", &rg_pci_dev->bar); + ret += of_property_read_u32(pdev->dev.of_node, "bus_width", &rg_pci_dev->bus_width); + + if (ret != 0) { + dev_err(&pdev->dev, "Failed to get dts config, ret:%d.\n", ret); + return -ENXIO; + } + + ret = 0; + ret += of_property_read_u32(pdev->dev.of_node, "upg_ctrl_base", &firmware_upg->upg_ctrl_base); + ret += of_property_read_u32(pdev->dev.of_node, "upg_flash_base", &firmware_upg->upg_flash_base); + if (ret != 0) { + PCIE_DEV_DEBUG_VERBOSE("dts don't adaptive fpga upg related, ret:%d.\n", ret); + firmware_upg->upg_ctrl_base = -1; + firmware_upg->upg_flash_base = -1; + } else { + PCIE_DEV_DEBUG_VERBOSE("upg_ctrl_base:0x%04x, upg_flash_base:0x%02x.\n", + firmware_upg->upg_ctrl_base, firmware_upg->upg_flash_base); + } + } else { + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + pci_dev_device = pdev->dev.platform_data; + rg_pci_dev->name = pci_dev_device->pci_dev_name; + rg_pci_dev->domain = pci_dev_device->pci_domain; + rg_pci_dev->bus = pci_dev_device->pci_bus; + rg_pci_dev->slot = pci_dev_device->pci_slot; + rg_pci_dev->fn = pci_dev_device->pci_fn; + rg_pci_dev->bar = pci_dev_device->pci_bar; + rg_pci_dev->bus_width = pci_dev_device->bus_width; + firmware_upg->upg_ctrl_base = pci_dev_device->upg_ctrl_base; + firmware_upg->upg_flash_base = pci_dev_device->upg_flash_base; + PCIE_DEV_DEBUG_VERBOSE("upg_ctrl_base:0x%04x, upg_flash_base:0x%02x.\n", + firmware_upg->upg_ctrl_base, firmware_upg->upg_flash_base); + } + + PCIE_DEV_DEBUG_VERBOSE("name:%s, domain:0x%04x, bus:0x%02x, slot:0x%02x, fn:%u, bar:%u, bus_width:%d.\n", + rg_pci_dev->name, rg_pci_dev->domain, rg_pci_dev->bus, rg_pci_dev->slot, rg_pci_dev->fn, + rg_pci_dev->bar, rg_pci_dev->bus_width); + + devfn = PCI_DEVFN(rg_pci_dev->slot, rg_pci_dev->fn); + pci_dev = pci_get_domain_bus_and_slot(rg_pci_dev->domain, rg_pci_dev->bus, devfn); + if (pci_dev == NULL) { + dev_err(&pdev->dev, "Failed to find pci_dev, domain:0x%04x, bus:0x%02x, devfn:0x%x\n", + rg_pci_dev->domain, rg_pci_dev->bus, devfn); + return -ENXIO; + } + ret = pci_setup_bars(rg_pci_dev, pci_dev); + if (ret != 0) { + dev_err(&pdev->dev, "Failed to get pci bar address.\n"); + return ret; + } + + if (!rg_pci_dev->setreg || !rg_pci_dev->getreg) { + switch (rg_pci_dev->bus_width) { + case 1: + rg_pci_dev->setreg = pci_dev_setreg_8; + rg_pci_dev->getreg = pci_dev_getreg_8; + break; + + case 2: + rg_pci_dev->setreg = pci_dev_setreg_16; + rg_pci_dev->getreg = pci_dev_getreg_16; + break; + + case 4: + rg_pci_dev->setreg = pci_dev_setreg_32; + rg_pci_dev->getreg = pci_dev_getreg_32; + break; + default: + dev_err(&pdev->dev, "Error: unsupported I/O width (%d).\n", rg_pci_dev->bus_width); + ret = -EINVAL; + goto io_unmap; + } + } + + misc = &rg_pci_dev->misc; + misc->minor = MISC_DYNAMIC_MINOR; + misc->name = rg_pci_dev->name; + misc->fops = &pcie_dev_fops; + misc->mode = 0666; + if (misc_register(misc) != 0) { + dev_err(&pdev->dev, "Failed to register %s device.\n", misc->name); + ret = -ENXIO; + goto io_unmap; + } + if (misc->minor >= MAX_PCIE_NUM) { + dev_err(&pdev->dev, "Error: device minor[%d] more than max pcie num[%d].\n", + misc->minor, MAX_PCIE_NUM); + misc_deregister(misc); + ret = -EINVAL; + goto io_unmap; + } + pcie_dev_arry[misc->minor] = rg_pci_dev; + dev_info(&pdev->dev, "%04x:%02x:%02x.%d[bar%d: %s]: register %s device with minor:%d success.\n", + rg_pci_dev->domain, rg_pci_dev->bus, rg_pci_dev->slot, rg_pci_dev->fn, rg_pci_dev->bar, + rg_pci_dev->bar_flag == IORESOURCE_MEM ? "IORESOURCE_MEM" : "IORESOURCE_IO", + misc->name, misc->minor ); + return 0; + +io_unmap: + if (rg_pci_dev->pci_mem_base) { + iounmap(rg_pci_dev->pci_mem_base); + } + return ret; +} + +static int pci_dev_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < MAX_PCIE_NUM ; i++) { + if (pcie_dev_arry[i] != NULL) { + if (pcie_dev_arry[i]->pci_mem_base) { + iounmap(pcie_dev_arry[i]->pci_mem_base); + } + misc_deregister(&pcie_dev_arry[i]->misc); + pcie_dev_arry[i] = NULL; + } + } + + return 0; +} + +static struct of_device_id pci_dev_match[] = { + { + .compatible = "ruijie,rg-pci-dev", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, pci_dev_match); + +static struct platform_driver rg_pci_dev_driver = { + .probe = pci_dev_probe, + .remove = pci_dev_remove, + .driver = { + .owner = THIS_MODULE, + .name = PROXY_NAME, + .of_match_table = pci_dev_match, + }, +}; + +static int __init rg_pci_dev_init(void) +{ + return platform_driver_register(&rg_pci_dev_driver); +} + +static void __exit rg_pci_dev_exit(void) +{ + platform_driver_unregister(&rg_pci_dev_driver); +} + +module_init(rg_pci_dev_init); +module_exit(rg_pci_dev_exit); +MODULE_DESCRIPTION("pcie device driver"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.h new file mode 100644 index 000000000000..c967e021070d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pcie_dev.h @@ -0,0 +1,23 @@ +#ifndef __RG_PCIE_DEV_H__ +#define __RG_PCIE_DEV_H__ + +#define UPG_TYPE 'U' +#define GET_FPGA_UPG_CTL_BASE _IOR(UPG_TYPE, 0, int) +#define GET_FPGA_UPG_FLASH_BASE _IOR(UPG_TYPE, 1, int) + +#define PCI_DEV_NAME_MAX_LEN (64) + +typedef struct pci_dev_device_s { + char pci_dev_name[PCI_DEV_NAME_MAX_LEN]; + int pci_domain; + int pci_bus; + int pci_slot; + int pci_fn; + int pci_bar; + int bus_width; + int upg_ctrl_base; + int upg_flash_base; + int device_flag; +} pci_dev_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/Makefile new file mode 100755 index 000000000000..369b64605dd3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/Makefile @@ -0,0 +1,20 @@ +pes_parent_dir:=$(shell pwd)/$(lastword $(MAKEFILE_LIST)) +pes_parent_dir:=$(shell dirname $(pes_parent_dir)) + +SUBDIRS=$(shell ls -l | grep ^d | awk '{if($$9 != "build") print $$9}') +INC = -I./inc + +all : CHECK $(SUBDIRS) +CHECK : + @echo $(pes_parent_dir) + +$(SUBDIRS):ECHO + #@echo $@ + make -C $@ + +ECHO: + @echo $(SUBDIRS) + +.PHONY : clean +clean : + -rm -rf $(SYSFS_OUT_PUT) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/Makefile new file mode 100755 index 000000000000..ec190b348367 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/Makefile @@ -0,0 +1,31 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUBDIR_CFG = cfg +rg_plat_dfd-objs := dfd_module.o dfd_fan_driver.o \ +dfd_syseeprom_driver.o \ +dfd_cpld_driver.o \ +dfd_led_driver.o \ +dfd_slot_driver.o \ +dfd_sensors_driver.o \ +dfd_psu_driver.o \ +dfd_sff_driver.o \ +dfd_sfpbase.o \ +$(SUBDIR_CFG)/dfd_cfg.o \ +$(SUBDIR_CFG)/dfd_cfg_adapter.o \ +$(SUBDIR_CFG)/dfd_cfg_file.o \ +$(SUBDIR_CFG)/dfd_cfg_info.o \ +$(SUBDIR_CFG)/dfd_cfg_listnode.o \ +$(SUBDIR_CFG)/dfd_frueeprom.o \ +$(SUBDIR_CFG)/dfd_tlveeprom.o \ + +obj-m := rg_plat_dfd.o +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(module_out_put_dir) ]; then mkdir -p $(module_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(module_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/$(SUBDIR_CFG)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/$(SUBDIR_CFG)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg.c new file mode 100644 index 000000000000..c9b3f6a0e371 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg.c @@ -0,0 +1,815 @@ +/* + * Copyright(C) 2001-2015 Ruijie Network. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include "../include/dfd_module.h" +#include "../include/dfd_cfg_file.h" +#include "../include/dfd_cfg_listnode.h" +#include "../include/dfd_cfg_info.h" +#include "../include/dfd_cfg_adapter.h" +#include "../include/dfd_cfg.h" + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) _name, +static char *dfd_cfg_item_name[] = { + DFD_CFG_ITEM_ALL +}; + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) {_index_min, _index_max}, +static index_range_t dfd_cfg_item_index_range[] = { + DFD_CFG_ITEM_ALL +}; + +static lnode_root_t dfd_ko_cfg_list_root; + +static void dfd_ko_cfg_del_space_lf_cr(char *str) +{ + int i, j; + int len; + + len = strlen(str); + for (i = 0; i < len; i++) { + if (str[i] == '\r' || str[i] == '\n' || str[i] == ' ') { + for (j = i; j < len - 1; j++) { + str[j] = str[j + 1]; + } + str[j] = '\0'; + len--; + i--; + } + } +} + +static int dfd_ko_cfg_get_value_from_char(char *value_str, int32_t *value, int line_num) +{ + int value_tmp = 0; + + if (strlen(value_str) == 0) { + DBG_DEBUG(DBG_WARN, "line%d: value str is empty\n", line_num); + *value = DFD_CFG_EMPTY_VALUE; + return 0; + } + + if ((strlen(value_str) > 2) && (value_str[0] == '0') + && (value_str[1] == 'x' || value_str[1] == 'X')) { + value_tmp = (int32_t)simple_strtol(value_str, NULL, 16); + } else { + value_tmp = (int32_t)simple_strtol(value_str, NULL, 10); + } + + *value = value_tmp; + return 0; +} + +static int dfd_ko_cfg_analyse_index(char *index_str, int *index1, int *index2, int line_num) +{ + int rv; + char *index1_begin_char, *index2_begin_char; + + if (index_str[0] != '_') { + DBG_DEBUG(DBG_ERROR, "line%d: no '-' between name and index1\n", line_num); + return -1; + } + + index1_begin_char = index_str; + rv = dfd_ko_cfg_get_value_from_char(++index1_begin_char, index1, line_num); + if (rv < 0) { + return -1; + } + + if (index2 == NULL) { + return 0; + } + + index2_begin_char = strchr(index1_begin_char, '_'); + if (index2_begin_char == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: no '-' between index1 and index2\n", line_num); + return -1; + } else { + rv = dfd_ko_cfg_get_value_from_char(++index2_begin_char, index2, line_num); + if (rv < 0) { + return -1; + } + } + + return 0; +} + +static int dfd_ko_cfg_check_array_index(index_range_t *index_range, int *index1, int *index2, + int line_num) +{ + + if ((*index1 < 0) || (*index1 > index_range->index1_max)) { + DBG_DEBUG(DBG_ERROR, "line%d: index1[%d] invalid, max=%d\n", line_num, *index1, + index_range->index1_max); + return -1; + } + + if (index2 == NULL) { + return 0; + } + + if ((*index2 < 0) || (*index2 > index_range->index2_max)) { + DBG_DEBUG(DBG_ERROR, "line%d: index2[%d] invalid, max=%d\n", line_num, *index2, + index_range->index2_max); + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_index(char *index_str, index_range_t *index_range, int *index1, + int *index2, int line_num) +{ + int rv; + + if (index_range->index2_max == INDEX_NOT_EXIST) { + index2 = NULL; + } + + rv = dfd_ko_cfg_analyse_index(index_str, index1, index2, line_num); + if (rv < 0) { + return -1; + } + + rv = dfd_ko_cfg_check_array_index(index_range, index1, index2, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_add_int_item(int key, int value, int line_num) +{ + int rv; + int *int_cfg; + + int_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (int_cfg == NULL) { + + int_cfg = (int *)kmalloc(sizeof(int), GFP_KERNEL); + if (int_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc int fail\n", line_num); + return -1; + } + + *int_cfg = value; + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, int_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add int item[%d] success, key=0x%08x\n", line_num, value, key); + } else { + kfree(int_cfg); + int_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add int item[%d] fail, key=0x%08x rv=%d \n", line_num, value, key, rv); + return -1; + } + } else { + + DBG_DEBUG(DBG_WARN, "line%d: replace int item[%d->%d], key=0x%08x\n", line_num, *int_cfg, value, key); + *int_cfg = value; + } + + return 0; +} + +static int dfd_ko_cfg_analyse_int_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, char *arg_value, + char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int value, key; + char *arg_name_tmp; + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + rv = dfd_ko_cfg_get_value_from_char(arg_value, &value, line_num); + if (rv < 0) { + return -1; + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_int_item(key, value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_add_str_item(int key, char *str, int line_num) +{ + int rv; + char *str_cfg; + + str_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (str_cfg == NULL) { + + str_cfg = (char *)kmalloc(DFD_CFG_STR_MAX_LEN, GFP_KERNEL); + if (str_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc str[%lu] fail\n", line_num, strlen(str)); + return -1; + } + memset(str_cfg, 0, DFD_CFG_STR_MAX_LEN); + strncpy(str_cfg, str, DFD_CFG_STR_MAX_LEN - 1); + + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, str_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add string item[%s] success, key=0x%08x\n", line_num, str_cfg, key); + } else { + kfree(str_cfg); + str_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add string item[%s] fail, key=0x%08x rv=%d \n", line_num, str_cfg, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_WARN, "line%d: replace string item[%s->%s], key=0x%08x\n", line_num, str_cfg, str, key); + memset(str_cfg, 0, DFD_CFG_STR_MAX_LEN); + strncpy(str_cfg, str, DFD_CFG_STR_MAX_LEN - 1); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_str_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, char *arg_value, + char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int btree_key; + char *arg_name_tmp; + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + if (strlen(arg_value) >= DFD_CFG_STR_MAX_LEN) { + DBG_DEBUG(DBG_ERROR, "line%d: string item[%s] is too long \n", line_num, arg_value); + return -1; + } + + btree_key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_str_item(btree_key, arg_value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_i2c_dev_member(char *member_str, dfd_i2c_dev_mem_t *member, int line_num) +{ + dfd_i2c_dev_mem_t mem_index; + + for (mem_index = DFD_I2C_DEV_MEM_BUS; mem_index < DFD_I2C_DEV_MEM_END; mem_index++) { + if (memcmp(member_str, g_dfd_i2c_dev_mem_str[mem_index], + strlen(g_dfd_i2c_dev_mem_str[mem_index])) == 0) { + *member = mem_index; + return 0; + } + } + + DBG_DEBUG(DBG_ERROR, "line%d: i2c dev member[%s] invalid\n", line_num, member_str); + return -1; +} + +static void dfd_ko_cfg_set_i2c_dev_mem_value(dfd_i2c_dev_t *i2c_dev, dfd_i2c_dev_mem_t member, + int value) +{ + switch (member) { + case DFD_I2C_DEV_MEM_BUS: + i2c_dev->bus = value; + break; + case DFD_I2C_DEV_MEM_ADDR: + i2c_dev->addr = value; + break; + default: + break; + } +} + +static int dfd_ko_cfg_add_i2c_dev_item(int key, dfd_i2c_dev_mem_t member, int value, int line_num) +{ + int rv; + dfd_i2c_dev_t *i2c_dev_cfg; + + i2c_dev_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (i2c_dev_cfg == NULL) { + + i2c_dev_cfg = (dfd_i2c_dev_t *)kmalloc(sizeof(dfd_i2c_dev_t), GFP_KERNEL); + if (i2c_dev_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc i2c_dev fail\n", line_num); + return -1; + } + memset(i2c_dev_cfg, 0, sizeof(dfd_i2c_dev_t)); + + dfd_ko_cfg_set_i2c_dev_mem_value(i2c_dev_cfg, member, value); + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, i2c_dev_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add i2c_dev item[%s=%d] success, key=0x%08x\n", line_num, + g_dfd_i2c_dev_mem_str[member], value, key); + } else { + kfree(i2c_dev_cfg); + i2c_dev_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add i2c_dev item[%s=%d] fail, key=0x%08x rv=%d\n", line_num, + g_dfd_i2c_dev_mem_str[member], value, key, rv); + return -1; + } + } else { + + DBG_DEBUG(DBG_VERBOSE, "line%d: replace i2c_dev item[%s=%d], key=0x%08x\n", line_num, + g_dfd_i2c_dev_mem_str[member], value, key); + dfd_ko_cfg_set_i2c_dev_mem_value(i2c_dev_cfg, member, value); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_i2c_dev_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int value, key; + char *arg_name_tmp; + dfd_i2c_dev_mem_t member; + + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_i2c_dev_member(arg_name_tmp, &member, line_num); + if (rv < 0) { + return -1; + } + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp += strlen(g_dfd_i2c_dev_mem_str[member]); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + rv = dfd_ko_cfg_get_value_from_char(arg_value, &value, line_num); + if (rv < 0) { + return -1; + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_i2c_dev_item(key, member, value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_enum_value_by_str(char *enum_val_str[], int enum_val_end, char *buf) +{ + int i; + int enum_val; + + enum_val = DFD_CFG_INVALID_VALUE; + for (i = 0; i < enum_val_end; i++) { + if (memcmp(buf, enum_val_str[i], strlen(enum_val_str[i])) == 0) { + enum_val = i; + break; + } + } + + return enum_val; +} + +static int dfd_ko_cfg_get_info_ctrl_member(char *member_str, info_ctrl_mem_t *member, int line_num) +{ + info_ctrl_mem_t mem_index; + + for (mem_index = INFO_CTRL_MEM_MODE; mem_index < INFO_CTRL_MEM_END; mem_index++) { + if (memcmp(member_str, g_info_ctrl_mem_str[mem_index], + strlen(g_info_ctrl_mem_str[mem_index])) == 0) { + *member = mem_index; + return 0; + } + } + + DBG_DEBUG(DBG_ERROR, "line%d: info ctrl member[%s] invalid\n", line_num, member_str); + return -1; +} + +static void dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_t *info_ctrl, info_ctrl_mem_t member, + char *buf_val, int line_num) +{ + switch (member) { + case INFO_CTRL_MEM_MODE: + info_ctrl->mode = dfd_ko_cfg_get_enum_value_by_str(g_info_ctrl_mode_str, INFO_CTRL_MODE_END, buf_val);; + break; + case INFO_CTRL_MEM_INT_CONS: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_cons), line_num); + break; + case INFO_CTRL_MEM_SRC: + info_ctrl->src = dfd_ko_cfg_get_enum_value_by_str(g_info_src_str, INFO_SRC_END, buf_val); + break; + case INFO_CTRL_MEM_FRMT: + info_ctrl->frmt = dfd_ko_cfg_get_enum_value_by_str(g_info_frmt_str, INFO_FRMT_END, buf_val); + break; + case INFO_CTRL_MEM_POLA: + info_ctrl->pola = dfd_ko_cfg_get_enum_value_by_str(g_info_pola_str, INFO_POLA_END, buf_val); + break; + case INFO_CTRL_MEM_FPATH: + memset(info_ctrl->fpath, 0, sizeof(info_ctrl->fpath)); + strncpy(info_ctrl->fpath, buf_val, sizeof(info_ctrl->fpath) - 1); + break; + case INFO_CTRL_MEM_ADDR: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->addr), line_num); + break; + case INFO_CTRL_MEM_LEN: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->len), line_num); + break; + case INFO_CTRL_MEM_BIT_OFFSET: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->bit_offset), line_num); + break; + case INFO_CTRL_MEM_STR_CONS: + memset(info_ctrl->str_cons, 0, sizeof(info_ctrl->str_cons)); + strncpy(info_ctrl->str_cons, buf_val, sizeof(info_ctrl->str_cons) - 1); + break; + case INFO_CTRL_MEM_INT_EXTRA1: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_extra1), line_num); + break; + case INFO_CTRL_MEM_INT_EXTRA2: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_extra2), line_num); + break; + default: + break; + } +} + +static int dfd_ko_cfg_add_info_ctrl_item(int key, info_ctrl_mem_t member, char *buf_val, + int line_num) +{ + int rv; + info_ctrl_t *info_ctrl_cfg; + + info_ctrl_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (info_ctrl_cfg == NULL) { + + info_ctrl_cfg = (info_ctrl_t *)kmalloc(sizeof(info_ctrl_t), GFP_KERNEL); + if (info_ctrl_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc info_ctrl fail\n", line_num); + return -1; + } + memset(info_ctrl_cfg, 0, sizeof(info_ctrl_t)); + + dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_cfg, member, buf_val, line_num); + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, info_ctrl_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add info_ctrl item[%s=%s] success, key=0x%08x\n", line_num, + g_info_ctrl_mem_str[member], buf_val, key); + } else { + kfree(info_ctrl_cfg); + info_ctrl_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add info_ctrl item[%s=%s] fail, key=0x%08x rv=%d\n", line_num, + g_info_ctrl_mem_str[member], buf_val, key, rv); + return -1; + } + } else { + + DBG_DEBUG(DBG_VERBOSE, "line%d: replace info_ctrl item[%s=%s], key=0x%08x\n", line_num, + g_info_ctrl_mem_str[member], buf_val, key); + dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_cfg, member, buf_val, line_num); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_info_ctrl_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int key; + char *arg_name_tmp; + info_ctrl_mem_t member; + + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_info_ctrl_member(arg_name_tmp, &member, line_num); + if (rv < 0) { + return -1; + } + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp += strlen(g_info_ctrl_mem_str[member]); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_info_ctrl_item(key, member, arg_value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_analyse_config(char *arg_name, char*arg_value, int line_num) +{ + int i, rv = 0; + int cfg_item_num; + + cfg_item_num = sizeof(dfd_cfg_item_name) / sizeof(dfd_cfg_item_name[0]); + for (i = 0; i < cfg_item_num; i++) { + if (memcmp(arg_name, dfd_cfg_item_name[i], strlen(dfd_cfg_item_name[i])) == 0){ + if (DFD_CFG_ITEM_IS_INT(i)) { + rv = dfd_ko_cfg_analyse_int_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_STRING(i)) { + rv = dfd_ko_cfg_analyse_str_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_I2C_DEV(i)) { + rv = dfd_ko_cfg_analyse_i2c_dev_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_INFO_CTRL(i)) { + rv = dfd_ko_cfg_analyse_info_ctrl_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else { + rv = -1; + } + break; + } + } + + return rv; +} + +static int dfd_ko_cfg_cut_config_line(char *config_line, char *arg_name, char *arg_value) +{ + int i, j = 0, k = 0; + int len, name_value_flag = 0; + + len = strlen(config_line); + for (i = 0; i < len; i++) { + if (config_line[i] == '=') { + name_value_flag = 1; + continue; + } + + if (name_value_flag == 0) { + arg_name[j++] = config_line[i]; + } else { + arg_value[k++] = config_line[i]; + } + } + + if (name_value_flag == 0) { + return -1; + } else { + return 0; + } +} + +static int dfd_ko_cfg_analyse_config_line(char *config_line, int line_num) +{ + int rv; + char arg_name[DFD_CFG_NAME_MAX_LEN] = {0}; + char arg_value[DFD_CFG_VALUE_MAX_LEN] = {0}; + + dfd_ko_cfg_del_space_lf_cr(config_line); + + if (strlen(config_line) == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: space line\n", line_num); + return 0; + } + + if (config_line[0] == '#') { + DBG_DEBUG(DBG_VERBOSE, "line%d: comment line[%s]\n", line_num, config_line); + return 0; + } + + rv = dfd_ko_cfg_cut_config_line(config_line, arg_name, arg_value); + if (rv < 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: [%s]no '=' between name and value\n", line_num, config_line); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "line%d: config_line[%s] name[%s] value[%s]\n", line_num, config_line, arg_name, arg_value); + return dfd_ko_cfg_analyse_config(arg_name, arg_value, line_num); +} + +static int dfd_ko_cfg_analyse_config_file(char *fpath) +{ + int rv; + int line_num = 1; + kfile_ctrl_t kfile_ctrl; + char config_line[DFD_CFG_CMDLINE_MAX_LEN] = {0}; + + rv = kfile_open(fpath, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", fpath, rv); + return -1; + } + + while(kfile_gets(config_line, sizeof(config_line), &kfile_ctrl) > 0){ + rv = dfd_ko_cfg_analyse_config_line(config_line, line_num++); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "!!!!file[%s] config line[%d %s] analyse fail\n", fpath, line_num - 1, + config_line); + break; + } + + (void)memset(config_line, 0, sizeof(config_line)); + + } + kfile_close(&kfile_ctrl); + + return rv; +} + +void *dfd_ko_cfg_get_item(int key) +{ + return lnode_find_node(&dfd_ko_cfg_list_root, key); +} + +static void dfd_ko_cfg_print_item(int key, const void *cfg) +{ + int item_id; + dfd_i2c_dev_t *i2c_dev; + info_ctrl_t *info_ctrl; + + if (cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return; + } + printk(KERN_INFO "**************************\n"); + printk(KERN_INFO "key=0x%08x\n", key); + + item_id = DFD_CFG_ITEM_ID(key); + if (DFD_CFG_ITEM_IS_INT(item_id)) { + printk(KERN_INFO "int=%d\n", *((int *)cfg)); + } else if (DFD_CFG_ITEM_IS_I2C_DEV(item_id)) { + i2c_dev = (dfd_i2c_dev_t *)cfg; + printk(KERN_INFO ".bus=0x%02x\n", i2c_dev->bus); + printk(KERN_INFO ".addr=0x%02x\n", i2c_dev->addr); + } else if (DFD_CFG_ITEM_IS_INFO_CTRL(item_id)) { + info_ctrl = (info_ctrl_t *)cfg; + printk(KERN_INFO ".mode=%s\n", g_info_ctrl_mode_str[info_ctrl->mode]); + printk(KERN_INFO ".int_cons=%d\n", info_ctrl->int_cons); + printk(KERN_INFO ".src=%s\n", g_info_src_str[info_ctrl->src]); + printk(KERN_INFO ".frmt=%s\n", g_info_frmt_str[info_ctrl->frmt]); + printk(KERN_INFO ".pola=%s\n", g_info_pola_str[info_ctrl->pola]); + printk(KERN_INFO ".fpath=%s\n", info_ctrl->fpath); + printk(KERN_INFO ".addr=0x%02x\n", info_ctrl->addr); + printk(KERN_INFO ".len=%d\n", info_ctrl->len); + printk(KERN_INFO ".bit_offset=%d\n", info_ctrl->bit_offset); + } else { + printk(KERN_INFO "item[%d] error!\n", item_id); + } +} + +void dfd_ko_cfg_show_item(int key) +{ + void *cfg; + + cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (cfg == 0) { + printk(KERN_INFO "item[0x%08x] not exist\n", key); + return; + } + + dfd_ko_cfg_print_item(key, cfg); +} + +static int dfd_get_my_dev_type_by_file(void) +{ + struct file *fp; + loff_t pos; + int card_type; + char buf[DFD_PID_BUF_LEN]; + int ret; + + fp= filp_open(DFD_PUB_CARDTYPE_FILE, O_RDONLY, 0); + if (IS_ERR(fp)) { + DBG_DEBUG(DBG_VERBOSE, "open file fail!\n"); + return -1; + } + memset(buf, 0, DFD_PID_BUF_LEN); + pos = 0; + ret = kernel_read(fp, buf, DFD_PRODUCT_ID_LENGTH + 1, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_VERBOSE, "kernel_read failed, path=%s, addr=0, size=%d, ret=%d\n", + DFD_PUB_CARDTYPE_FILE, DFD_PRODUCT_ID_LENGTH + 1, ret); + filp_close(fp, NULL); + return -1; + } + + card_type = simple_strtoul(buf, NULL, 10); + DBG_DEBUG(DBG_VERBOSE, "card_type 0x%x.\n", card_type); + + filp_close(fp, NULL); + return card_type; +} + +static int drv_get_my_dev_type(void) +{ + static int type = -1; + + if (type > 0) { + return type; + } + type = dfd_get_my_dev_type_by_file(); + DBG_DEBUG(DBG_VERBOSE, "ko board type %d\n", type); + return type; +} + +static int dfd_ko_cfg_init(void) +{ + int rv; + int card_type; + char file_name[32] = {0}; + char fpath[128] = {0}; + kfile_ctrl_t kfile_ctrl; + + rv = lnode_init_root(&dfd_ko_cfg_list_root); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "init list root fail, rv=%d\n", rv); + return -1; + } + + card_type = drv_get_my_dev_type(); + if (card_type > 0) { + snprintf(fpath, sizeof(fpath), "%s0x%x", DFD_KO_CFG_FILE_DIR, card_type); + rv = kfile_open(fpath, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_VERBOSE, "open config file[%s] fail, rv=%d, maybe not exist\n", + fpath, rv); + + rv = kfile_open(DFD_KO_CFG_FILE_NAME, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", DFD_KO_CFG_FILE_NAME, + rv); + return -1; + } + DBG_DEBUG(DBG_ERROR, "get config file from: %s, success.\n", DFD_KO_CFG_FILE_NAME); + } else { + DBG_DEBUG(DBG_VERBOSE, "get config file from: %s, success.\n", fpath); + } + } else { + DBG_DEBUG(DBG_VERBOSE, "get board id failed, try to get config file from: %s\n", + DFD_KO_CFG_FILE_NAME); + + rv = kfile_open(DFD_KO_CFG_FILE_NAME, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", DFD_KO_CFG_FILE_NAME, rv); + return -1; + } + DBG_DEBUG(DBG_ERROR, "get config file from: %s, success.\n", DFD_KO_CFG_FILE_NAME); + } + + while (kfile_gets(file_name, sizeof(file_name), &kfile_ctrl) > 0) { + + dfd_ko_cfg_del_space_lf_cr(file_name); + memset(fpath, 0, sizeof(fpath)); + snprintf(fpath, sizeof(fpath), "%s%s.cfg", DFD_KO_CFG_FILE_DIR, file_name); + DBG_DEBUG(DBG_VERBOSE, ">>>>start parsing config file[%s]\n", fpath); + + rv = dfd_ko_cfg_analyse_config_file(fpath); + if (rv < 0) { + break; + } + } + kfile_close(&kfile_ctrl); + + return 0; +} + +int32_t dfd_dev_cfg_init(void) +{ + return dfd_ko_cfg_init(); +} + +void dfd_dev_cfg_exit(void) +{ + lnode_free_list(&dfd_ko_cfg_list_root); + return; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_adapter.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_adapter.c new file mode 100644 index 000000000000..b758bf62bd8c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_adapter.c @@ -0,0 +1,354 @@ +/* + * Copyright(C) 2015 Ruijie Network. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "../include/dfd_module.h" +#include "../include/dfd_cfg_file.h" +#include "../include/dfd_cfg.h" +#include "../include/dfd_cfg_adapter.h" + +char *g_dfd_i2c_dev_mem_str[DFD_I2C_DEV_MEM_END] = { + ".bus", + ".addr", +}; + +static dfd_i2c_dev_t* dfd_ko_get_cpld_i2c_dev(int sub_slot, int cpld_id) +{ + int key; + dfd_i2c_dev_t *i2c_dev; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_I2C_DEV, sub_slot, cpld_id); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld[%d] i2c dev config fail, key=0x%08x\n", cpld_id, key); + return NULL; + } + + return i2c_dev; +} + +static int32_t dfd_ko_i2c_smbus_transfer(int read_write, int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int rv; + struct i2c_adapter *i2c_adap; + union i2c_smbus_data data; + + i2c_adap = i2c_get_adapter(bus); + if (i2c_adap == NULL) { + DBG_DEBUG(DBG_ERROR, "get i2c bus[%d] adapter fail\n", bus); + return -DFD_RV_DEV_FAIL; + } + + if (read_write == I2C_SMBUS_WRITE) { + data.byte = *buf; + } else { + data.byte = 0; + } + rv = i2c_smbus_xfer(i2c_adap, addr, 0, read_write, offset, I2C_SMBUS_BYTE_DATA, &data); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "i2c dev[bus=%d addr=0x%x offset=0x%x size=%d rw=%d] transfer fail, rv=%d\n", + bus, addr, offset, size, read_write, rv); + rv = -DFD_RV_DEV_FAIL; + } else { + DBG_DEBUG(DBG_VERBOSE, "i2c dev[bus=%d addr=0x%x offset=0x%x size=%d rw=%d] transfer success\n", + bus, addr, offset, size, read_write); + rv = DFD_RV_OK; + } + + if (read_write == I2C_SMBUS_READ) { + if (rv == DFD_RV_OK) { + *buf = data.byte; + } else { + *buf = 0; + } + } + + i2c_put_adapter(i2c_adap); + return rv; +} + +static int32_t dfd_ko_i2c_read_data(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + for (i = 0; i < DFD_KO_CPLD_I2C_RETRY_TIMES; i++) { + rv = dfd_ko_i2c_smbus_transfer(I2C_SMBUS_READ, bus, addr, offset, buf, size); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "[%d]cpld read[offset=0x%x] fail, rv %d\n", i, addr, rv); + msleep(DFD_KO_CPLD_I2C_RETRY_SLEEP); + } else { + DBG_DEBUG(DBG_VERBOSE, "[%d]cpld read[offset=0x%x] success, value=0x%x\n", + i, addr, *buf); + break; + } + } + return rv; +} + +static int32_t dfd_ko_i2c_write_data(int bus, int addr, int offset, uint8_t data, uint32_t size) +{ + int i, rv; + for (i = 0; i < DFD_KO_CPLD_I2C_RETRY_TIMES; i++) { + rv = dfd_ko_i2c_smbus_transfer(I2C_SMBUS_WRITE, bus, addr, offset, &data, size); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "[%d]cpld write[offset=0x%x] fail, rv=%d\n", i, addr, rv); + msleep(DFD_KO_CPLD_I2C_RETRY_SLEEP); + } else { + DBG_DEBUG(DBG_VERBOSE, "[%d]cpld write[offset=0x%x, data=%d] success\n", i, addr, data); + break; + } + } + + return rv; +} + +static int32_t dfd_ko_cpld_i2c_read(int32_t addr, uint8_t *buf) +{ + int rv; + int sub_slot, cpld_id, cpld_addr; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_INDEX_INVALID; + } + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + cpld_addr = DFD_KO_CPLD_GET_INDEX(addr); + + i2c_dev = dfd_ko_get_cpld_i2c_dev(sub_slot, cpld_id); + if (i2c_dev == NULL) { + return -DFD_RV_DEV_NOTSUPPORT; + } + rv = dfd_ko_i2c_read_data(i2c_dev->bus, i2c_dev->addr, cpld_addr, buf, sizeof(uint8_t)); + + return rv; +} + +static int32_t dfd_ko_cpld_i2c_write(int32_t addr, uint8_t data) +{ + int rv; + int sub_slot, cpld_id, cpld_addr; + dfd_i2c_dev_t *i2c_dev; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + cpld_addr = DFD_KO_CPLD_GET_INDEX(addr); + + i2c_dev = dfd_ko_get_cpld_i2c_dev(sub_slot, cpld_id); + if (i2c_dev == NULL) { + return -DFD_RV_DEV_NOTSUPPORT; + } + + rv = dfd_ko_i2c_write_data(i2c_dev->bus, i2c_dev->addr, cpld_addr, data, sizeof(uint8_t)); + + return rv; +} + +static int32_t dfd_ko_cpld_io_read(int32_t addr, uint8_t *buf) +{ + int cpld_id, sub_slot, offset; + int key; + int *tmp; + uint16_t io_port; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + offset = DFD_KO_CPLD_GET_INDEX(addr); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_LPC_DEV, sub_slot, cpld_id); + tmp = dfd_ko_cfg_get_item(key); + if (tmp == NULL) { + DBG_DEBUG(DBG_ERROR,"get cpld io base config fail, key=0x%08x\n", key); + return -1; + } + + io_port = (u16)(*tmp) + offset; + *buf = inb(io_port); + DBG_DEBUG(DBG_VERBOSE, "read cpld io port addr 0x%x, data 0x%x\n", io_port, *buf); + + return DFD_RV_OK; + +} + +static int32_t dfd_ko_cpld_io_write(int32_t addr, uint8_t data) +{ + int cpld_id, sub_slot, offset; + int key; + int *tmp; + uint16_t io_port; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + offset = DFD_KO_CPLD_GET_INDEX(addr); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_LPC_DEV, sub_slot, cpld_id); + tmp = dfd_ko_cfg_get_item(key); + if (tmp == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld io base config fail, key=0x%08x\n", key); + return -1; + } + + io_port = (u16)(*tmp) + offset; + DBG_DEBUG(DBG_VERBOSE, "write cpld io port addr 0x%x, data 0x%x\n", io_port, data); + outb(data, (u16)io_port); + + return DFD_RV_OK; +} + +static int dfd_cfg_get_cpld_mode(int sub_slot, int cpld_id, int *mode) +{ + int key; + char *name; + + if (mode == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_TYPE_ERR; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_MODE, sub_slot, cpld_id); + name = dfd_ko_cfg_get_item(key); + if (name == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld[%d] mode info ctrl fail, key=0x%08x\n", cpld_id, key); + return -DFD_RV_NODE_FAIL; + } + + DBG_DEBUG(DBG_VERBOSE, "cpld_id %d mode_name %s.\n", cpld_id, name); + if (!strncmp(name, DFD_KO_CPLD_MODE_I2C_STRING, strlen(DFD_KO_CPLD_MODE_I2C_STRING))) { + *mode = DFD_CPLD_MODE_I2C; + } else if (!strncmp(name, DFD_KO_CPLD_MODE_LPC_STRING, strlen(DFD_KO_CPLD_MODE_LPC_STRING))) { + *mode = DFD_CPLD_MODE_LPC; + } else { + + *mode = DFD_CPLD_MODE_I2C; + } + + DBG_DEBUG(DBG_VERBOSE, "cpld_id %d mode %d.\n", cpld_id, *mode); + return 0; +} + +int32_t dfd_ko_cpld_read(int32_t addr, uint8_t *buf) +{ + int ret; + int sub_slot, cpld_id; + int cpld_mode; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + + ret = dfd_cfg_get_cpld_mode(sub_slot, cpld_id, &cpld_mode); + if (ret) { + DBG_DEBUG(DBG_WARN, "drv_get_cpld_mode sub_slot %d cpldid %d faile, set default i2c mode.\n", sub_slot, cpld_id); + cpld_mode = DFD_CPLD_MODE_I2C; + } + + if (cpld_mode == DFD_CPLD_MODE_I2C) { + ret = dfd_ko_cpld_i2c_read(addr, buf); + } else if (cpld_mode == DFD_CPLD_MODE_LPC) { + ret = dfd_ko_cpld_io_read(addr, buf); + } else { + DBG_DEBUG(DBG_ERROR, "cpld_mode %d invalid.\n", cpld_mode); + ret = -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_DEBUG(DBG_VERBOSE, "addr 0x%x val 0x%x ret %d\n", addr, *buf, ret); + return ret; +} + +int32_t dfd_ko_cpld_write(int32_t addr, uint8_t val) +{ + int ret; + int sub_slot, cpld_id, cpld_mode; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + + ret = dfd_cfg_get_cpld_mode(sub_slot, cpld_id, &cpld_mode); + if (ret) { + DBG_DEBUG(DBG_ERROR, "drv_get_cpld_mode sub_slot %d cpldid %d faile, set default local_bus mode.\n", sub_slot, cpld_id); + cpld_mode = DFD_CPLD_MODE_I2C; + } + + if (cpld_mode == DFD_CPLD_MODE_I2C) { + ret = dfd_ko_cpld_i2c_write(addr, val); + } else if (cpld_mode == DFD_CPLD_MODE_LPC) { + ret = dfd_ko_cpld_io_write(addr, val); + } else { + DBG_DEBUG(DBG_ERROR, "cpld_mode %d invalid.\n", cpld_mode); + ret = -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_DEBUG(DBG_VERBOSE, "addr 0x%x val 0x%x ret %d\n", addr, val, ret); + return ret; +} + +int32_t dfd_ko_i2c_read(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + + for (i = 0; i < size; i++) { + rv = dfd_ko_i2c_read_data(bus, addr, offset, &buf[i], sizeof(uint8_t)); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_read[bus=%d addr=0x%x offset=0x%x]fail, rv=%d\n", + bus, addr, offset, rv); + return rv; + } + offset++; + } + + return size; +} + +int32_t dfd_ko_i2c_write(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + + for (i = 0; i < size; i++) { + rv = dfd_ko_i2c_write_data(bus, addr, offset, buf[i], sizeof(uint8_t)); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_write[bus=%d addr=0x%x offset=0x%x]fail, rv=%d\n", + bus, addr, offset, rv); + return rv; + } + offset++; + } + + return size; + +} + +int32_t dfd_ko_read_file(char *fpath, int32_t addr, uint8_t *val, int32_t read_bytes) +{ + int32_t ret; + struct file *filp; + loff_t pos; + + if ((fpath == NULL) || (val == NULL) || (addr < 0) || (read_bytes < 0)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, addr=%d read_bytes=%d\n", addr, read_bytes); + return -DFD_RV_INDEX_INVALID; + } + + filp = filp_open(fpath, O_RDONLY, 0); + if (IS_ERR(filp)){ + DBG_DEBUG(DBG_ERROR, "open file[%s] fail\n", fpath); + return -DFD_RV_DEV_FAIL; + } + + pos = addr; + ret = kernel_read(filp, val, read_bytes, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_ERROR, "kernel_read failed, path=%s, addr=%d, size=%d, ret=%d\n", fpath, addr, read_bytes, ret); + ret = -DFD_RV_DEV_FAIL; + } + + filp_close(filp, NULL); + return ret; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_file.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_file.c new file mode 100644 index 000000000000..ffb96992d3d6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_file.c @@ -0,0 +1,239 @@ +/* + * Copyright(C) 2001-2015s Ruijie Network. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../include/dfd_cfg_file.h" +#include "../include/dfd_module.h" + +struct getdents_callback { + struct dir_context ctx; + const char *obj_name; + char *match_name; + int dir_len; + int found; +}; + +int kfile_open(char *fname, kfile_ctrl_t *kfile_ctrl) +{ + int ret; + struct file *filp; + loff_t pos; + + if ((fname == NULL) || (kfile_ctrl == NULL)) { + return KFILE_RV_INPUT_ERR; + } + + filp = filp_open(fname, O_RDONLY, 0); + if (IS_ERR(filp)){ + return KFILE_RV_OPEN_FAIL; + } + + kfile_ctrl->size = filp->f_inode->i_size; + + kfile_ctrl->buf = kmalloc(kfile_ctrl->size, GFP_KERNEL); + if (kfile_ctrl->buf == NULL) { + ret = KFILE_RV_MALLOC_FAIL; + goto close_fp; + } + memset(kfile_ctrl->buf, 0, kfile_ctrl->size); + + pos = 0; + ret = kernel_read(filp, kfile_ctrl->buf, kfile_ctrl->size, &pos); + if (ret < 0) { + ret = KFILE_RV_RD_FAIL; + goto free_buf; + } + + kfile_ctrl->pos = 0; + + ret = KFILE_RV_OK; + goto close_fp; + +free_buf: + kfree(kfile_ctrl->buf); + kfile_ctrl->buf = NULL; + +close_fp: + filp_close(filp, NULL); + return ret; +} + +void kfile_close(kfile_ctrl_t *kfile_ctrl) +{ + if (kfile_ctrl == NULL) { + return; + } + + kfile_ctrl->size = 0; + kfile_ctrl->pos = 0; + if (kfile_ctrl->buf) { + kfree(kfile_ctrl->buf); + kfile_ctrl->buf = NULL; + } +} + +int kfile_gets(char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl) +{ + int i; + int has_cr = 0; + + if ((buf == NULL) || (buf_size <= 0) || (kfile_ctrl == NULL) || (kfile_ctrl->buf == NULL) + || (kfile_ctrl->size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + memset(buf, 0, buf_size); + for (i = 0; i < buf_size; i++) { + + if (kfile_ctrl->pos >= kfile_ctrl->size) { + break; + } + + if (has_cr) { + break; + } + + if (IS_CR(kfile_ctrl->buf[kfile_ctrl->pos])) { + has_cr = 1; + } + + buf[i] = kfile_ctrl->buf[kfile_ctrl->pos]; + kfile_ctrl->pos++; + } + + return i; +} + +int kfile_read(int32_t addr, char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl) +{ + int i; + + if ((buf == NULL) || (buf_size <= 0) || (kfile_ctrl == NULL) || (kfile_ctrl->buf == NULL) + || (kfile_ctrl->size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + if ((addr < 0) || (addr >= kfile_ctrl->size)) { + return KFILE_RV_ADDR_ERR; + } + + memset(buf, 0, buf_size); + + kfile_ctrl->pos = addr; + for (i = 0; i < buf_size; i++) { + + if (kfile_ctrl->pos >= kfile_ctrl->size) { + break; + } + + buf[i] = kfile_ctrl->buf[kfile_ctrl->pos]; + kfile_ctrl->pos++; + } + + return i; +} + +static int kfile_filldir_one(struct dir_context *ctx, const char * name, int len, + loff_t pos, u64 ino, unsigned int d_type) +{ + struct getdents_callback *buf ; + int result; + buf = container_of(ctx, struct getdents_callback, ctx); + result = 0; + if (strncmp(buf->obj_name, name, strlen(buf->obj_name)) == 0) { + if (buf->dir_len < len) { + DBG_DEBUG(DBG_ERROR, "match ok. dir name:%s, but buf_len %d small than dir len %d.\n", + name, buf->dir_len, len); + buf->found = 0; + return -1; + } + memset(buf->match_name, 0 , buf->dir_len); + memcpy(buf->match_name, name, len); + buf->found = 1; + result = -1; + } + return result; +} + +int kfile_iterate_dir(const char *dir_path, const char *obj_name, char *match_name, int len) +{ + int ret; + struct file *dir; + struct getdents_callback buffer = { + .ctx.actor = kfile_filldir_one, + }; + + if(!dir_path || !obj_name || !match_name) { + DBG_DEBUG(DBG_ERROR, "params error. \n"); + return KFILE_RV_INPUT_ERR; + } + buffer.obj_name = obj_name; + buffer.match_name = match_name; + buffer.dir_len = len; + buffer.found = 0; + + dir = filp_open(dir_path, O_RDONLY, 0); + if (IS_ERR(dir)) { + DBG_DEBUG(DBG_ERROR, "filp_open error, dir path:%s\n", dir_path); + return KFILE_RV_OPEN_FAIL; + } + ret = iterate_dir(dir, &buffer.ctx); + if (buffer.found) { + DBG_DEBUG(DBG_VERBOSE, "match ok, dir name:%s\n", match_name); + filp_close(dir, NULL); + return DFD_RV_OK; + } + filp_close(dir, NULL); + return -DFD_RV_NODE_FAIL; +} + +#if 0 + +int kfile_write(char *fpath, int32_t addr, char *buf, int buf_size) +{ + int ret = KFILE_RV_OK; + struct file *filp; + mm_segment_t old_fs; + int wlen; + + if ((fpath == NULL) || (buf == NULL) || (buf_size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + if (addr < 0) { + return KFILE_RV_ADDR_ERR; + } + + filp = filp_open(fpath, O_RDWR, 0); + if (IS_ERR(filp)){ + return KFILE_RV_OPEN_FAIL; + } + + old_fs = get_fs(); + set_fs(KERNEL_DS); + + filp->f_op->llseek(filp,0,0); + filp->f_pos = addr; + + wlen = filp->f_op->write(filp, buf, buf_size, &(filp->f_pos)); + if (wlen < 0) { + ret = KFILE_RV_WR_FAIL; + } + + filp->f_op->llseek(filp,0,0); + set_fs(old_fs); + filp_close(filp, NULL); + + return ret; +} +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_info.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_info.c new file mode 100644 index 000000000000..50e7dbf126d7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_info.c @@ -0,0 +1,590 @@ +/* + * Copyright(C) 2013 Ruijie Network. All rights reserved. + */ + +#include +#include +#include + +#include "../include/dfd_module.h" +#include "../include/dfd_cfg_adapter.h" +#include "../include/dfd_cfg.h" +#include "../include/dfd_cfg_info.h" +#include "../include/dfd_cfg_file.h" + +#define DFD_HWMON_NAME "hwmon" +#define DFD_GET_CPLD_VOLATGE_CODE_VALUE(value) ((value >> 4)& 0xfff) +#define DFD_GET_CPLD_VOLATGE_REAL_VALUE(code_val, k) ((code_val * 16 * 33 * k) / ((65536 - 5000) * 10)) + +char *g_info_ctrl_mem_str[INFO_CTRL_MEM_END] = { + ".mode", + ".int_cons", + ".src", + ".frmt", + ".pola", + ".fpath", + ".addr", + ".len", + ".bit_offset", + ".str_cons", + ".int_extra1", + ".int_extra2", +}; + +char *g_info_ctrl_mode_str[INFO_CTRL_MODE_END] = { + "none", + "config", + "constant", + "tlv", + "str_constant", +}; + +char *g_info_src_str[INFO_SRC_END] = { + "none", + "cpld", + "fpga", + "other_i2c", + "file", +}; + +char *g_info_frmt_str[INFO_FRMT_END] = { + "none", + "bit", + "byte", + "num_bytes", + "num_str", + "num_buf", + "buf", +}; + +char *g_info_pola_str[INFO_POLA_END] = { + "none", + "positive", + "negative", +}; + +static int dfd_read_info_from_cpld(int32_t addr, int read_bytes, uint8_t *val) +{ + int i, rv; + + for (i = 0; i < read_bytes; i++) { + rv = dfd_ko_cpld_read(addr, &(val[i])); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "read info[addr=0x%x read_bytes=%d] from cpld fail, reading_byte=%d rv=%d\n", + addr, read_bytes, i, rv); + return rv; + } + addr++; + } + + return read_bytes; +} + +static int dfd_write_info_to_cpld(int32_t addr, int write_bytes, uint8_t *val, uint8_t bit_mask) +{ + int rv; + uint8_t val_tmp; + + if (bit_mask != 0xff) { + rv = dfd_ko_cpld_read(addr, &val_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "read original info[addr=0x%x] from cpld fail, rv=%d\n", addr, rv); + return -1; + } + + val_tmp = (val_tmp & (~bit_mask)) | (val[0] & bit_mask); + } else { + val_tmp = val[0]; + } + + rv = dfd_ko_cpld_write(addr, val_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "write info[addr=0x%x val=0x%x] to cpld fail, rv=%d\n", addr, val_tmp, rv); + return -1; + } + + return 0; +} + +static int dfd_read_info(info_src_t src, char *fpath, int32_t addr, int read_bytes, uint8_t *val) +{ + int rv = 0; + + switch (src) { + case INFO_SRC_CPLD: + rv = dfd_read_info_from_cpld(addr, read_bytes, val); + break; + case INFO_SRC_FPGA: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support read info from fpga\n"); + break; + case INFO_SRC_OTHER_I2C: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support read info from other i2c\n"); + break; + case INFO_SRC_FILE: + rv = dfd_ko_read_file(fpath, addr, val, read_bytes); + break; + default: + rv = -1; + DBG_DEBUG(DBG_ERROR, "info src[%d] error\n", src); + break; + } + + return rv; +} + +static int dfd_write_info(info_src_t src, char *fpath, int32_t addr, int write_bytes, uint8_t *val, uint8_t bit_mask) +{ + int rv = 0; + + switch (src) { + case INFO_SRC_CPLD: + rv = dfd_write_info_to_cpld(addr, write_bytes, val, bit_mask); + break; + case INFO_SRC_FPGA: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to fpga\n"); + break; + case INFO_SRC_OTHER_I2C: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to other i2c\n"); + break; + case INFO_SRC_FILE: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to file\n"); + break; + default: + rv = -1; + DBG_DEBUG(DBG_ERROR, "info src[%d] error\n", src); + break; + } + + return rv; +} + +int dfd_info_get_int(int key, int *ret, info_num_buf_to_value_f pfun) +{ + int i, rv; + int read_bytes, readed_bytes, int_tmp; + uint8_t byte_tmp, val[INFO_INT_MAX_LEN + 1] = {0}; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || (ret == NULL)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode == INFO_CTRL_MODE_CONS) { + *ret = info_ctrl->int_cons; + return DFD_RV_OK; + } else if (info_ctrl->mode == INFO_CTRL_MODE_TLV) { + return INFO_CTRL_MODE_TLV; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + + if (!INFO_BIT_OFFSET_VALID(info_ctrl->bit_offset)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit_offsest[%d] invalid\n", + key, info_ctrl->bit_offset); + return -DFD_RV_TYPE_ERR; + } + + read_bytes = 1; + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt) || IS_INFO_FRMT_NUM_STR(info_ctrl->frmt) + || IS_INFO_FRMT_NUM_BUF(info_ctrl->frmt)) { + + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + read_bytes = info_ctrl->len; + } else { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] info format[%d] error\n", key, info_ctrl->frmt); + return -DFD_RV_TYPE_ERR; + } + + readed_bytes = dfd_read_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, read_bytes, &(val[0])); + if (readed_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read int info[key=0x%08x src=%s frmt=%s fpath=%s addr=0x%x read_bytes=%d] fail, rv=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, read_bytes, readed_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + + if (info_ctrl->pola == INFO_POLA_NEGA) { + val[0] = ~val[0]; + } + + byte_tmp = (val[0] >> info_ctrl->bit_offset) & (~(0xff << info_ctrl->len)); + + if (pfun) { + rv = pfun(&byte_tmp, sizeof(byte_tmp), &int_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit process fail, rv=%d\n", key, rv); + return rv; + } + } else { + int_tmp = (int)byte_tmp; + } + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt)) { + + int_tmp = 0; + for (i = 0; i < info_ctrl->len; i++) { + if (info_ctrl->pola == INFO_POLA_NEGA) { + int_tmp |= val[info_ctrl->len - i - 1]; + } else { + int_tmp |= val[i]; + } + + if (i != (info_ctrl->len - 1)) { + int_tmp <<= 8; + } + } + } else if (IS_INFO_FRMT_NUM_STR(info_ctrl->frmt)) { + + val[readed_bytes] = '\0'; + int_tmp = simple_strtol((char *)(&(val[0])), NULL, 10); + } else { + if (pfun == NULL) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] number buf process function is null\n", key); + return -DFD_RV_INDEX_INVALID; + } + + rv = pfun(val, readed_bytes, &int_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] number buf process fail, rv=%d\n", key, rv); + return rv; + } + } + + *ret = int_tmp; + DBG_DEBUG(DBG_VERBOSE, "read int info[key=0x%08x src=%s frmt=%s pola=%s fpath=%s addr=0x%x len=%d bit_offset=%d] success, ret=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], g_info_pola_str[info_ctrl->pola], + info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, info_ctrl->bit_offset, *ret); + return DFD_RV_OK; +} + +int dfd_info_get_buf(int key, uint8_t *buf, int buf_len, info_buf_to_buf_f pfun) +{ + int rv; + int read_bytes, buf_real_len; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || (buf == NULL)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode != INFO_CTRL_MODE_CFG) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] mode[%d] invalid\n", key, info_ctrl->mode); + return -DFD_RV_TYPE_ERR; + } + + if (!IS_INFO_FRMT_BUF(info_ctrl->frmt) || !INFO_BUF_LEN_VALAID(info_ctrl->len) + || (buf_len <= info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] format=%d or len=%d invlaid, buf_len=%d\n", + key, info_ctrl->frmt, info_ctrl->len, buf_len); + return -DFD_RV_TYPE_ERR; + } + + read_bytes = dfd_read_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, buf_tmp); + if (read_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read buf info[key=0x%08x src=%s frmt=%s fpath=%s addr=0x%x len=%d] fail, rv=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, info_ctrl->len, read_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] buf process fail, rv=%d\n", key, rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + } else { + buf_real_len = read_bytes; + memcpy(buf, buf_tmp, read_bytes); + } + + return buf_real_len; +} + +static int dfd_2key_info_get_buf(info_ctrl_t *info_ctrl, uint8_t *buf, int buf_len, info_hwmon_buf_f pfun) +{ + int rv; + int read_bytes, buf_real_len; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + char temp_fpath[INFO_FPATH_MAX_LEN]; + + if (!IS_INFO_FRMT_BUF(info_ctrl->frmt) || !INFO_BUF_LEN_VALAID(info_ctrl->len) + || (buf_len <= info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "key_path info ctrl format=%d or len=%d invlaid, buf_len=%d\n", + info_ctrl->frmt, info_ctrl->len, buf_len); + return -DFD_RV_TYPE_ERR; + } + + memset(buf_tmp, 0 , sizeof(buf_tmp)); + rv = kfile_iterate_dir(info_ctrl->fpath, DFD_HWMON_NAME, buf_tmp, INFO_BUF_MAX_LEN); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dir patch:%s ,can find name %s dir \n", + info_ctrl->fpath, DFD_HWMON_NAME); + return -DFD_RV_NO_NODE; + } + memset(temp_fpath, 0 , sizeof(temp_fpath)); + snprintf(temp_fpath, sizeof(temp_fpath), "%s%s/%s", + info_ctrl->fpath, buf_tmp, info_ctrl->str_cons); + DBG_DEBUG(DBG_VERBOSE, "match ok path = %s \n", temp_fpath); + + memset(buf_tmp, 0, sizeof(buf_tmp)); + + read_bytes = dfd_read_info(info_ctrl->src, temp_fpath, info_ctrl->addr, info_ctrl->len, buf_tmp); + if (read_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read buf info[src=%s frmt=%s fpath=%s addr=0x%x len=%d] fail, rv=%d\n", + g_info_src_str[info_ctrl->src], g_info_src_str[info_ctrl->frmt], temp_fpath, + info_ctrl->addr, info_ctrl->len, read_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len, info_ctrl); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl buf process fail, rv=%d\n", rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + } else { + buf_real_len = read_bytes; + memcpy(buf, buf_tmp, buf_real_len); + } + return buf_real_len; +} + +int dfd_info_set_int(int key, int val) +{ + int rv; + int write_bytes; + uint8_t byte_tmp, bit_mask; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key))) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode != INFO_CTRL_MODE_CFG) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] mode[%d] warnning\n", key, info_ctrl->mode); + return -DFD_RV_TYPE_ERR; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + + if (!INFO_BIT_OFFSET_VALID(info_ctrl->bit_offset)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit_offsest[%d] invalid\n", + key, info_ctrl->bit_offset); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + + byte_tmp = (uint8_t)(val & 0xff); + byte_tmp <<= info_ctrl->bit_offset; + if (info_ctrl->pola == INFO_POLA_NEGA) { + byte_tmp = ~byte_tmp; + } + + bit_mask = (~(0xff << info_ctrl->len)) << info_ctrl->bit_offset; + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt)) { + + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + + byte_tmp = (uint8_t)(val & 0xff); + + bit_mask = 0xff; + } else if (IS_INFO_FRMT_NUM_STR(info_ctrl->frmt)) { + + DBG_DEBUG(DBG_ERROR, "not support str int set\n"); + return -1; + } else if (IS_INFO_FRMT_NUM_BUF(info_ctrl->frmt)) { + + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + + byte_tmp = (uint8_t)(val & 0xff); + + bit_mask = 0xff; + } else { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] format[%d] error\n", key, info_ctrl->frmt); + return -DFD_RV_TYPE_ERR; + } + + rv = dfd_write_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, write_bytes, + &byte_tmp, bit_mask); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "write int info[src=%s frmt=%s fpath=%s addr=0x%x len=%d val=%d] fail, rv=%d\n", + g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, info_ctrl->len, val, rv); + return -DFD_RV_DEV_FAIL; + } + + DBG_DEBUG(DBG_VERBOSE, "write int info[src=%s frmt=%s pola=%s fpath=%s addr=0x%x len=%d bit_offset=%d val=%d] success\n", + g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], g_info_pola_str[info_ctrl->pola], + info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, info_ctrl->bit_offset, val); + return DFD_RV_OK; +} + +static int dfd_info_get_cpld_voltage(int key, int *value) +{ + int rv, addr_tmp; + int vol_ref_tmp, vol_ref; + int vol_curr_tmp, vol_curr; + info_ctrl_t *info_ctrl; + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + rv = dfd_info_get_int(key, &vol_curr_tmp, NULL); + if(rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld current voltage error, addr:0x%x, rv =%d\n", info_ctrl->addr, rv); + return rv; + } + vol_curr_tmp = DFD_GET_CPLD_VOLATGE_CODE_VALUE(vol_curr_tmp); + if(info_ctrl->addr == info_ctrl->int_extra1) { + + vol_curr = DFD_GET_CPLD_VOLATGE_REAL_VALUE(vol_curr_tmp, info_ctrl->int_extra2); + } else { + + addr_tmp = info_ctrl->addr; + info_ctrl->addr = info_ctrl->int_extra1; + rv = dfd_info_get_int(key, &vol_ref_tmp, NULL); + info_ctrl->addr = addr_tmp; + if(rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld reference voltage error, addr:0x%x rv:%d\n", info_ctrl->addr, rv); + return rv; + } + vol_ref = DFD_GET_CPLD_VOLATGE_CODE_VALUE(vol_ref_tmp); + vol_curr = (vol_curr_tmp * info_ctrl->int_extra2) / vol_ref; + } + *value = vol_curr; + return DFD_RV_OK; +} + +static int dfd_info_get_sensor_value(int key, uint8_t *buf, int buf_len, info_hwmon_buf_f pfun) +{ + int rv, buf_real_len; + int value; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + info_ctrl_t *info_ctrl; + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_ERROR, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if ( DFD_CFG_ITEM_ID(key) == DFD_CFG_ITEM_HWMON_IN && info_ctrl->src == INFO_SRC_CPLD) { + + rv = dfd_info_get_cpld_voltage(key, &value); + if(rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld voltage failed.key=0x%08x, rv:%d\n", key, rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + DBG_DEBUG(DBG_VERBOSE, "get cpld voltage ok, value:%d\n", value); + memset(buf_tmp, 0 ,sizeof(buf_tmp)); + snprintf(buf_tmp, sizeof(buf_tmp), "%d\n", value); + buf_real_len = strlen(buf_tmp); + if(buf_len <= buf_real_len) { + DBG_DEBUG(DBG_ERROR, "length not enough.buf_len:%d,need length:%d\n", buf_len, buf_real_len); + return -DFD_RV_DEV_FAIL; + } + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, strlen(buf_tmp), buf, &buf_real_len, info_ctrl); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "deal date error.org value:%s, buf_len:%d, rv=%d\n", + buf_tmp, buf_len, rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + } else { + memcpy(buf, buf_tmp, buf_real_len); + } + return buf_real_len; + } + + DBG_DEBUG(DBG_ERROR, "not support mode. key:0x%08x\n", key); + return -DFD_RV_MODE_NOTSUPPORT; +} + +int dfd_info_get_sensor(uint32_t key, char *buf, int buf_len, info_hwmon_buf_f pfun) +{ + info_ctrl_t *key_info_ctrl; + int rv; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || + (buf == NULL) || buf_len <= 0) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key_path=0x%08x, buf_len:%d.\n", + key, buf_len); + return -DFD_RV_INVALID_VALUE; + } + + key_info_ctrl = dfd_ko_cfg_get_item(key); + if (key_info_ctrl == NULL) { + DBG_DEBUG(DBG_ERROR, "key_path info error, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + memset(buf, 0 , buf_len); + + if (key_info_ctrl->mode == INFO_CTRL_MODE_SRT_CONS) { + snprintf(buf, buf_len, "%s\n", key_info_ctrl->str_cons); + DBG_DEBUG(DBG_VERBOSE, "get sensor value through string config, key=0x%08x, value:%s\n", key, buf); + return strlen(buf); + } + + if (key_info_ctrl->mode == INFO_CTRL_MODE_CFG && key_info_ctrl->src == INFO_SRC_FILE) { + DBG_DEBUG(DBG_VERBOSE, "get sensor value through hwmon, key:0x%08x\n", key); + rv = dfd_2key_info_get_buf(key_info_ctrl, buf, buf_len, pfun); + if (rv < 0) { + DBG_DEBUG(DBG_VERBOSE, "get sensor value through hwmon failed, key:0x%08x, rv:%d\n", key, rv); + } + return rv; + } + rv = dfd_info_get_sensor_value(key, buf, buf_len, pfun); + if( rv < 0) { + DBG_DEBUG(DBG_ERROR, "get sensor value failed, key=0x%08x, rv:%d.\n", key, rv); + } + return rv; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_listnode.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_listnode.c new file mode 100644 index 000000000000..056d98ffdc42 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_cfg_listnode.c @@ -0,0 +1,85 @@ +/* + * Copyright(C) 2001-2015 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "../include/dfd_cfg_listnode.h" + +void *lnode_find_node(lnode_root_t *root, int key) +{ + lnode_node_t *lnode; + + if (root == NULL){ + return NULL; + } + + list_for_each_entry(lnode, &(root->root), lst) { + if (lnode->key == key) { + return lnode->data; + } + } + + return NULL; +} + +int lnode_insert_node(lnode_root_t *root, int key, void *data) +{ + lnode_node_t *lnode; + void *data_tmp; + + if ((root == NULL) || (data == NULL)) { + return LNODE_RV_INPUT_ERR; + } + + data_tmp = lnode_find_node(root, key); + if (data_tmp != NULL) { + return LNODE_RV_NODE_EXIST; + } + + lnode = kmalloc(sizeof(lnode_node_t), GFP_KERNEL); + if (lnode == NULL) { + return LNODE_RV_NOMEM; + } + + lnode->key = key; + lnode->data = data; + list_add_tail(&(lnode->lst), &(root->root)); + + return LNODE_RV_OK; +} + +int lnode_init_root(lnode_root_t *root) +{ + if (root == NULL) { + return LNODE_RV_INPUT_ERR; + } + + INIT_LIST_HEAD(&(root->root)); + + return LNODE_RV_OK; +} + +void lnode_free_list(lnode_root_t *root) +{ + lnode_node_t *lnode, *lnode_next; + + if (root == NULL){ + return ; + } + + list_for_each_entry_safe(lnode, lnode_next, &(root->root), lst) { + if ( lnode->data ) { + kfree(lnode->data); + lnode->data = NULL; + lnode->key = 0; + } + list_del(&lnode->lst); + kfree(lnode); + lnode = NULL; + } + + return ; + +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_frueeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_frueeprom.c new file mode 100644 index 000000000000..b0d885218907 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_frueeprom.c @@ -0,0 +1,496 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include +#include +#include + +#include "../include/dfd_frueeprom.h" +#include "../include/dfd_cfg_adapter.h" +#include "../include/dfd_module.h" +#include "../../rg_dev_sysfs/include/rg_sysfs_common.h" + +int g_dfd_fru_dbg_level = 0; +module_param(g_dfd_fru_dbg_level, int, S_IRUGO | S_IWUSR); + +/** + * Takes the pointer to stream of bytes and length + * and returns the 8 bit checksum + * This algo is per IPMI V2.0 spec + */ +static unsigned char ipmi_calculate_crc(const unsigned char *data, size_t len) +{ + char crc = 0; + size_t byte = 0; + + for(byte = 0; byte < len; byte++) + { + crc += *data++; + } + + return(-crc); +} + +/* Validates the data for crc and mandatory fields */ +static int ipmi_verify_fru_data(const uint8_t *data, const size_t len) +{ + uint8_t checksum = 0; + int rc = -DFD_RV_TYPE_ERR; + + /* Validate for first byte to always have a value of [1] */ + if(data[0] != IPMI_FRU_HDR_BYTE_ZERO) + { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid entry:[%d] in byte-0\n",data[0]); + return rc; + } else { + DBG_FRU_DEBUG(DBG_VERBOSE, "SUCCESS: Validated [0x%X] in entry_1 of fru_data\n",data[0]); + } + + /* See if the calculated CRC matches with the embedded one. + * CRC to be calculated on all except the last one that is CRC itself.*/ + checksum = ipmi_calculate_crc(data, len - 1); + if(checksum != data[len-1]) + { + DBG_FRU_DEBUG(DBG_ERROR, "Checksum mismatch." + " Calculated:[0x%X], Embedded:[0x%X]\n", + checksum, data[len - 1]); + return rc; + } else { + DBG_FRU_DEBUG(DBG_VERBOSE, "SUCCESS: Checksum matches:[0x%X]\n",checksum); + } + + return 0; +} + +/* private method to parse type/length */ +static int ipmi_parse_type_length (const void *areabuf, + unsigned int areabuflen, + unsigned int current_area_offset, + uint8_t *number_of_data_bytes, + ipmi_fru_field_t *field) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + uint8_t type_length; + uint8_t type_code; + + type_length = areabufptr[current_area_offset]; + + /* ipmi workaround + * + * dell p weredge r610 + * + * my reading of the fru spec is that all non-custom fields are + * required to be listed by the vendor. however, on this + * motherboard, some areas list this, indicating that there is + * no more data to be parsed. so now, for "required" fields, i + * check to see if the type-length field is a sentinel before + * calling this function. + */ + + type_code = (type_length & IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK) >> IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT; + (*number_of_data_bytes) = type_length & IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK; + + /* special case: this shouldn't be a length of 0x01 (see type/length + * byte format in fru information storage definition). + */ + DBG_FRU_DEBUG(DBG_VERBOSE, "areabuflen:%d, current_area_offset:0x%x, type_code:0x%x, number_of_data_bytes:%d\n", + areabuflen, current_area_offset, type_code, *number_of_data_bytes ); + if (type_code == IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE + && (*number_of_data_bytes) == 0x01) { + DBG_FRU_DEBUG(DBG_ERROR, "fru type length error.value:0x%x\n", type_length); + return (-1); + } + + if ((current_area_offset + 1 + (*number_of_data_bytes)) > areabuflen) { + DBG_FRU_DEBUG(DBG_ERROR, "buf length error. current_area_offset:0x%x, need length:%d, total length:0x%x\n", + current_area_offset, *number_of_data_bytes, areabuflen ); + return (-1); + } + + if (field) { + memset (field->type_length_field, '\0', IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX); + memcpy (field->type_length_field, &areabufptr[current_area_offset + 1], *number_of_data_bytes); + DBG_FRU_DEBUG(DBG_VERBOSE, "fru parse ok. value:%s\n", field->type_length_field); + field->type_length_field_length = *number_of_data_bytes; + } + + return (0); +} + +static int ipmi_fru_product_info_area(const void *areabuf, + unsigned int areabuflen, ipmi_product_info_t *ipmi_product_info) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + unsigned int area_offset = 2; + uint8_t number_of_data_bytes; + int rv; + ipmi_fru_field_t **ipmi_fru_field_point; + int ipmi_fru_field_len, i; + + if (!areabuf || !areabuflen || !ipmi_product_info) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid Parameter.\n"); + return -DFD_RV_INVALID_VALUE; + } + + /* Verify the crc and size */ + rv = ipmi_verify_fru_data(areabuf, areabuflen); + if(rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate fru product info data\n"); + return rv; + } + + ipmi_fru_field_len = (sizeof(ipmi_product_info_t) - sizeof(uint8_t *)) /(sizeof(ipmi_fru_field_t *)); + + if (ipmi_product_info->language_code) { + (*ipmi_product_info->language_code) = areabufptr[area_offset]; + } + area_offset++; + ipmi_fru_field_point = (ipmi_fru_field_t **)((uint8_t *)ipmi_product_info + sizeof(uint8_t *)); + for(i = 0; i < ipmi_fru_field_len; i++) { + if (*ipmi_fru_field_point) { + memset(*ipmi_fru_field_point, '\0', sizeof(ipmi_fru_field_t)); + } + + if ((areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) || (area_offset == areabuflen - 1)) { + rv = 0; + break; + } + + rv = ipmi_parse_type_length(areabufptr, areabuflen, area_offset, &number_of_data_bytes, *ipmi_fru_field_point); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "[%d] _parse_type_length area_offset[%d] rv=%d \n", i, area_offset, rv); + break; + } + + area_offset += 1; /* type/length byte */ + area_offset += number_of_data_bytes; + ipmi_fru_field_point++; + } + + return (rv); +} + +static int ipmi_fru_board_info_area(const void *areabuf, + unsigned int areabuflen, ipmi_board_info_t *ipmi_board_info) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + unsigned int area_offset = 2; + uint8_t number_of_data_bytes; + int rv; + ipmi_fru_field_t **ipmi_fru_field_point; + int ipmi_fru_field_len, i; + + if (!areabuf || !areabuflen || !ipmi_board_info) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid Parameter.\n"); + return -DFD_RV_INVALID_VALUE; + } + + /* Verify the crc and size */ + rv = ipmi_verify_fru_data(areabuf, areabuflen); + if(rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate fru product info data\n"); + return rv; + } + + ipmi_fru_field_len = (sizeof(ipmi_board_info_t) - sizeof(uint8_t *) - sizeof(uint8_t *)) /(sizeof(ipmi_fru_field_t *)); + + if (ipmi_board_info->language_code) { + (*ipmi_board_info->language_code) = areabufptr[area_offset]; + } + area_offset++; + + if (ipmi_board_info->mfg_time) { + memcpy(ipmi_board_info->mfg_time, &areabufptr[area_offset], IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH); + } + area_offset += IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH; + ipmi_fru_field_point = (ipmi_fru_field_t **)((uint8_t *)ipmi_board_info + sizeof(uint8_t *) + sizeof(uint8_t *)); + for(i = 0; i < ipmi_fru_field_len; i++) { + if (*ipmi_fru_field_point) { + memset(*ipmi_fru_field_point, '\0', sizeof(ipmi_fru_field_t)); + } + + if ((areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) || (area_offset == areabuflen - 1)) { + rv = 0; + break; + } + + rv = ipmi_parse_type_length(areabufptr, areabuflen, area_offset, &number_of_data_bytes, *ipmi_fru_field_point); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "[%d] _parse_type_length area_offset[%d] rv=%d \n", i, area_offset, rv); + break; + } + + area_offset += 1; /* type/length byte */ + area_offset += number_of_data_bytes; + ipmi_fru_field_point++; + } + + return (rv); +} + +/** + * Validates the fru data per ipmi common header constructs. + * Returns with updated common_hdr and also file_size + */ +static int ipmi_validate_common_hdr(const uint8_t *fru_data, const size_t data_len) +{ + int rc = -1; + + uint8_t common_hdr[sizeof(fru_common_header_t)] = {0}; + if(data_len >= sizeof(common_hdr)) + { + memcpy(common_hdr, fru_data, sizeof(common_hdr)); + } + else + { + DBG_FRU_DEBUG(DBG_ERROR, "Incomplete fru data file. Size:[%zd]\n", data_len); + return rc; + } + + /* Verify the crc and size */ + rc = ipmi_verify_fru_data(common_hdr, sizeof(common_hdr)); + if(rc < 0) + { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate common header\n"); + return rc; + } + + return 0; +} + +static int dfd_get_frue2prom_info(int bus, int dev_addr, fru_common_header_t *info) +{ + int ret; + uint8_t fru_common_header_info[sizeof(fru_common_header_t)]; + + if (info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, 0, (uint8_t *)info, sizeof(fru_common_header_t)); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom head info error(bus: %d, addr: 0x%02x).\n", bus, dev_addr); + return ret; + } + + memcpy(fru_common_header_info, (uint8_t *)info, sizeof(fru_common_header_t)); + + if (ipmi_validate_common_hdr(fru_common_header_info, sizeof(fru_common_header_t)) != 0) { + return -DFD_RV_TYPE_ERR; + } + + return DFD_RV_OK; +} + +static int dfd_set_fru_product_info(ipmi_product_info_t *ipmi_product_info, ipmi_fru_field_t *vpd_info, int type) +{ + int ret; + ret = DFD_RV_OK; + if (ipmi_product_info == NULL || vpd_info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset((uint8_t *)ipmi_product_info, 0, sizeof(ipmi_product_info_t)); + switch(type) { + case DFD_DEV_INFO_TYPE_SN: + ipmi_product_info->product_serial_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_NAME: + ipmi_product_info->product_name = vpd_info; + break; + case DFD_DEV_INFO_TYPE_DEV_TYPE: + ipmi_product_info->product_type_fields = vpd_info; + break; + case DFD_DEV_INFO_TYPE_HW_INFO: + ipmi_product_info->product_version = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NAME: + ipmi_product_info->product_part_model_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NUMBER: + ipmi_product_info->product_part_model_number = vpd_info; + break; + default: + ret = -1; + break; + } + + return ret; +} + +static int dfd_set_fru_board_info(ipmi_board_info_t *ipmi_board_info, ipmi_fru_field_t *vpd_info, int type) +{ + int ret; + ret = DFD_RV_OK; + if (ipmi_board_info == NULL || vpd_info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset((uint8_t *)ipmi_board_info, 0, sizeof(ipmi_board_info_t)); + switch(type) { + case DFD_DEV_INFO_TYPE_SN: + ipmi_board_info->board_serial_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_NAME: + ipmi_board_info->board_product_name = vpd_info; + break; + case DFD_DEV_INFO_TYPE_HW_INFO: + ipmi_board_info->board_custom_fields = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NUMBER: + ipmi_board_info->board_part_number = vpd_info; + break; + default: + ret = -1; + break; + } + + return ret; +} + +int dfd_get_fru_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len) +{ + fru_common_header_t info; + uint8_t *fru_data; + int ret; + uint8_t fru_len; + ipmi_product_info_t ipmi_product_info; + ipmi_fru_field_t vpd_info; + int product_offset; + int fru_len_tmp; + + if (buf == NULL || buf_len <= 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + DBG_FRU_DEBUG(DBG_VERBOSE, "Read fru eeprom (bus: %d, addr: 0x%02x, type:%d, buf: %p, len: %d).\n", + bus, dev_addr, type, buf, buf_len); + + ret = dfd_get_frue2prom_info(bus, dev_addr, &info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom info head error(bus: %d, addr: 0x%02x, buf: %p, len: %d).\n", + bus, dev_addr, buf, buf_len); + return ret; + } + + product_offset = info.product_offset * IPMI_EIGHT_BYTES; + ret = dfd_ko_i2c_read(bus, dev_addr, product_offset + 1, &fru_len, 1); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "read eeprom info product_offset(bus: %d, addr: 0x%02x, product offset:%d).\n", + bus, dev_addr, info.product_offset); + return -DFD_RV_DEV_FAIL; + } + + fru_len_tmp = fru_len * IPMI_EIGHT_BYTES; + fru_data = (uint8_t *)kmalloc(sizeof(uint8_t) * fru_len_tmp, GFP_KERNEL); + if (fru_data == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Allocate buffer(len:%d) error!\n", fru_len_tmp); + return -DFD_RV_NO_MEMORY; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, product_offset, fru_data, fru_len_tmp); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Get FRU data error.\n"); + kfree(fru_data); + return ret; + } + + memset((uint8_t *)&vpd_info, 0, sizeof(ipmi_fru_field_t)); + ret = dfd_set_fru_product_info(&ipmi_product_info, &vpd_info, type); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Not support to get info: %d.\n", type); + kfree(fru_data); + return ret; + } + + ret = ipmi_fru_product_info_area(fru_data, fru_len_tmp, &ipmi_product_info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "analysis FRU product info error.\n"); + kfree(fru_data); + return ret; + } + + kfree(fru_data); + + buf_len = buf_len < vpd_info.type_length_field_length ? buf_len : vpd_info.type_length_field_length; + memcpy(buf, (uint8_t *)&vpd_info, buf_len); + + return DFD_RV_OK; +} + +int dfd_get_fru_board_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len) +{ + fru_common_header_t info; + uint8_t *fru_data; + int ret; + uint8_t fru_len; + ipmi_board_info_t ipmi_board_info; + ipmi_fru_field_t vpd_info; + int board_offset; + int fru_len_tmp; + + if (buf == NULL || buf_len <= 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + DBG_FRU_DEBUG(DBG_VERBOSE, "Read fru eeprom (bus: %d, addr: 0x%02x, type:%d, buf: %p, len: %d).\n", + bus, dev_addr, type, buf, buf_len); + + ret = dfd_get_frue2prom_info(bus, dev_addr, &info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom info head error(bus: %d, addr: 0x%02x, buf: %p, len: %d).\n", + bus, dev_addr, buf, buf_len); + return ret; + } + + board_offset = info.board_offset * IPMI_EIGHT_BYTES; + ret = dfd_ko_i2c_read(bus, dev_addr, board_offset + 1, &fru_len, 1); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "read eeprom info product_offset(bus: %d, addr: 0x%02x, product offset:%d).\n", + bus, dev_addr, info.board_offset); + return -DFD_RV_DEV_FAIL; + } + + fru_len_tmp = fru_len * IPMI_EIGHT_BYTES; + fru_data = (uint8_t *)kmalloc(sizeof(uint8_t) * fru_len_tmp, GFP_KERNEL); + if (fru_data == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Allocate buffer(len:%d) error!\n", fru_len_tmp); + return -DFD_RV_NO_MEMORY; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, board_offset, fru_data, fru_len_tmp); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Get FRU data error.\n"); + kfree(fru_data); + return ret; + } + + memset((uint8_t *)&vpd_info, 0, sizeof(ipmi_fru_field_t)); + ret = dfd_set_fru_board_info(&ipmi_board_info, &vpd_info, type); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Not support to get info: %d.\n", type); + kfree(fru_data); + return ret; + } + + ret = ipmi_fru_board_info_area(fru_data, fru_len_tmp, &ipmi_board_info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "analysis FRU product info error.\n"); + kfree(fru_data); + return ret; + } + + kfree(fru_data); + + buf_len = buf_len < vpd_info.type_length_field_length ? buf_len : vpd_info.type_length_field_length; + memcpy(buf, (uint8_t *)&vpd_info, buf_len); + + return DFD_RV_OK; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_tlveeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_tlveeprom.c new file mode 100644 index 000000000000..d5819e5c6714 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/cfg/dfd_tlveeprom.c @@ -0,0 +1,474 @@ +/* + * Copyright (C) 2003-2014 FreeIPMI Core Team + * + * 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 3 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, see . + * + */ +/*****************************************************************************\ + * Copyright (C) 2007-2014 Lawrence Livermore National Security, LLC. + * Copyright (C) 2007 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Albert Chu + * UCRL-CODE-232183 + * + * This file is part of Ipmi-fru, a tool used for retrieving + * motherboard field replaceable unit (FRU) information. For details, + * see http://www.llnl.gov/linux/. + * + * Ipmi-fru 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 3 of the License, or (at your + * option) any later version. + * + * Ipmi-fru 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 Ipmi-fru. If not, see . +\*****************************************************************************/ +#include + +#include "../include/dfd_tlveeprom.h" +#include "../include/dfd_module.h" +#include "../../rg_dev_sysfs/include/rg_sysfs_common.h" + +/* using in is_valid_tlvinfo_header */ +static uint32_t g_eeprom_size; + +/* + * 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 , "ONIE 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"}, +}; + +#define TLV_CODE_NUM (sizeof(tlv_code_list) / sizeof(tlv_code_list[0])) + +const unsigned long g_crc_table[] = { + 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 long crc, const unsigned char *buf, unsigned len) +{ + unsigned i; + if (len < 1) + return 0xffffffff; + + for (i = 0; i != len; ++i) + { + crc = g_crc_table[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); + } + + crc = crc ^ 0xffffffff; + + return crc; +} + +/* + * 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)); +} + +/* + * 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 = g_eeprom_size; + 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. + */ +static void decode_tlv_value(tlvinfo_tlv_t *tlv, tlv_decode_value_t *decode_value) +{ + int i; + char *value; + uint32_t length; + + value = (char *)decode_value->value; + + 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; + length = tlv->length; + break; + case TLV_CODE_MAC_BASE: + length = sprintf(value, "%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: + length = sprintf(value, "%u", tlv->value[0]); + break; + case TLV_CODE_MAC_SIZE: + length = sprintf(value, "%u", (tlv->value[0] << 8) | tlv->value[1]); + break; + case TLV_CODE_VENDOR_EXT: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s %02X", value, tlv->value[i]); + } + break; + case TLV_CODE_CRC_32: + length = sprintf(value, "0x%02X%02X%02X%02X", tlv->value[0], + tlv->value[1], tlv->value[2], tlv->value[3]); + break; + default: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s 0x%02X", value, tlv->value[i]); + } + break; + } + + decode_value->length = length; +} + +/* + * 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(uint8_t *eeprom) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_crc; + unsigned int calc_crc; + unsigned int stored_crc; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + /* 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(0xffffffffL, (const unsigned char *)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]); + + return (calc_crc == stored_crc); +} + +/* + * 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. + */ +static bool tlvinfo_find_tlv(uint8_t *eeprom, uint8_t tcode, int *eeprom_index) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + /* 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. + */ +static bool tlvinfo_decode_tlv(uint8_t *eeprom, uint8_t tcode, tlv_decode_value_t *decode_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, decode_value); + return true; + } + + return false; +} + +/* + * parse_tlv_eeprom + * + * parse the EEPROM into memory, if it hasn't already been read. + */ +int parse_tlv_eeprom(uint8_t *eeprom, uint32_t size) +{ + unsigned int i; + bool ret; + tlvinfo_header_t *eeprom_hdr; + tlv_decode_value_t decode_value; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + g_eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv crc.\n"); + return -1; + } + + for (i = 0; i < TLV_CODE_NUM; i++) { + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = tlvinfo_decode_tlv(eeprom, tlv_code_list[i].m_code, &decode_value); + if (!ret) { + DBG_DEBUG(DBG_ERROR, "No found type: %s\n", tlv_code_list[i].m_name); + continue; + } + + DBG_DEBUG(DBG_VERBOSE, "i: %d,Found type: %s tlv[%d]:%s\n", i, tlv_code_list[i].m_name, tlv_code_list[i].m_code, + decode_value.value); + for (j = 0; j < decode_value.length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", decode_value.value[j]); + } + DBG_DEBUG(DBG_VERBOSE, "\n\n"); + } + return 0; +} +static int dfd_parse_tlv_eeprom(uint8_t *eeprom, uint32_t size, uint8_t main_type, tlv_decode_value_t *decode_value) +{ + bool ret; + tlvinfo_header_t *eeprom_hdr; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + g_eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv crc.\n"); + return -1; + } + + ret = tlvinfo_decode_tlv(eeprom, main_type, decode_value); + if (!ret) { + DBG_DEBUG(DBG_ERROR, "No found type: %d\n", main_type); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "Found type: %d, value: %s\n", main_type,decode_value->value); + for (j = 0; j < decode_value->length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", decode_value->value[j]); + } + DBG_DEBUG(DBG_VERBOSE, "\n\n"); + + return 0; +} +#if 0 + +static int tlvinfo_find_rg_ext_tlv(tlv_decode_value_t *ext_tlv_value, uint8_t ext_type, + uint8_t *buf, uint32_t *buf_len) +{ + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end, eeprom_index; + + /* Search through the TLVs, looking for the first one which matches the + * supplied type code.*/ + DBG_DEBUG(DBG_VERBOSE, "ext_tlv_value->length: %d.\n", ext_tlv_value->length); + for (eeprom_index = 0; eeprom_index < ext_tlv_value->length; eeprom_index++) { + if ((eeprom_index % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", ext_tlv_value->value[eeprom_index]); + } + + DBG_DEBUG(DBG_VERBOSE, "\n"); + + eeprom_index = 0; + eeprom_end = ext_tlv_value->length; + while (eeprom_index < eeprom_end) { + eeprom_tlv = (tlvinfo_tlv_t *) &(ext_tlv_value->value[eeprom_index]); + if (!is_valid_tlv(eeprom_tlv)) { + DBG_DEBUG(DBG_ERROR, "tlv is not valid, eeprom_tlv->type 0x%x.\n", eeprom_tlv->type); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "eeprom_tlv->length %d.\n", eeprom_tlv->length); + if (eeprom_tlv->type == ext_type) { + if (*buf_len >= eeprom_tlv->length) { + memcpy(buf, eeprom_tlv->value, eeprom_tlv->length); + DBG_DEBUG(DBG_VERBOSE, "eeprom_tlv->length %d.\n", eeprom_tlv->length); + *buf_len = eeprom_tlv->length; + return 0; + } + DBG_DEBUG(DBG_VERBOSE, "buf_len %d small than info_len %d.\n", *buf_len, eeprom_tlv->length); + return -1; + } + + eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; + } + + DBG_DEBUG(DBG_VERBOSE, "ext_type %d: tlv is not found.\n", ext_type); + return -1; +} +#endif + +int dfd_tlvinfo_get_e2prom_info(uint8_t *eeprom, uint32_t size, dfd_tlv_type_t *tlv_type, uint8_t* buf, uint32_t *buf_len) +{ + tlv_decode_value_t decode_value; + int ret; + + if (eeprom == NULL || tlv_type == NULL || buf == NULL) { + DBG_DEBUG(DBG_ERROR, "Input para invalid.\n"); + return -1; + } + + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = dfd_parse_tlv_eeprom(eeprom, size, tlv_type->main_type, &decode_value); + if (ret) { + DBG_DEBUG(DBG_ERROR, "dfd_parse_tlv_eeprom failed ret %d.\n", ret); + return ret; + } + + if (*buf_len >= decode_value.length) { + memcpy(buf, decode_value.value, decode_value.length); + *buf_len = decode_value.length; + return 0; + } + DBG_DEBUG(DBG_ERROR, "buf_len %d small than info_len %d.\n", *buf_len, decode_value.length); + return -1; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_cpld_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_cpld_driver.c new file mode 100644 index 000000000000..999224606060 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_cpld_driver.c @@ -0,0 +1,117 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" + +int g_dfd_cpld_dbg_level = 0; +module_param(g_dfd_cpld_dbg_level, int, S_IRUGO | S_IWUSR); + +ssize_t dfd_get_cpld_name(unsigned int cpld_index, char *buf) +{ + int key; + char *cpld_name; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error. buf is NULL.cpld index:%d", cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_NAME, cpld_index, 0); + cpld_name = dfd_ko_cfg_get_item(key); + if (cpld_name == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "cpld name config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%s\n", cpld_name); + snprintf(buf, PAGE_SIZE, "%s\n", cpld_name); + return strlen(buf); +} + +ssize_t dfd_get_cpld_type(unsigned int cpld_index, char *buf) +{ + int key; + char *cpld_type; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error. buf is NULL.cpld index:%d\n", cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TYPE, cpld_index, 0); + cpld_type = dfd_ko_cfg_get_item(key); + if (cpld_type == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "cpld type config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%s\n", cpld_type); + snprintf(buf, PAGE_SIZE, "%s\n", cpld_type); + return strlen(buf); +} + +ssize_t dfd_get_cpld_version(unsigned int cpld_index, char *buf) +{ + int key, rv; + uint32_t value; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error. buf is NULL."); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_VERSION, cpld_index, 0); + rv = dfd_info_get_int(key, &value, NULL); + if (rv < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "cpld version config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%x\n", value); + snprintf(buf, PAGE_SIZE, "%08x\n", value); + return strlen(buf); +} + +int dfd_set_cpld_testreg(unsigned int cpld_index, int value) +{ + int key, ret; + + if (value < 0 || value > 0xff) { + DBG_CPLD_DEBUG(DBG_ERROR, "can not set cpld test register value = 0x%02x.\n", value); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TEST_REG, cpld_index, 0); + ret = dfd_info_set_int(key, value); + if (ret < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "set cpld test register error, key:0x%x,ret:%d\n",key, ret); + return ret; + } + return DFD_RV_OK; +} + +int dfd_get_cpld_testreg(unsigned int cpld_index, int *value) +{ + int key, ret; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TEST_REG, cpld_index, 0); + ret = dfd_info_get_int(key, value, NULL); + if (ret < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "get cpld test register error, key:0x%x,ret:%d\n",key, ret); + return ret; + } + return DFD_RV_OK; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_fan_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_fan_driver.c new file mode 100644 index 000000000000..b56413c8c646 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_fan_driver.c @@ -0,0 +1,487 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define DFD_FAN_EEPROM_MODE_TLV_STRING "tlv" +#define DFD_FAN_EEPROM_MODE_FRU_STRING "fru" +#define FAN_SIZE (256) + +typedef enum fan_status_e { + FAN_ABSENT = 0, + FAN_OK = 1, + FAN_NOT_OK = 2, +} fan_status_t; + +typedef enum fan_present_status_e { + ABSENT = 0, + PRESENT = 1, +} fan_present_status_t; + +typedef enum fan_motor_status_e { + MOTOR_STALL = 0, + MOTOR_ROLL = 1, +} fan_motor_status_t; + +typedef enum fan_eeprom_mode_e { + FAN_EEPROM_MODE_TLV, /* TLV */ + FAN_EEPROM_MODE_FRU, /*FRU*/ +} fan_eeprom_mode_t; + +typedef struct dfd_dev_head_info_s { + uint8_t ver; + uint8_t flag; + uint8_t hw_ver; + uint8_t type; + int16_t tlv_len; +} dfd_dev_head_info_t; + +typedef struct dfd_dev_tlv_info_s { + uint8_t type; + uint8_t len; + uint8_t data[0]; +} dfd_dev_tlv_info_t; + +typedef enum fan_direction_e { + FRONT_TO_BACK = 0, + BACK_TO_FRONT = 1, + FAN_DIRECTION_END = 2, +} fan_direction_t; + +int g_dfd_fan_dbg_level = 0; +module_param(g_dfd_fan_dbg_level, int, S_IRUGO | S_IWUSR); + +static int dfd_get_fan_eeprom_mode(void) +{ + int key, mode; + char *name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_E2_MODE, 0, 0); + name = dfd_ko_cfg_get_item(key); + if (name == NULL) { + + DFD_FAN_DEBUG(DBG_WARN, "get fan eeprom mode fail, key=0x%08x\n", key); + return FAN_EEPROM_MODE_TLV; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan eeprom mode_name %s.\n", name); + if (!strncmp(name, DFD_FAN_EEPROM_MODE_TLV_STRING, strlen(DFD_FAN_EEPROM_MODE_TLV_STRING))) { + mode = FAN_EEPROM_MODE_TLV; + } else if (!strncmp(name, DFD_FAN_EEPROM_MODE_FRU_STRING, strlen(DFD_FAN_EEPROM_MODE_FRU_STRING))) { + mode = FAN_EEPROM_MODE_FRU; + } else { + + mode = FAN_EEPROM_MODE_TLV; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan eeprom mode %d.\n", mode); + return mode; +} + +static int dfd_fan_tlv_eeprom_read(int bus, int addr, uint8_t cmd, char *buf) +{ + dfd_dev_head_info_t info; + char tmp_tlv_len[sizeof(uint16_t)]; + char *tlv_data; + dfd_dev_tlv_info_t *tlv; + int buf_len; + int rv, match_flag; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_ko_i2c_read(bus, addr, 0, (uint8_t *)&info, sizeof(dfd_dev_head_info_t)); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan may not present.\n"); + return -DFD_RV_DEV_NOTSUPPORT; + } + + memcpy(tmp_tlv_len, (uint8_t *)&info.tlv_len, sizeof(uint16_t)); + info.tlv_len = (tmp_tlv_len[0] << 8) + tmp_tlv_len[1]; + + if ((info.tlv_len <= 0 ) || (info.tlv_len > 0xFF)) { + DFD_FAN_DEBUG(DBG_ERROR, "fan maybe not set mac.\n"); + return -DFD_RV_TYPE_ERR; + } + DFD_FAN_DEBUG(DBG_VERBOSE, "info.tlv_len:%d\n", info.tlv_len); + + tlv_data = (uint8_t *)kmalloc(info.tlv_len, GFP_KERNEL); + if (tlv_data == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "tlv_data kmalloc failed \n"); + return -DFD_RV_NO_MEMORY; + } + memset(tlv_data, 0, info.tlv_len); + + rv = dfd_ko_i2c_read(bus, addr, sizeof(dfd_dev_head_info_t), tlv_data, info.tlv_len); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR,"fan eeprom read failed\n"); + kfree(tlv_data); + return -DFD_RV_DEV_NOTSUPPORT; + } + + buf_len = FAN_SIZE - 1; + match_flag = 0; + for(tlv = (dfd_dev_tlv_info_t *)tlv_data; (ulong)tlv < (ulong)tlv_data + info.tlv_len;) { + DFD_FAN_DEBUG(DBG_VERBOSE, "tlv: %p, tlv->type: 0x%x, tlv->len: 0x%x info->tlv_len: 0x%x\n", + tlv, tlv->type, tlv->len, info.tlv_len); + if (tlv->type == cmd && tlv->len <= buf_len ) { + DFD_FAN_DEBUG(DBG_VERBOSE, "find tlv data, copy...\n"); + memcpy(buf, (uint8_t *)tlv->data, tlv->len); + buf_len = (uint32_t)tlv->len; + match_flag = 1; + break; + } + tlv = (dfd_dev_tlv_info_t *)((uint8_t* )tlv + sizeof(dfd_dev_tlv_info_t) + tlv->len); + } + kfree(tlv_data); + if (match_flag == 0) { + DFD_FAN_DEBUG(DBG_ERROR,"can't find fan tlv date. bus:%d, addr:0x%02x, tlv type:%d.\n", bus, addr, cmd); + return -DFD_RV_TYPE_ERR; + } + return buf_len; +} + +int dfd_get_fan_roll_status(unsigned int fan_index, unsigned int motor_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_ROLL_STATUS, fan_index, motor_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan roll status error, fan:%d,motor:%d\n", + fan_index, motor_index); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan%u motor%u get fan roll status success, status:%d.\n", + fan_index, motor_index, status); + return status; +} + +int dfd_get_fan_present_status(unsigned int fan_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_PRESENT_STATUS, RG_MAIN_DEV_FAN, fan_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan%u get present status error, key:0x%x\n", fan_index, key); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan%u get present status success, status:%d.\n", fan_index, status); + return status; +} + +int dfd_get_fan_status(unsigned int fan_index) +{ + int motor_num, motor_index, status, errcnt; + + status = dfd_get_fan_present_status(fan_index); + if(status != PRESENT ) { + DFD_FAN_DEBUG(DBG_ERROR, "fan index:%d, status:%d\n",fan_index, status); + return status; + } + + motor_num = dfd_get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_MOTOR); + if(motor_num <= 0 ) { + DFD_FAN_DEBUG(DBG_ERROR, "get motor number error:%d\n",motor_num); + return -DFD_RV_DEV_FAIL; + } + errcnt = 0; + for(motor_index = 0; motor_index < motor_num; motor_index++) { + status = dfd_get_fan_roll_status(fan_index, motor_index); + if(status < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan roll status error, fan index:%d, motor index:%d, status:%d\n", + fan_index, motor_index, status); + return status; + } + if(status != MOTOR_ROLL) { + DFD_FAN_DEBUG(DBG_ERROR, + "stall:fan index:%d, motor index:%d, status:%d\n",fan_index, motor_index, status); + errcnt++; + } + } + if (errcnt > 0) { + return FAN_NOT_OK; + } + return FAN_OK; +} + +ssize_t dfd_get_fan_status_str(unsigned int fan_index, char *buf) +{ + int ret; + + if(buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "params error.fan_index:%d.",fan_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_status(fan_index); + if(ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan status error,ret:%d, fan_index:%d\n", ret, fan_index); + return ret; + } + memset(buf, 0, PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +ssize_t dfd_get_fan_info(unsigned int fan_index, uint8_t cmd, char *buf) +{ + int key, rv, eeprom_mode; + char fan_buf[FAN_SIZE]; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index:%d, cmd:0x%x.\n", fan_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + memset(fan_buf, 0, FAN_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_FAN, fan_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "fan i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + eeprom_mode = dfd_get_fan_eeprom_mode(); + if(eeprom_mode == FAN_EEPROM_MODE_TLV) { + rv = dfd_fan_tlv_eeprom_read(i2c_dev->bus, i2c_dev->addr, cmd, fan_buf); + } else { + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, cmd, fan_buf, FAN_SIZE); + } + + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "%s\n", fan_buf); + snprintf(buf, FAN_SIZE, "%s\n", fan_buf); + return strlen(buf); +} + +ssize_t dfd_get_fan_speed(unsigned int fan_index, unsigned int motor_index,unsigned int *speed) +{ + int key, ret, speed_tmp; + + if (speed == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED, fan_index, motor_index); + ret = dfd_info_get_int(key, &speed_tmp, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan speed error, key:0x%x,ret:%d\n",key, ret); + return ret; + } + + if (speed_tmp == 0 || speed_tmp == 0xffff) { + *speed = 0; + } else { + *speed = 15000000 / speed_tmp; + } + return DFD_RV_OK; +} + +int dfd_set_fan_speed_level(unsigned int fan_index, unsigned int motor_index, int level) +{ + int key, ret; + + if (level < 0 || level > 0xff) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, can not set fan speed level: %d.\n", + fan_index, motor_index, level); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_RATIO, fan_index, motor_index); + ret = dfd_info_set_int(key, level); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, set fan level 0x%02x error, key:0x%x,ret:%d\n", + fan_index, motor_index, level, key, ret); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan:%u, motor:%u, set fan speed level 0x%02x success.\n", + fan_index, motor_index, level); + return DFD_RV_OK; +} + +int dfd_set_fan_pwm(unsigned int fan_index, unsigned int motor_index, int pwm) +{ + int ret, data; + + if (pwm < 0 || pwm > 100) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, can't set pwm: %d.\n", + fan_index, motor_index, pwm); + return -DFD_RV_INVALID_VALUE; + } + + data = pwm * 255 / 100; + ret = dfd_set_fan_speed_level(fan_index, motor_index, data); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, set fan ratio:%d error, ret:%d\n", + fan_index, motor_index, data, ret); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan:%u, motor:%u, set fan ratio %d success.\n", + fan_index, motor_index, data); + return DFD_RV_OK; +} + +int dfd_get_fan_speed_level(unsigned int fan_index, unsigned int motor_index, int *level) +{ + int key, ret, speed_level; + + if (level == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_RATIO, fan_index, motor_index); + ret = dfd_info_get_int(key, &speed_level, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, get fan speed level error, key:0x%x,ret:%d\n", + fan_index, motor_index, key, ret); + return ret; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan:%u, motor:%u, get fan speed level success, value:0x%02x.\n", + fan_index, motor_index, speed_level); + *level = speed_level; + return DFD_RV_OK; +} + +int dfd_get_fan_pwm(unsigned int fan_index, unsigned int motor_index, int *pwm) +{ + int ret, level; + + if (pwm == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_speed_level(fan_index, motor_index, &level); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan:%u, motor:%u, get fan pwm error, ret:%d\n", + fan_index, motor_index, ret); + return ret; + } + + if ((level * 100) % 255 > 0) { + *pwm = level * 100 / 255 + 1; + } else { + *pwm = level * 100 / 255; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan:%u, motor:%u, get fan pwm success, value:%d.\n", + fan_index, motor_index, *pwm); + return DFD_RV_OK; +} + +int dfd_get_fan_speed_tolerance(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_tolerance; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_TOLERANCE, fan_index, motor_index); + p_fan_speed_tolerance = dfd_ko_cfg_get_item(key); + if (p_fan_speed_tolerance == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan speed tolerance failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_tolerance; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan speed tolerance ok, key:0x%x, value:%d\n",key, *value); + return DFD_RV_OK; +} + +int dfd_get_fan_speed_target(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_target; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_TARGET, fan_index, motor_index); + p_fan_speed_target = dfd_ko_cfg_get_item(key); + if (p_fan_speed_target == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan speed target failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_target; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan speed target ok, key:0x%x, value:%d\n",key, *value); + return DFD_RV_OK; +} + +int dfd_get_fan_direction(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_direction; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_DIRECTION, fan_index, motor_index); + p_fan_direction = dfd_ko_cfg_get_item(key); + if (p_fan_direction == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan direction failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_direction; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan direction ok, key:0x%x, value:%d\n",key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_direction_str(unsigned int fan_index, unsigned int motor_index, char *buf) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. buf is NULL. fan index:%d, motor index:%d.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_direction(fan_index, motor_index, &value); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan direction string failed, ret:%d, fan_index:%d, motor_index:%d\n", + ret, fan_index, motor_index); + return ret; + } + memset(buf, 0, PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_led_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_led_driver.c new file mode 100644 index 000000000000..2e0355ce825c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_led_driver.c @@ -0,0 +1,86 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_cfg_adapter.h" + +#define LED_STATUS_MEM (9) + +int g_dfd_sysled_dbg_level = 0; +module_param(g_dfd_sysled_dbg_level, int, S_IRUGO | S_IWUSR); + +typedef enum dfd_led_status_e { + DFD_LED_DARK = 0, + DFD_LED_GREEN = 1, + DFD_LED_YELLOW = 2, + DFD_LED_RED = 3, + DFD_LED_GREEN_FLASH = 4, + DFD_LED_YELLOW_FLASH = 5, + DFD_LED_RED_FLASH = 6, + DFD_LED_BLUE = 7, + DFD_LED_END = 8, +} dfd_led_status_t; + +static int g_dfd_rg_led_status[LED_STATUS_MEM] = { + DFD_LED_DARK, + DFD_LED_RED_FLASH, + DFD_LED_RED, + DFD_LED_GREEN_FLASH, + DFD_LED_GREEN, + DFD_LED_YELLOW_FLASH, + DFD_LED_YELLOW, + DFD_LED_DARK, + DFD_LED_BLUE, +}; + +static int dfd_get_led_status_value(uint16_t led_id, uint8_t led_index, int *value) +{ + int key, ori_value, ret, value_tmp; + int *p_decode_value; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS, led_id, led_index); + ret = dfd_info_get_int(key, &ori_value, NULL); + if (ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status error, key:0x%x,ret:%d\n", key, ret); + return ret; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS_DECODE, led_id, ori_value); + p_decode_value = dfd_ko_cfg_get_item(key); + if (p_decode_value == NULL) { + DFD_FAN_DEBUG(DBG_VERBOSE, "led id:%d index:%d, status needn't decode.value:0x%x\n", led_id, led_index, ori_value); + value_tmp = ori_value; + } else { + DFD_FAN_DEBUG(DBG_VERBOSE, "led id:%d index:%d,, ori_value:0x%x,decode value:0x%x\n", led_id, led_index, ori_value, *p_decode_value); + value_tmp = *p_decode_value; + } + if(value_tmp >=0 && value_tmp < LED_STATUS_MEM) { + *value = g_dfd_rg_led_status[value_tmp]; + return DFD_RV_OK; + } + return -DFD_RV_INVALID_VALUE; +} + +ssize_t dfd_get_led_status(uint16_t led_id, uint8_t led_index, char *buf) +{ + int ret, led_value; + + if(buf == NULL) { + DBG_SYSLED_DEBUG(DBG_ERROR, "param error, buf is NULL. led_id:%d, led_index:%d\n", + led_id, led_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_led_status_value(led_id, led_index, &led_value); + if(ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status error,ret:%d, led_id:%d, led_index:%d\n", ret, led_id, led_index); + return ret; + } + memset(buf, 0 , PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", led_value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_module.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_module.c new file mode 100644 index 000000000000..b64663f81737 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_module.c @@ -0,0 +1,134 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_fan_driver.h" +#include "./include/dfd_syseeprom_driver.h" +#include "./include/dfd_cpld_driver.h" +#include "./include/dfd_led_driver.h" +#include "./include/dfd_slot_driver.h" +#include "./include/dfd_sensors_driver.h" +#include "./include/dfd_psu_driver.h" +#include "./include/dfd_sff_driver.h" + +typedef enum dfd_dev_init_fail_s { + DFD_KO_INIT_CPLD_FAIL = 1, + DFD_KO_INIT_FPGA_FAIL = 2, + DFD_KO_INIT_IRQ_FAIL = 3, + DFD_KO_INIT_CFG_FAIL = 4, + DFD_KO_INIT_DATA_FAIL = 5, +} dfd_dev_init_fail_t; + +int g_dfd_dbg_level = 0; + +char *g_status_mem_str[STATUS_MEM_END] = { + "ABSENT", + "OK", + "NOT OK", +}; + +int dfd_get_dev_number(unsigned int main_dev_id, unsigned int minor_dev_id) +{ + int key,dev_num; + int *p_dev_num; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_NUM, main_dev_id, minor_dev_id); + p_dev_num = dfd_ko_cfg_get_item(key); + if (p_dev_num == NULL) { + DBG_DEBUG(DBG_ERROR, "get device number failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + dev_num = *p_dev_num; + DBG_DEBUG(DBG_VERBOSE, "get device number ok, number:%d\n",dev_num); + return dev_num; +} + +static struct switch_drivers_t switch_drivers= { + .get_dev_number = dfd_get_dev_number, + /* fan */ + .get_fan_status = dfd_get_fan_status, + .get_fan_info = dfd_get_fan_info, + .get_fan_speed = dfd_get_fan_speed, + .get_fan_pwm = dfd_get_fan_pwm, + .set_fan_pwm = dfd_set_fan_pwm, + .get_fan_speed_tolerance = dfd_get_fan_speed_tolerance, + .get_fan_speed_target = dfd_get_fan_speed_target, + .get_fan_direction = dfd_get_fan_direction, + .get_fan_status_str = dfd_get_fan_status_str, + .get_fan_direction_str = dfd_get_fan_direction_str, + .get_fan_present_status = dfd_get_fan_present_status, + .get_fan_roll_status = dfd_get_fan_roll_status, + .get_fan_speed_level = dfd_get_fan_speed_level, + .set_fan_speed_level = dfd_set_fan_speed_level, + /* syseeprom */ + .get_syseeprom_info = dfd_get_syseeprom_info, + /* cpld */ + .get_cpld_name = dfd_get_cpld_name, + .get_cpld_type = dfd_get_cpld_type, + .get_cpld_version = dfd_get_cpld_version, + .get_cpld_testreg = dfd_get_cpld_testreg, + .set_cpld_testreg = dfd_set_cpld_testreg, + /* led */ + .get_led_status = dfd_get_led_status, + /* slot */ + .get_slot_status_str = dfd_get_slot_status_str, + .get_slot_info = dfd_get_slot_info, + /* sensors */ + .get_temp_info = dfd_get_temp_info, + .get_voltage_info = dfd_get_voltage_info, + /* psu */ + .get_psu_info = dfd_get_psu_info, + .get_psu_status_str = dfd_get_psu_status_str, + .get_psu_sensor_info = dfd_get_psu_sensor_info, + .get_psu_present_status = dfd_get_psu_present_status, + .get_psu_output_status = dfd_get_psu_output_status, + .get_psu_alert_status = dfd_get_psu_alert_status, + /* sff */ + .get_sff_id = dfd_get_sff_id, + .set_sff_cpld_info = dfd_set_sff_cpld_info, + .get_sff_cpld_info = dfd_get_sff_cpld_info, + .get_sff_eeprom_info = dfd_get_sff_eeprom_info, + .get_sff_dir_name = dfd_get_sff_dir_name, + .get_sff_polling_size = dfd_get_sff_polling_size, + .get_sff_polling_data = dfd_get_sff_polling_data, +}; + +struct switch_drivers_t * dfd_plat_driver_get(void) { + return &switch_drivers; +} + +static int32_t __init dfd_dev_init(void) +{ + int ret; + + DBG_DEBUG(DBG_VERBOSE, "Enter.\n"); + + ret = dfd_dev_cfg_init(); + if (ret != 0) { + DBG_DEBUG(DBG_ERROR, "dfd_dev_cfg_init failed ret %d.\n", ret); + ret = -DFD_KO_INIT_CFG_FAIL; + return ret; + } + + DBG_DEBUG(DBG_VERBOSE, "success.\n"); + return 0; +} + +static void __exit dfd_dev_exit(void) +{ + DBG_DEBUG(DBG_VERBOSE, "dfd_dev_exit.\n"); + dfd_dev_cfg_exit(); + return ; +} + +module_init(dfd_dev_init); +module_exit(dfd_dev_exit); +module_param(g_dfd_dbg_level, int, S_IRUGO | S_IWUSR); +EXPORT_SYMBOL(dfd_plat_driver_get); +MODULE_AUTHOR("sonic_rd "); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_psu_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_psu_driver.c new file mode 100644 index 000000000000..22fc96e3b2d0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_psu_driver.c @@ -0,0 +1,206 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define PSU_SIZE (256) + +typedef enum dfd_psu_status_e { + DFD_PSU_PRESENT_STATUS = 0, + DFD_PSU_OUTPUT_STATUS = 1, + DFD_PSU_ALERT_STATUS = 2, +} dfd_psu_status_t; + +typedef enum dfd_psu_present_status_e { + ABSENT = 0, + PRESENT = 1, +} dfd_psu_present_status_t; + +typedef enum dfd_psu_output_status_e { + FAULT = 0, + NORMAL = 1, +} dfd_psu_output_status_t; + +int g_dfd_psu_dbg_level = 0; +module_param(g_dfd_psu_dbg_level, int, S_IRUGO | S_IWUSR); + +int dfd_get_psu_present_status(unsigned int psu_index) +{ + int ret, present_key, present_status; + + present_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_PRESENT_STATUS); + ret = dfd_info_get_int(present_key, &present_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_present_status error. psu_index:%d, ret:%d\n", + psu_index, ret); + return ret; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "dfd_get_psu_present_status success. psu_index:%d, status:%d\n", + psu_index, present_status); + return present_status; +} + +int dfd_get_psu_output_status(unsigned int psu_index) +{ + int ret, output_key, output_status; + + output_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_OUTPUT_STATUS); + ret = dfd_info_get_int(output_key, &output_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_output_status error. psu_index:%d, ret:%d\n", + psu_index, ret); + return ret; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "dfd_get_psu_output_status success. psu_index:%d, status:%d\n", + psu_index, output_status); + return output_status; +} + +int dfd_get_psu_alert_status(unsigned int psu_index) +{ + int ret, alert_key, alert_status; + + alert_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_ALERT_STATUS); + ret = dfd_info_get_int(alert_key, &alert_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_alert_status error. psu_index:%d, ret:%d\n", + psu_index, ret); + return ret; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "dfd_get_psu_alert_status success. psu_index:%d, status:%d\n", + psu_index, alert_status); + return alert_status; +} + +int dfd_get_psu_status(unsigned int psu_index) +{ + int present_key, present_status; + int output_key, output__status; + int alert_key, alert_status; + int ret1, ret2; + + present_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_PRESENT_STATUS); + ret1 = dfd_info_get_int(present_key, &present_status, NULL); + if (ret1 < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_status error. psu_index:%d, ret:%d\n", psu_index, ret1); + return ret1; + } + if(present_status != PRESENT) { + return STATUS_ABSENT; + } + + output_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_OUTPUT_STATUS); + alert_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_ALERT_STATUS); + ret1 = dfd_info_get_int(output_key, &output__status, NULL); + ret2 = dfd_info_get_int(alert_key, &alert_status, NULL); + if( ret1 < 0 || ret2 < 0 ||output__status != NORMAL || alert_status != NORMAL) { + return STATUS_NOT_OK; + } + return STATUS_OK; +} + +ssize_t dfd_get_psu_status_str(unsigned int psu_index, char *buf) +{ + int ret; + if(buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "params error.psu_index:%d.",psu_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_psu_status(psu_index); + if(ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu status error,ret:%d, psu_index:%d\n", ret, psu_index); + return ret; + } + memset(buf, 0 , PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static int dfd_psu_product_name_decode(char *psu_buf, int buf_len) +{ + int key, i; + char *p_psu_name, *p_decode_name; + int *psu_type_num; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_NUM, RG_MAIN_DEV_PSU, RG_MINOR_DEV_PSU); + psu_type_num = dfd_ko_cfg_get_item(key); + if (psu_type_num == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "get product psu type number error, key:0x%x\n", key); + return -DFD_RV_NO_NODE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_NAME, 0, 0); + p_decode_name = dfd_ko_cfg_get_item(key); + if (p_decode_name == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error.psu decode name is NULL., key:0x%x\n", key); + return -DFD_RV_NO_NODE; + } + + for (i = 1; i <= *psu_type_num; i++) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_NAME, i, 0); + p_psu_name = dfd_ko_cfg_get_item(key); + if (p_psu_name == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error.get psu name error., key:0x%x\n", key); + return -DFD_RV_NO_NODE; + } + if (!strncmp(psu_buf, p_psu_name, strlen(p_psu_name))) { + DFD_PSU_DEBUG(DBG_VERBOSE, "psu name match ok, org name:%s\n", p_psu_name); + memset(psu_buf, 0, buf_len); + strncpy(psu_buf, p_decode_name, buf_len -1); + return DFD_RV_OK; + } + } + DFD_PSU_DEBUG(DBG_ERROR, "psu name:%s error.can't match.\n", psu_buf); + return -DFD_RV_DEV_NOTSUPPORT; +} + +ssize_t dfd_get_psu_info(unsigned int psu_index, uint8_t cmd, char *buf) +{ + int key, rv; + char psu_buf[PSU_SIZE]; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "buf is NULL, psu index:%d, cmd:%d\n", psu_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + memset(psu_buf, 0, PSU_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_PSU, psu_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "psu i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, cmd, psu_buf, PSU_SIZE); + + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + DFD_PSU_DEBUG(DBG_VERBOSE, "%s\n", psu_buf); + + if (cmd == DFD_DEV_INFO_TYPE_PART_NAME) { + rv = dfd_psu_product_name_decode(psu_buf, PSU_SIZE); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu name decode error. rv:%d.\n", rv); + return rv; + } + } + snprintf(buf, PSU_SIZE, "%s\n", psu_buf); + return strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sensors_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sensors_driver.c new file mode 100644 index 000000000000..c0a246c47826 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sensors_driver.c @@ -0,0 +1,178 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" +#include "./include/dfd_cfg_file.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define DFD_GET_TEMP_SENSOR_KEY1(dev_index, temp_index) \ + (((dev_index & 0xff) << 8) | (temp_index & 0xff)) +#define DFD_GET_TEMP_SENSOR_KEY2(main_dev_id, temp_type) \ + (((main_dev_id & 0x0f) << 4) | (temp_type & 0x0f)) +#define DFD_FORMAT_STR_MAX_LEN (32) + +int g_dfd_sensor_dbg_level = 0; +module_param(g_dfd_sensor_dbg_level, int, S_IRUGO | S_IWUSR); + +static int dfd_deal_hwmon_buf(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new, info_ctrl_t *info_ctrl) +{ + int i, tmp_len; + int exp, decimal, divisor; + int org_value, tmp_value; + int div_result, div_mod; + char fmt_str[DFD_FORMAT_STR_MAX_LEN]; + + exp = info_ctrl->int_cons; + decimal = info_ctrl->bit_offset; + + if (exp <= 0) { + DBG_DEBUG(DBG_VERBOSE, "exponent %d, don't need transform. buf_len:%d, buf_len_new:%d\n", + exp, buf_len, *buf_len_new); + snprintf(buf_new, *buf_len_new, "%s", buf); + *buf_len_new = strlen(buf_new); + return DFD_RV_OK; + } + divisor = 1; + for (i = 0; i < exp; i++) { + divisor *= 10; + } + org_value = simple_strtol(buf, NULL, 10); + if (org_value < 0) { + tmp_value = 0 - org_value; + } else { + tmp_value = org_value; + } + div_result = tmp_value / divisor; + div_mod = tmp_value % divisor; + DBG_DEBUG(DBG_VERBOSE, "exp:%d, decimal:%d, original value:%d, divisor:%d, result :%d, mod:%d\n", + exp, decimal, org_value, divisor, div_result, div_mod); + + memset(fmt_str, 0, sizeof(fmt_str)); + if (org_value < 0) { + snprintf(fmt_str, sizeof(fmt_str), "-%%d.%%0%dd\n",exp); + } else { + snprintf(fmt_str, sizeof(fmt_str), "%%d.%%0%dd\n",exp); + } + DBG_DEBUG(DBG_VERBOSE, "format string:%s",fmt_str); + snprintf(buf_new, *buf_len_new, fmt_str, div_result, div_mod); + *buf_len_new = strlen(buf_new); + tmp_len = *buf_len_new; + + if ( decimal > 0) { + for(i = 0; i < *buf_len_new; i++) { + if (buf_new[i] == '.') { + if( i + decimal + 2 <= *buf_len_new ) { + buf_new[i + decimal + 1 ] = '\n'; + buf_new[i + decimal + 2 ] = '\0'; + *buf_len_new = strlen(buf_new); + DBG_DEBUG(DBG_VERBOSE, "deal decimal[%d] ok, str len:%d, value:%s\n", + decimal, *buf_len_new, buf_new); + } + break; + } + } + if (tmp_len == *buf_len_new) { + DBG_DEBUG(DBG_WARN, "deal decimal[%d] failed, use original value:%s\n", decimal, buf_new); + } + } + return DFD_RV_OK; +} + +static int dfd_get_sensor_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t sensor_type, + uint8_t sensor_index, uint8_t sensor_attr, char *buf) +{ + uint32_t key; + uint16_t key_index1; + uint8_t key_index2; + int rv; + info_hwmon_buf_f pfunc; + + key_index1 = DFD_GET_TEMP_SENSOR_KEY1(dev_index, sensor_index); + key_index2 = DFD_GET_TEMP_SENSOR_KEY2(main_dev_id, sensor_attr); + if (sensor_type == RG_MINOR_DEV_TEMP ) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_TEMP, key_index1, key_index2); + } else if (sensor_type == RG_MINOR_DEV_IN) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_IN, key_index1, key_index2); + } else { + DFD_SENSOR_DEBUG(DBG_ERROR, "unknow sensor type:%d.\n",sensor_type); + return -DFD_RV_INVALID_VALUE; + } + + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get sensor info.main_dev_id:%d, dev_index:0x%x, sensor_index:0x%x, sensor_attr:0x%x, key:0x%x,\n", + main_dev_id, dev_index, sensor_index, sensor_attr, key); + + pfunc = dfd_deal_hwmon_buf; + memset(buf, 0 , PAGE_SIZE); + rv = dfd_info_get_sensor(key, buf, PAGE_SIZE, pfunc); + return rv; +} + +ssize_t dfd_get_temp_info(uint8_t main_dev_id, uint8_t dev_index, + uint8_t temp_index, uint8_t temp_attr, char *buf) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_TEMP, temp_index, temp_attr, buf); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get temp info error. rv:%d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get temp info ok.value:%s\n", buf); + } + return rv; +} + +ssize_t dfd_get_voltage_info(uint8_t main_dev_id, uint8_t dev_index, + uint8_t in_index, uint8_t in_attr, char *buf) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_IN, in_index, in_attr, buf); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get voltage info error. rv:%d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get voltage info ok.value:%s\n", buf); + } + return rv; +} + +ssize_t dfd_get_psu_sensor_info(uint8_t psu_index, uint8_t sensor_type, char *buf) +{ + int rv, key; + info_hwmon_buf_f pfunc; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_PSU, psu_index, sensor_type); + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get psu sensor info. psu index:%d, sensor type:%d, key:0x%x,\n", + psu_index, sensor_type, key); + pfunc = dfd_deal_hwmon_buf; + memset(buf, 0 , PAGE_SIZE); + rv = dfd_info_get_sensor(key, buf, PAGE_SIZE, pfunc); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get psu sensor info error. key:0x%x, rv:%d\n", key, rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get psu sensor info ok.value:%s\n", buf); + } + return rv; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sff_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sff_driver.c new file mode 100644 index 000000000000..ab35f75b855b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sff_driver.c @@ -0,0 +1,199 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_cfg_adapter.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +int g_dfd_sff_dbg_level = 0; +module_param(g_dfd_sff_dbg_level, int, S_IRUGO | S_IWUSR); + +extern ssize_t sfp_show_atrr(int sfp_bus, int sfp_mode, const char *attr_name, char *buf, int buf_len); + +int dfd_get_sff_id(unsigned int sff_index) +{ + int key; + int *p_sff_id; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_ID, sff_index, 0); + p_sff_id = dfd_ko_cfg_get_item(key); + if (p_sff_id == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff id error, key:0x%x\n", key); + return -DFD_RV_NO_NODE; + } + DFD_SFF_DEBUG(DBG_VERBOSE, "get sff id ok, sff index:%d, id:0x%x.\n", sff_index, *p_sff_id); + return *p_sff_id; +} + +int dfd_set_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, int value) +{ + int key, ret; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_CPLD_REG, sff_index, cpld_reg_type); + ret = dfd_info_set_int(key, value); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "set sff cpld reg error, key:0x%x,ret:%d.\n", key, ret); + return ret; + } + + return DFD_RV_OK; +} + +ssize_t dfd_get_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, char *buf, int len) +{ + int key, ret, value; + + if(buf == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "param error, buf is NULL. sff_index:%d, cpld_reg_type:%d.\n", + sff_index, cpld_reg_type); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_CPLD_REG, sff_index, cpld_reg_type); + ret = dfd_info_get_int(key, &value, NULL); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff cpld reg error, key:0x%x,ret:%d.\n", key, ret); + return ret; + } + + memset(buf, 0 , len); + return (ssize_t)snprintf(buf, len, "%d\n", value); +} + +ssize_t dfd_get_sff_eeprom_info(unsigned int sff_index, const char *attr_name, char *buf, int buf_len) +{ + int ret; + int sff_id, sff_bus, sff_speed; + + if(!buf || !attr_name || buf_len <= 0) { + DFD_SFF_DEBUG(DBG_ERROR, "param error, buf or attr_name is NULL. sff index:%d, buf len:%d.\n", + sff_index, buf_len); + return -DFD_RV_INVALID_VALUE; + } + + sff_id = dfd_get_sff_id(sff_index); + if (sff_id < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff id error, sff_index:%d, ret:%d\n", sff_index, sff_id); + return -DFD_RV_NODE_FAIL; + + } + sff_bus = RG_GET_SFF_I2C_ADAPTER(sff_id); + sff_speed = RG_GET_SFF_SPEED_MODE(sff_id); + + memset(buf, 0 , buf_len); + ret = sfp_show_atrr(sff_bus, sff_speed, attr_name, buf, buf_len); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "prase sff eeprom info error. sff index:%d, bus:%d, speed mode:%d, attr_name:%s.\n", + sff_index, sff_bus, sff_speed, attr_name); + } + + return ret; +} + +ssize_t dfd_get_sff_dir_name(unsigned int sff_index, char *buf, int buf_len) +{ + int key; + char *sff_dir_name; + + if (buf == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "param error. buf is NULL.sff index:%d", sff_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, buf_len); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_DIR_NAME, sff_index, 0); + sff_dir_name = dfd_ko_cfg_get_item(key); + if (sff_dir_name == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "sff dir name config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + DFD_SFF_DEBUG(DBG_VERBOSE, "%s\n", sff_dir_name); + snprintf(buf, buf_len, "%s", sff_dir_name); + return strlen(buf); + +} + +int dfd_get_sff_polling_size(void) +{ + int key; + int *p_eeprom_size; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_POLLING_SIZE, 0, 0); + + p_eeprom_size = dfd_ko_cfg_get_item(key); + if (p_eeprom_size == NULL) { + DFD_SFF_DEBUG(DBG_VERBOSE, "get sff polling size error, maybe unsupport sff polling. key:0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + return *p_eeprom_size; +} + +ssize_t dfd_get_sff_polling_data(unsigned int sff_index, char *buf, loff_t offset, size_t count) +{ + int key, eeprom_size; + ssize_t rd_len; + loff_t rd_addr; + char *logic_dev_path; + int *p_base_addr; + + if(buf == NULL || offset < 0 || count <= 0) { + DFD_SFF_DEBUG(DBG_ERROR, "params error, offset:%lld, count:%lu.\n", offset, count); + return -DFD_RV_INVALID_VALUE; + } + + eeprom_size = dfd_get_sff_polling_size(); + if (eeprom_size < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff polling size error, ret:%d.\n", eeprom_size); + return -DFD_RV_DEV_NOTSUPPORT; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_POLLING_DATA_BASE_ADDR, sff_index, 0); + p_base_addr = dfd_ko_cfg_get_item(key); + if (p_base_addr == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff polling data base addr error, sff_index:%u, key:0x%x.\n", + sff_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_POLLING_LOGIC_DEV_PATH, sff_index, 0); + logic_dev_path = dfd_ko_cfg_get_item(key); + if (logic_dev_path == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff polling logic device path error, key=0x%08x.\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DFD_SFF_DEBUG(DBG_VERBOSE, "sff:%u, eeprom size:0x%x, base addr:0x%x, path:%s, offset:0x%llx, rd_len:%lu.\n", + sff_index, eeprom_size, *p_base_addr, logic_dev_path, offset, count); + + if (offset >= eeprom_size) { + DFD_SFF_DEBUG(DBG_VERBOSE, "offset:0x%llx, eeprom size:0x%x, EOF.\n", + offset, eeprom_size); + return 0; + } + + if (offset + count > eeprom_size) { + DFD_SFF_DEBUG(DBG_VERBOSE, "read count out of range. input len:%lu, read len:%llu.\n", + count, eeprom_size - offset); + count = eeprom_size - offset; + } + + rd_addr = *p_base_addr + offset; + rd_len = dfd_ko_read_file(logic_dev_path, rd_addr, buf, count); + if (rd_len < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read sff polling data failed, loc:%s, offset:0x%llx, rd_len:%lu, ret:%ld,\n", + logic_dev_path, rd_addr, count, rd_len); + } else { + DFD_SFF_DEBUG(DBG_VERBOSE, "read sff polling data success, loc:%s, offset:0x%llx, rd_len:%lu, rd_len:%ld,\n", + logic_dev_path, rd_addr, count, rd_len); + } + + return rd_len; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sfpbase.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sfpbase.c new file mode 100644 index 000000000000..4084edcdab79 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_sfpbase.c @@ -0,0 +1,986 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg_adapter.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" +#include "./include/dfd_sfpparse.h" + +#define DFD_TEMP_BUFF_SIZE (128) +#define DFD_SFP_OPTOE_ADDR (0x50) +#define DFD_SFP_PAGE_SIZE (256) +#define DFD_FPATH_MAX_LEN (64) +#define DFD_QSFP_DOM_SIZE (8) +#define SFP_DIAGNOSTIC_MONITORING_TYPE_ADDR (92) + +/* sfp cable length */ +static char *g_sfp_cable_length_type[] = { + "LengthSMFkm-UnitsOfKm", /* byte14 */ + "LengthSMF(UnitsOf100m)", /* byte15 */ + "Length50um(UnitsOf10m)", /* byte16 */ + "Length62.5um(UnitsOfm)", /* byte17 */ + "LengthCable(UnitsOfm)", /* byte18 */ + "LengthOM3(UnitsOf10m)", /* byte19 */ +}; + +/* qsfp cable length */ +static char *g_qsfp_cable_length_type[] = { + "Length(km)", /* byte142 */ + "Length OM3(2m)", /* byte143 */ + "Length OM2(m)", /* byte144 */ + "Length OM1(m)", /* byte145 */ + "Length Cable Assembly(m)", /* byte146 */ +}; + +/* qsfp sepecification compliance*/ +static struct sff_e2_spec_comp_s g_qsfp_spec_comp[] = { + {0, "10/40G Ethernet Compliance Code", qsfp_comp_10_ethcc_bitmap}, /* byte131 */ + {1, "SONET Compliance codes" , qsfp_comp_socc_bitmap}, /* byte132 */ + {2, "SAS/SATA compliance codes", qsfp_comp_sscc_bitmap}, /* byte133 */ + {3, "Gigabit Ethernet Compliant codes", qsfp_comp_gethcc_bitmap}, /* byte134 */ + {4, "Fibre Channel link length", qsfp_comp_fcll_bitmap}, /* byte135 */ + {5, "Transmitter Technology", qsfp_comp_tt_bitmap}, /* byte136 */ + {6, "Fibre Channel transmission media", qsfp_comp_fctm_bitmap}, /* byte137 */ + {7, "Fibre Channel Speed", qsfp_comp_fcs_bitmap}, /* byte138 */ +}; + +/* sfp sepecification compliance*/ +static struct sff_e2_spec_comp_s g_sfp_spec_comp[] = { + {0, "10GEthernetComplianceCode", sfp_comp_10_ethcc_bitmap}, /* byte3 */ + {0, "InfinibandComplianceCode" , sfp_comp_infcc_bitmap}, /* byte3 */ + {1, "ESCONComplianceCodes", sfp_comp_escc_bitmap}, /* byte4 */ + {1, "SONETComplianceCodes", sfp_comp_socc1_bitmap}, /* byte4 */ + {2, "SONETComplianceCodes", sfp_comp_socc2_bitmap}, /* byte5 */ + {3, "EthernetComplianceCodes", sfp_comp_ethcc_bitmap}, /* byte6 */ + {4, "FibreChannelLinkLength", sfp_comp_fcll_bitmap}, /* byte7 */ + {4, "FibreChannelTechnology", sfp_comp_fct1_bitmap}, /* byte7 */ + {5, "FibreChannelTechnology", sfp_comp_fct2_bitmap}, /* byte8 */ + {5, "SFP+CableTechnology", sfp_comp_sfpct_bitmap}, /* byte8 */ + {6, "FibreChannelTransmissionMedia", sfp_comp_fctm_bitmap}, /* byte9 */ + {7, "FibreChannelSpeed", sfp_comp_fcs_bitmap}, /* byte10 */ +}; + +static void dump_date(unsigned char *data, struct rj_eeprom_parse_t *eep_parse) +{ + int i = 0; + DFD_SFF_DEBUG(DBG_VERBOSE, "eeprom return data, addr 0x%x, offset %d, suboff %d, size %d, type %d:\n", + eep_parse->addr, eep_parse->offset, eep_parse->sub_offset, + eep_parse->size, eep_parse->type); + for (i = 0; i < eep_parse->size; i++) { + DFD_SFF_DEBUG(DBG_VERBOSE, " data[%d]=0x%x=\n", i, data[i]); + } +} + +static int twos_comp(int num, int bits) +{ + if ((num & (1 << (bits - 1))) != 0) { + num = num - (1 << bits); + } + return num; +} + +static int read_optoe_eeprom_data(const unsigned int sfp_bus, + const unsigned char sfp_addr, + const unsigned int sfp_offset, char *buf, int read_bytes) +{ + char filename[DFD_FPATH_MAX_LEN]; + int ret; + + memset(filename, 0, sizeof(filename)); + snprintf(filename, sizeof(filename), "/sys/bus/i2c/devices/%d-%04x/eeprom",sfp_bus,sfp_addr); + DFD_SFF_DEBUG(DBG_VERBOSE, "read optoe eeprom, fpath:%s, offset:0x%x, read bytes:%d.\n", filename, sfp_offset, read_bytes); + ret = dfd_ko_read_file(filename, sfp_offset, buf, read_bytes); + if ( ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read optoe eeprom error.\n"); + return ret; + } + DFD_SFF_DEBUG(DBG_VERBOSE, " read_optoe_eeprom_data ok.\n"); + + return ret; +} + +static int read_one_eeprom_data(const unsigned int sfp_bus, + const unsigned char sfp_addr, + const unsigned int sfp_offset) +{ + char filename[DFD_FPATH_MAX_LEN]; + unsigned char data; + int ret; + + memset(filename, 0, sizeof(filename)); + snprintf(filename, sizeof(filename), "/sys/bus/i2c/devices/%d-%04x/eeprom",sfp_bus,sfp_addr); + DFD_SFF_DEBUG(DBG_VERBOSE, "read one eeprom date, fpath:%s, offset:0x%x.\n", filename, sfp_offset); + ret = dfd_ko_read_file(filename, sfp_offset, &data, 1); + if ( ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read one eeprom error.\n"); + return ret; + } + DFD_SFF_DEBUG(DBG_VERBOSE, " read_one_eeprom_data get data 0x%x\n", data); + + return data; + +} + +static int get_calibration_type(const unsigned int sfp_bus, + rj_dom_type_t dom_type) +{ + int calb_type; + int tmp_data; + + if (dom_type == DOM_SFF8436) { + calb_type = 1; + } else { + tmp_data = read_one_eeprom_data(sfp_bus, DFD_SFP_OPTOE_ADDR, SFP_DIAGNOSTIC_MONITORING_TYPE_ADDR); + if ((tmp_data>>5)&1) { + calb_type = 1; + } else if ((tmp_data>>4)&1) { + calb_type = 2; + } else { + calb_type = 0; + } + } + return calb_type; +} + +static int get_dom_ext_calibration_constants(rj_dom_ext_calibration_t dom_ext_type) +{ + int off; + + switch (dom_ext_type) { + case EXTCALB_RX_PWR_4: + off = 56; + break; + case EXTCALB_RX_PWR_3: + off = 60; + break; + case EXTCALB_RX_PWR_2: + off = 64; + break; + case EXTCALB_RX_PWR_1: + off = 68; + break; + case EXTCALB_RX_PWR_0: + off = 72; + break; + case EXTCALB_TX_I_Slope: + off = 76; + break; + case EXTCALB_TX_I_Offset: + off = 78; + break; + case EXTCALB_TX_PWR_Slope: + off = 80; + break; + case EXTCALB_TX_PWR_Offset: + off = 82; + break; + case EXTCALB_T_Slope: + off = 84; + break; + case EXTCALB_T_Offset: + off = 86; + break; + case EXTCALB_V_Slope: + off = 88; + break; + case EXTCALB_V_Offset: + off = 90; + break; + default: + off = 0; + DFD_SFF_DEBUG(DBG_ERROR, "Not support type dom_ext_type\n"); + break; + } + + return off; +} + +static void get_div_mod_4(int idata, int divdata, + int *out_div, int *out_mod) +{ + *out_div = idata/divdata; + *out_mod = (idata*10000/divdata)%10000; +} + +static void power_in_dbm_str(int result, char *out_buf, int buf_len) +{ + int div_result, mod_result; + + if (result == 0) { + snprintf(out_buf, buf_len, "%s\n", "-inf"); + } else if (result < 0) { + snprintf(out_buf, buf_len, "%s\n", "NaN"); + } else { + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } +} + +static int calc_rx_power_value(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + int msb, int lsb, int *result) +{ + int off, value; + unsigned int cal_type; + int rx_pwr_byte0, rx_pwr_byte1, rx_pwr_byte2, rx_pwr_byte3; + int rx_pwr_4, rx_pwr_3, rx_pwr_2, rx_pwr_1, rx_pwr_0, rx_pwr; + int bus_addr; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + value = (msb << 8) | (lsb & 0xff); + + if (cal_type == 1) { + /* Internal Calibration */ + *result = value; + return DFD_RV_OK; + } + if (cal_type == 2) { + /* XXX: External Calibration + # RX_PWR(uW) = RX_PWR_4 * RX_PWR_AD + + # RX_PWR_3 * RX_PWR_AD + + # RX_PWR_2 * RX_PWR_AD + + # RX_PWR_1 * RX_PWR_AD + + # RX_PWR(0)*/ + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_4); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_4 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_3); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_3 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_2); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_2 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_1); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_1 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_RX_PWR_0); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + rx_pwr_byte3 = read_one_eeprom_data(sfp_bus, bus_addr, off); + rx_pwr_byte2 = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + rx_pwr_byte1 = read_one_eeprom_data(sfp_bus, bus_addr, off+2); + rx_pwr_byte0 = read_one_eeprom_data(sfp_bus, bus_addr, off+3); + rx_pwr_0 = (rx_pwr_byte3 << 24) | (rx_pwr_byte2 << 16) | (rx_pwr_byte1 << 8) | (rx_pwr_byte0 & 0xff); + + rx_pwr = (rx_pwr_4 * value) + (rx_pwr_3 * value) + (rx_pwr_2 * value) + (rx_pwr_1 * value) + rx_pwr_0; + + *result = rx_pwr; + return DFD_RV_OK; + } + return -DFD_RV_TYPE_ERR; +} + +static void sfp_calc_rx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int ret, result; + + ret = calc_rx_power_value(sfp_bus, eep_parse, data[0], data[1], &result); + if(ret < 0) { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + power_in_dbm_str(result, out_buf, buf_len); + return ; +} + +static void qsfp_calc_rx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, ret, result, div_result, mod_result ; + + for (i = 0; i < DFD_QSFP_DOM_SIZE; i += 2) { + ret = calc_rx_power_value(sfp_bus, eep_parse, data[i], data[i + 1], &result); + if (ret < 0) { + snprintf(out_buf, buf_len, "%srx%dpower: Unknown\n", out_buf, (i/2 + 1)); + } else { + if (result == 0) { + snprintf(out_buf, buf_len, "%srx%dpower: -inf\n", out_buf, (i/2 + 1)); + } else if (result < 0) { + snprintf(out_buf, buf_len, "%srx%dpower: NaN\n", out_buf, (i/2 + 1)); + } else { + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%srx%dpower: %d.%04d\n", out_buf, (i/2 + 1), div_result, mod_result); + } + } + } + return ; + +} + +static int calc_tx_power_value(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + int msb, int lsb, int *result) +{ + int off, value; + unsigned int cal_type; + int msb_tx_pwr, lsb_tx_pwr, tx_pwr_slope, tx_pwr_offset; + int bus_addr; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + value = (msb << 8) | (lsb & 0xff); + DFD_SFF_DEBUG(DBG_VERBOSE, "calc_tx_power. sfp_bus:%d, value:0x%x, cal_type:%d.\n", sfp_bus, value, cal_type); + + if (cal_type == 1) { + *result = value; + return DFD_RV_OK; + } + if (cal_type == 2) { + /* XXX: TX_PWR(uW) = TX_PWR_Slope * TX_PWR_AD + TX_PWR_Offset */ + off = get_dom_ext_calibration_constants(EXTCALB_TX_PWR_Slope); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_tx_pwr = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_tx_pwr = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + tx_pwr_slope = (msb_tx_pwr << 8) | (lsb_tx_pwr & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_TX_PWR_Offset); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_tx_pwr = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_tx_pwr = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + tx_pwr_offset = (msb_tx_pwr << 8) | (lsb_tx_pwr & 0xff); + tx_pwr_offset = twos_comp(tx_pwr_offset, 16); + + *result = tx_pwr_slope * value + tx_pwr_offset; + return DFD_RV_OK; + } + return -DFD_RV_TYPE_ERR; +} + +static void sfp_calc_tx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int ret, result; + + ret = calc_tx_power_value(sfp_bus, eep_parse, data[0], data[1], &result); + if(ret < 0) { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + power_in_dbm_str(result, out_buf, buf_len); + return ; +} + +static void qsfp_calc_tx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, ret, result, div_result, mod_result ; + + for (i = 0; i < DFD_QSFP_DOM_SIZE; i += 2) { + ret = calc_tx_power_value(sfp_bus, eep_parse, data[i], data[i + 1], &result); + if (ret < 0) { + snprintf(out_buf, buf_len, "%stx%dpower: Unknown\n", out_buf, (i/2 + 1)); + } else { + if (result == 0) { + snprintf(out_buf, buf_len, "%stx%dpower: -inf\n", out_buf, (i/2 + 1)); + } else if (result < 0) { + snprintf(out_buf, buf_len, "%stx%dpower: NaN\n", out_buf, (i/2 + 1)); + } else { + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%stx%dpower: %d.%04d\n", out_buf, (i/2 + 1), div_result, mod_result); + } + } + } + return ; +} + +static int calc_bias_value(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + int msb, int lsb, int *div_result, int *mod_result) +{ + int off; + unsigned int cal_type, result; + int msb_i, lsb_i, i_slope, i_offset; + int bus_addr; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + result = (msb << 8) | (lsb & 0xff); + + if (cal_type == 1) { + /* Internal Calibration */ + get_div_mod_4(result, 500, div_result, mod_result); + return DFD_RV_OK; + } + if (cal_type == 2) { + /* XXX: External Calibration */ + /* I(uA) = I_Slope * I_AD + I_Offset */ + off = get_dom_ext_calibration_constants(EXTCALB_TX_I_Slope); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_i = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_i = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + i_slope = (msb_i << 8) | (lsb_i & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_TX_I_Offset); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_i = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_i = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + i_offset = (msb_i << 8) | (lsb_i & 0xff); + i_offset = twos_comp(i_offset, 16); + + result = i_slope * result + i_offset; + get_div_mod_4(result, 500, div_result, mod_result); + return DFD_RV_OK; + } + return -DFD_RV_TYPE_ERR; +} + +static void sfp_calc_tx_bias(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int ret, div_result, mod_result; + + ret = calc_bias_value(sfp_bus, eep_parse, data[0], data[1], &div_result, &mod_result); + if(ret < 0) { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + return ; +} + +static void qsfp_calc_tx_bias(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, ret, div_result, mod_result; + + for (i = 0; i < DFD_QSFP_DOM_SIZE; i += 2) { + ret = calc_bias_value(sfp_bus, eep_parse, data[i], data[i + 1], &div_result, &mod_result); + if (ret < 0) { + snprintf(out_buf, buf_len, "%stx%dbias: Unknown\n", out_buf, (i/2 + 1)); + } else { + snprintf(out_buf, buf_len, "%stx%dbias: %d.%04d\n", out_buf, (i/2 + 1), div_result, mod_result); + } + } + return ; +} + +static void calc_temperature(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int off; + unsigned int cal_type, msb, lsb, result; + int msb_t, lsb_t, t_slope, t_offset; + int bus_addr; + int div_result, mod_result; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + msb = data[0]; + lsb = data[1]; + + result = (msb << 8) | (lsb & 0xff); + result = twos_comp(result, 16); + if (cal_type == 1) { + /* Internal calibration */ + get_div_mod_4(result, 256, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } else if (cal_type == 2) { + /* XXX:External calibration */ + /* T(C) = T_Slope * T_AD + T_Offset */ + off = get_dom_ext_calibration_constants(EXTCALB_T_Slope); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_t = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_t = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + t_slope = (msb_t << 8) | (lsb_t & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_T_Offset); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_t = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_t = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + t_offset = (msb_t << 8) | (lsb_t & 0xff); + t_offset = twos_comp(t_offset, 16); + + result = t_slope * result + t_offset; + get_div_mod_4(result, 256, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } else { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + } +} + +static void calc_voltage(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int off; + unsigned int cal_type, msb, lsb, result; + int msb_v, lsb_v, v_slope, v_offset; + int bus_addr; + int div_result, mod_result; + + bus_addr = DFD_SFP_OPTOE_ADDR; + cal_type = get_calibration_type(sfp_bus, eep_parse->dom_type); + msb = data[0]; + lsb = data[1]; + result = (msb << 8) | (lsb & 0xff); + + if (cal_type == 1) { + /* Internal Calibration */ + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } else if (cal_type == 2) { + /* XXX:External Calibration */ + /*V(uV) = V_Slope * VAD + V_Offset */ + off = get_dom_ext_calibration_constants(EXTCALB_V_Slope); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_v = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_v = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + v_slope = (msb_v << 8) | (lsb_v & 0xff); + + off = get_dom_ext_calibration_constants(EXTCALB_V_Offset); + if (eep_parse->dom_type == DOM_SFF8472) { + off += DFD_SFP_PAGE_SIZE; + } + msb_v = read_one_eeprom_data(sfp_bus, bus_addr, off); + lsb_v = read_one_eeprom_data(sfp_bus, bus_addr, off+1); + v_offset = (msb_v << 8) | (lsb_v & 0xff); + v_offset = twos_comp(v_offset, 16); + + result = v_slope * result + v_offset; + get_div_mod_4(result, 10000, &div_result, &mod_result); + snprintf(out_buf, buf_len, "%d.%04d\n", div_result, mod_result); + } else { + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + } +} + +static void convert_date_to_string(unsigned char *inchar, unsigned char *outtxt) +{ + snprintf(outtxt, DFD_TEMP_BUFF_SIZE, "%s%c%c-%c%c-%c%c %c%c", + "20", inchar[0], inchar[1], inchar[2], inchar[3], + inchar[4], inchar[5], inchar[6], inchar[7]); + DFD_SFF_DEBUG(DBG_VERBOSE, "==outtxt %s\n", outtxt); +} + +static void convert_int_to_str(int idata, unsigned char *outtxt) +{ + snprintf(outtxt, DFD_TEMP_BUFF_SIZE, "%d", idata); + DFD_SFF_DEBUG(DBG_VERBOSE, "==outtxt %s\n", outtxt); +} + +static void convert_hex_to_str(unsigned char *inchar, unsigned int len, unsigned char *outtxt, int need_spc) +{ + unsigned char hbit, lbit; + unsigned int i, cnt; + cnt = 0; + for (i=0; i < len; i++) { + hbit = (*(inchar+i)&0xf0)>>4; + lbit = *(inchar+i)&0x0f; + if (hbit > 9) { + outtxt[cnt] = 'a'+hbit-10; + } else { + outtxt[cnt]='0'+hbit; + } + cnt++; + if (lbit > 9) { + outtxt[cnt]='a'+lbit-10; + } else{ + outtxt[cnt]='0'+lbit; + } + cnt++; + if (need_spc && i != len-1) { + outtxt[cnt]='-'; + cnt++; + } + } + outtxt[cnt] = 0; + + DFD_SFF_DEBUG(DBG_VERBOSE, "hex_to_str outtxt %s\n", outtxt); +} + +static bool test_bitmapvalue(unsigned char inchar, + struct rj_e2_enum_type_s *enum_str, int setoff) +{ + if (strcmp(enum_str[setoff].key, "BITVALUE") == 0) { + return true; + } + if (strcmp(enum_str[setoff].key, "NULL") == 0) { + return false; + } + if (((inchar >> setoff) & 1) == 1) { + return true; + } else { + return false; + } +} + +static void convert_strsplit(char *ibuf, char split_c, char *out_buf_1, char *out_buf_2) +{ + int i; + char *out_buf_p; + + out_buf_p = out_buf_1; + for (i = 0; i < strlen(ibuf); i++) { + if (ibuf[i] == split_c) { + out_buf_p = out_buf_2; + continue; + } + *out_buf_p = ibuf[i]; + out_buf_p++; + } +} + +static void convert_bitmapdate_to_string(unsigned char inchar, + struct rj_e2_enum_type_s *enum_str, char *buf, int buf_len) +{ + char tmp_buf[DFD_TEMP_BUFF_SIZE]; + char split_buf_1[DFD_TEMP_BUFF_SIZE]; + char split_buf_2[DFD_TEMP_BUFF_SIZE]; + char *tmp_buf_p; + int i; + + memset(tmp_buf, 0, sizeof(tmp_buf)); + memset(split_buf_1, 0, sizeof(split_buf_1)); + memset(split_buf_2, 0, sizeof(split_buf_2)); + tmp_buf_p = tmp_buf; + for (i = 0; i < 8; i++) { + if (test_bitmapvalue(inchar, enum_str, i) && ((tmp_buf_p-tmp_buf) < DFD_TEMP_BUFF_SIZE)) { + if (tmp_buf_p != tmp_buf) { + snprintf(tmp_buf_p, 2, "%c", ','); + tmp_buf_p++; + } + if (strcmp(enum_str[i].key, "BITVALUE") == 0) { + convert_strsplit(enum_str[i].value, ':', split_buf_1, split_buf_2); + DFD_SFF_DEBUG(DBG_VERBOSE, "bit 0 value %s , bit 1 value %s \n", split_buf_1, split_buf_2); + if ((inchar>>i & 1) == 0) { + snprintf(tmp_buf_p, strlen(split_buf_1)+1, "%s", split_buf_1); + tmp_buf_p += strlen(split_buf_1); + } else { + snprintf(tmp_buf_p, strlen(split_buf_2)+1, "%s", split_buf_2); + tmp_buf_p += strlen(split_buf_2); + } + } else { + snprintf(tmp_buf_p, strlen(enum_str[i].value)+1, "%s", enum_str[i].value); + tmp_buf_p += strlen(enum_str[i].value); + } + DFD_SFF_DEBUG(DBG_VERBOSE, "====tmp_buf %s \n", tmp_buf); + break; + } + } + snprintf(buf, buf_len, "%s\n", tmp_buf); +} + +static bool eep_parse_decode(struct rj_eeprom_parse_t *eep_parse, unsigned char *data, char *buf, int buf_len) +{ + bool ret; + unsigned char tmp; + struct rj_e2_enum_type_s *tmp_enum_str; + char out_buf[DFD_TEMP_BUFF_SIZE]; + int i; + + ret = true; + memset(out_buf, 0, sizeof(out_buf)); + dump_date(data, eep_parse); + switch (eep_parse->type) { + case E2_STR : + snprintf(buf, buf_len, "%s\n", data); + break; + case E2_ENUM: + convert_hex_to_str(data, eep_parse->size, out_buf, false); + if (eep_parse->enum_str != NULL) { + snprintf(buf, buf_len, "%s\n", "Unknown"); + tmp_enum_str = eep_parse->enum_str; + i = 0; + while (strcmp(tmp_enum_str->key, "NULL") != 0 && i < 100) { + DFD_SFF_DEBUG(DBG_VERBOSE, " key =%s, out_buf %s", tmp_enum_str->key, out_buf); + if (strcmp(tmp_enum_str->key, out_buf) == 0) { + DFD_SFF_DEBUG(DBG_VERBOSE, "====mach==\n"); + snprintf(buf, buf_len, "%s\n", tmp_enum_str->value); + break; + } + i++; + tmp_enum_str++; + } + } else { + snprintf(buf, buf_len, "0x%s\n", out_buf); + } + break; + case E2_INT: + convert_int_to_str(data[0], out_buf); + snprintf(buf, buf_len, "%s\n", out_buf); + break; + case E2_HEX: + convert_hex_to_str(data, eep_parse->size, out_buf, true); + snprintf(buf, buf_len, "%s\n", out_buf); + break; + case E2_DATE: + convert_date_to_string(data, out_buf); + snprintf(buf, buf_len, "%s\n", out_buf); + break; + case E2_BITVALUE: + tmp = data[0]; + if (((tmp >> eep_parse->sub_offset) & 1) == 1) { + snprintf(buf, buf_len, "1\n"); + } else { + snprintf(buf, buf_len, "0\n"); + } + break; + case E2_BITVALUE4: + tmp = data[0]; + if (((tmp >> eep_parse->sub_offset) & 1) == 1) { + snprintf(buf, buf_len, "1\n"); + } else { + snprintf(buf, buf_len, "0\n"); + } + break; + case E2_BITMAP: + tmp = data[0]; + if (eep_parse->enum_str != NULL) { + convert_bitmapdate_to_string(tmp, eep_parse->enum_str, buf, buf_len); + } else { + snprintf(buf, buf_len, "0x%x\n", tmp); + } + break; + default: + ret = false; + DFD_SFF_DEBUG(DBG_ERROR, "Not support type %d \n", eep_parse->type); + break; + } + return ret; +} + +static void sfp_cable_length_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, c_flag; + + if (eep_parse->size <0 || eep_parse->size > ARRAY_SIZE(g_sfp_cable_length_type)) { + DFD_SFF_DEBUG(DBG_ERROR, "size error. sfp_bus: %d, eeprom parse size:%d.\n", sfp_bus, eep_parse->size); + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + + c_flag = 0; + for(i = 0; i < eep_parse->size; i++) { + if(data[i] != 0) { + c_flag = 1; + snprintf(out_buf, buf_len, "%s%s: %d\n", out_buf, g_sfp_cable_length_type[i], data[i]); + } + } + + if (c_flag == 0) { + snprintf(out_buf, buf_len, "%s\n", "Unspecified"); + } + + return ; +} + +static void qsfp_cable_length_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, c_flag; + + if (eep_parse->size <0 || eep_parse->size > ARRAY_SIZE(g_qsfp_cable_length_type)) { + DFD_SFF_DEBUG(DBG_ERROR, "size error. sfp_bus: %d, eeprom parse size:%d.\n", sfp_bus, eep_parse->size); + snprintf(out_buf, buf_len, "%s\n", "Unknown"); + return ; + } + c_flag = 0; + for(i = 0; i < eep_parse->size; i++) { + if(data[i] != 0) { + c_flag = 1; + snprintf(out_buf, buf_len, "%s%s: %d\n", out_buf, g_qsfp_cable_length_type[i], data[i]); + } + } + if (c_flag == 0) { + snprintf(out_buf, buf_len, "%s\n", "Unspecified"); + } + return ; +} + +static void sfp_spec_comp_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, s_flag, reg_offset; + int spec_comp_len; + char buf_tmp[DFD_TEMP_BUFF_SIZE]; + + spec_comp_len = ARRAY_SIZE(g_sfp_spec_comp); + s_flag = 0; + for(i = 0; i < spec_comp_len; i++) { + reg_offset = g_sfp_spec_comp[i].offset; + if (reg_offset < 0 || reg_offset >= eep_parse->size ||g_sfp_spec_comp[i].attr_value == NULL ) { + DFD_SFF_DEBUG(DBG_ERROR, "g_qsfp_spec_comp config error. sfp_bus: %d, g_qsfp_spec_comp index:%d, offset:%d, eeprom parse size:%d.\n", + sfp_bus, i, reg_offset, eep_parse->size); + continue; + } + if(data[reg_offset] != 0) { + memset(buf_tmp, 0, sizeof(buf_tmp)); + convert_bitmapdate_to_string(data[reg_offset], g_sfp_spec_comp[i].attr_value, buf_tmp, sizeof(buf_tmp)); + if (strcmp(buf_tmp, "\n") == 0) { + DFD_SFF_DEBUG(DBG_WARN, "qsfp sepecification_compliance.value reserved. sfp_bus:%d, reg offset:%d, value:0x%x\n", + sfp_bus, eep_parse->addr + i, data[i]); + continue; + } + s_flag = 1; + snprintf(out_buf, buf_len, "%s%s: %s", out_buf, g_sfp_spec_comp[i].attr_name, buf_tmp); + } + } + if (s_flag == 0) { + snprintf(out_buf, buf_len, "%s\n", "Unspecified"); + } + return ; +} + +static void qsfp_spec_comp_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len) +{ + int i, s_flag, reg_offset; + int spec_comp_len; + char buf_tmp[DFD_TEMP_BUFF_SIZE]; + + spec_comp_len = ARRAY_SIZE(g_qsfp_spec_comp); + s_flag = 0; + for(i = 0; i < spec_comp_len; i++) { + reg_offset = g_qsfp_spec_comp[i].offset; + if (reg_offset < 0 || reg_offset >= eep_parse->size ||g_qsfp_spec_comp[i].attr_value == NULL ) { + DFD_SFF_DEBUG(DBG_ERROR, "g_qsfp_spec_comp config error. sfp_bus: %d, g_qsfp_spec_comp index:%d, offset:%d, eeprom parse size:%d.\n", + sfp_bus, i, reg_offset, eep_parse->size); + continue; + } + if(data[reg_offset] != 0) { + memset(buf_tmp, 0, sizeof(buf_tmp)); + convert_bitmapdate_to_string(data[reg_offset], g_qsfp_spec_comp[i].attr_value, buf_tmp, sizeof(buf_tmp)); + if (strcmp(buf_tmp, "\n") == 0) { + DFD_SFF_DEBUG(DBG_WARN, "qsfp sepecification_compliance.value reserved. sfp_bus:%d, reg offset:%d, value:0x%x\n", + sfp_bus, eep_parse->addr + i, data[i]); + continue; + } + s_flag = 1; + snprintf(out_buf, buf_len, "%s%s: %s", out_buf, g_qsfp_spec_comp[i].attr_name, buf_tmp); + } + } + if (s_flag == 0) { + snprintf(out_buf, buf_len, "%s\n", "Unspecified"); + } + return ; +} + +ssize_t sfp_show_atrr(int sfp_bus, int sfp_mode, const char *attr_name, char *buf, int buf_len) +{ + struct rj_eeprom_parse_t *eep_parse; + unsigned char data[DFD_TEMP_BUFF_SIZE]; + int i, isqsfp, ret; + char *buf_start; + + if(!attr_name || !buf || buf_len <=0 ) { + DFD_SFF_DEBUG(DBG_ERROR, "param error. attr_name or buf is NULL. sfp_bus:%d,buf_len:%d\n", sfp_bus, buf_len); + return -DFD_RV_INVALID_VALUE; + } + eep_parse = NULL; + if (sfp_mode == RG_SFF_SPEED_100GE) { /* is sff8436 */ + isqsfp = true; + for (i = 0; i < sizeof(ssf8436_interface_id)/sizeof(struct rj_eeprom_parse_t); i++) { + if (strcmp(ssf8436_interface_id[i].attr_name, attr_name) == 0) { + DFD_SFF_DEBUG(DBG_VERBOSE, "match attribute.sfp_bus:%d, speed mode:%d, attr_name:%s.\n", sfp_bus, sfp_mode, attr_name); + eep_parse = &ssf8436_interface_id[i]; + break; + } + } + } else if (sfp_mode == RG_SFF_SPEED_25GE) { + isqsfp = false; + for (i = 0; i < sizeof(ssf8472_interface_id)/sizeof(struct rj_eeprom_parse_t); i++) { + if (strcmp(ssf8472_interface_id[i].attr_name, attr_name) == 0) { + DFD_SFF_DEBUG(DBG_VERBOSE, "match attribute.sfp_bus:%d, speed mode:%d, attr_name:%s.\n", sfp_bus, sfp_mode, attr_name); + eep_parse = &ssf8472_interface_id[i]; + break; + } + } + } else { + DFD_SFF_DEBUG(DBG_ERROR, "sfp attrname:%s, sfp mode:%d, don't support.\n", attr_name, sfp_mode); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (eep_parse == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "not define attr(%s) error.\n", attr_name); + return -DFD_RV_NODE_FAIL; + } + if (eep_parse->size > sizeof(data) ) { + DFD_SFF_DEBUG(DBG_ERROR, "date length error.need size:%d, date size:%lud.\n", eep_parse->size, sizeof(data)); + return -DFD_RV_INVALID_VALUE; + } + memset(data, 0, sizeof(data)); + buf_start = buf; + if (eep_parse->type != E2_BITVALUE4) { + ret = read_optoe_eeprom_data(sfp_bus, eep_parse->addr, eep_parse->offset, data, eep_parse->size); + dump_date(data, eep_parse); + if(ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read eeprom error.\n"); + return ret; + } + if (eep_parse->type == E2_FUNC) { + if( !eep_parse->calc_func ) { + DFD_SFF_DEBUG(DBG_ERROR, "eep_parse->calc_func is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + eep_parse->calc_func(sfp_bus, eep_parse, data, buf, buf_len); + } else { + if (!eep_parse_decode(eep_parse, data, buf, buf_len)) { + DFD_SFF_DEBUG(DBG_ERROR, "eep_parse_decode error.\n"); + return -DFD_RV_DEV_FAIL; + } + } + } else { + /* XXX */ + for (i = 0; i < eep_parse->ext.subaddr_num; i++) { + ret = read_optoe_eeprom_data(sfp_bus, eep_parse->addr, eep_parse->ext.subaddr[i].offset, data, eep_parse->ext.subaddr[i].size); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "read eeprom error.\n"); + return ret; + } + snprintf(buf, buf_len, "%s-%d:", eep_parse->ext.prefix, i); + eep_parse->sub_offset = eep_parse->ext.subaddr[i].sub_offset; + if (!eep_parse_decode(eep_parse, data, buf+(int)strlen(buf_start), buf_len - (int)strlen(buf_start))) { + DFD_SFF_DEBUG(DBG_ERROR, "eep_parse_decode error.\n"); + return -DFD_RV_DEV_FAIL; + } + } + buf = buf_start; + } + return (ssize_t)strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_slot_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_slot_driver.c new file mode 100644 index 000000000000..f29bfc5ed9e1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_slot_driver.c @@ -0,0 +1,81 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_cfg_info.h" +#include "./include/dfd_frueeprom.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define SLOT_SIZE (256) + +int g_dfd_slot_dbg_level = 0; +module_param(g_dfd_slot_dbg_level, int, S_IRUGO | S_IWUSR); + +int dfd_get_slot_status(unsigned int slot_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_PRESENT_STATUS, RG_MAIN_DEV_SLOT, slot_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "get slot status error, key:0x%x\n",key); + return ret; + } + return status; +} + +ssize_t dfd_get_slot_status_str(unsigned int slot_index, char *buf) +{ + int ret; + if(buf == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "params error.slot_index:%d.",slot_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_slot_status(slot_index); + if(ret < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "get slot status error,ret:%d, slot_index:%d\n", ret, slot_index); + return ret; + } + memset(buf, 0 , PAGE_SIZE); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +ssize_t dfd_get_slot_info(unsigned int slot_index, uint8_t cmd, char *buf) +{ + int key, rv; + char slot_buf[SLOT_SIZE]; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "buf is NULL, slot index:%d, cmd:%d\n", slot_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + memset(slot_buf, 0, SLOT_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_SLOT, slot_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "slot i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + + rv = dfd_get_fru_board_data(i2c_dev->bus, i2c_dev->addr, cmd, slot_buf, SLOT_SIZE); + + if (rv < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "slot eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + + DFD_SLOT_DEBUG(DBG_VERBOSE, "%s\n", slot_buf); + snprintf(buf, SLOT_SIZE, "%s\n", slot_buf); + return strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_syseeprom_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_syseeprom_driver.c new file mode 100644 index 000000000000..64ba725f04cb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/dfd_syseeprom_driver.c @@ -0,0 +1,59 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ + +#include + +#include "./include/dfd_module.h" +#include "./include/dfd_cfg.h" +#include "./include/dfd_cfg_adapter.h" +#include "./include/dfd_tlveeprom.h" +#include "../rg_dev_sysfs/include/rg_sysfs_common.h" + +#define EEPROM_SIZE (256) + +int g_dfd_syseeprom_dbg_level = 0; +module_param(g_dfd_syseeprom_dbg_level, int, S_IRUGO | S_IWUSR); + +ssize_t dfd_get_syseeprom_info(uint8_t type, char *buf) +{ + int key, rv; + uint32_t len; + uint8_t eeprom[EEPROM_SIZE]; + uint8_t tlv_buf[EEPROM_SIZE]; + dfd_i2c_dev_t *i2c_dev; + dfd_tlv_type_t tlv_type; + + if (buf == NULL) { + DBG_SYSE2_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, PAGE_SIZE); + memset(eeprom, 0, EEPROM_SIZE); + memset(tlv_buf, 0, EEPROM_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DBG_SYSE2_DEBUG(DBG_ERROR, "syseeprom i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_NODE_FAIL; + } + rv = dfd_ko_i2c_read(i2c_dev->bus, i2c_dev->addr, 0, eeprom, EEPROM_SIZE); + + if (rv < 0) { + DBG_SYSE2_DEBUG(DBG_ERROR, "syseeprom read failed.\n"); + return -DFD_RV_DEV_FAIL; + } + + tlv_type.main_type = type; + tlv_type.ext_type = DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE; + len = sizeof(tlv_buf); + rv = dfd_tlvinfo_get_e2prom_info(eeprom, EEPROM_SIZE, &tlv_type, tlv_buf, &len); + if( rv ) { + DBG_SYSE2_DEBUG(DBG_ERROR, "get tlv type :0x%02x error, ret:%d\n", tlv_type.main_type, rv); + return -DFD_RV_TYPE_ERR; + } + snprintf(buf, EEPROM_SIZE, "%s\n", tlv_buf); + return strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg.h new file mode 100644 index 000000000000..3971b524f695 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg.h @@ -0,0 +1,113 @@ +#ifndef __DFD_CFG_H__ +#define __DFD_CFG_H__ + +#include + +#define DFD_KO_CFG_FILE_NAME "/etc/plat_sysfs_cfg/cfg_file_name" +#define DFD_KO_CFG_FILE_DIR "/etc/plat_sysfs_cfg/" +#define DFD_PUB_CARDTYPE_FILE "/sys/module/ruijie_common/parameters/dfd_my_type" + +#define DFD_CFG_CMDLINE_MAX_LEN (256) +#define DFD_CFG_NAME_MAX_LEN (256) +#define DFD_CFG_VALUE_MAX_LEN (256) +#define DFD_CFG_STR_MAX_LEN (64) +#define DFD_CFG_CPLD_NUM_MAX (16) +#define DFD_PRODUCT_ID_LENGTH (8) +#define DFD_PID_BUF_LEN (32) +#define DFD_TEMP_NAME_BUF_LEN (32) + +#define DFD_CFG_EMPTY_VALUE (-1) +#define DFD_CFG_INVALID_VALUE (0) + +#define DFD_CFG_KEY(item, index1, index2) \ + ((((item) & 0xff) << 24) | (((index1) & 0xffff) << 8) | ((index2) & 0xff)) +#define DFD_CFG_ITEM_ID(key) (((key) >> 24) & 0xff) +#define DFD_CFG_INDEX1(key) (((key) >> 8) & 0xffff) +#define DFD_CFG_INDEX2(key) ((key)& 0xff) + +#define INDEX_NOT_EXIST (-1) +#define INDEX1_MAX (0xffff) +#define INDEX2_MAX (0xff) + +#define DFD_CFG_ITEM_ALL \ + DFD_CFG_ITEM(DFD_CFG_ITEM_NONE, "none", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DEV_NUM, "dev_num", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_TOLERANCE, "fan_speed_tolerance", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_TARGET, "fan_speed_target", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_DIRECTION, "fan_direction", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_LED_STATUS_DECODE, "led_status_decode", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_LPC_DEV, "cpld_lpc_dev", INDEX1_MAX, DFD_CFG_CPLD_NUM_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_ID, "sff_id", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_POLLING_SIZE, "sff_polling_size", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_POLLING_DATA_BASE_ADDR, "sff_polling_data_base_addr", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_INT_END, "end_int", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_MODE, "mode_cpld", INDEX1_MAX, DFD_CFG_CPLD_NUM_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_NAME, "cpld_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_TYPE, "cpld_type", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_E2_MODE, "fan_e2_mode", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_NAME, "psu_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_DIR_NAME, "sff_dir_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_POLLING_LOGIC_DEV_PATH, "sff_polling_logic_dev_path", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_STRING_END, "end_string", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_I2C_DEV, "cpld_i2c_dev", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_OTHER_I2C_DEV, "other_i2c_dev", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_I2C_DEV_END, "end_i2c_dev", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_ROLL_STATUS, "fan_roll_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED, "fan_speed", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_RATIO, "fan_ratio", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_LED_STATUS, "led_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_VERSION, "cpld_version", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_TEST_REG, "cpld_test_reg", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DEV_PRESENT_STATUS, "dev_present_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_STATUS, "psu_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_TEMP, "hwmon_temp", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_IN, "hwmon_in", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_PSU, "hwmon_psu", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_CPLD_REG, "sff_cpld_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_INFO_CTRL_END, "end_info_ctrl", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) _id, +typedef enum dfd_cfg_item_id_s { + DFD_CFG_ITEM_ALL +} dfd_cfg_item_id_t; + +#define DFD_CFG_ITEM_IS_INT(item_id) \ + (((item_id) > DFD_CFG_ITEM_NONE) && ((item_id) < DFD_CFG_ITEM_INT_END)) + +#define DFD_CFG_ITEM_IS_STRING(item_id) \ + (((item_id) > DFD_CFG_ITEM_INT_END) && ((item_id) < DFD_CFG_ITEM_STRING_END)) + +#define DFD_CFG_ITEM_IS_I2C_DEV(item_id) \ + (((item_id) > DFD_CFG_ITEM_STRING_END) && ((item_id) < DFD_CFG_ITEM_I2C_DEV_END)) + +#define DFD_CFG_ITEM_IS_INFO_CTRL(item_id) \ + (((item_id) > DFD_CFG_ITEM_I2C_DEV_END) && ((item_id) < DFD_CFG_ITEM_INFO_CTRL_END)) + +typedef struct index_range_s { + int index1_max; + int index2_max; +} index_range_t; + +typedef struct val_convert_node_s { + struct list_head lst; + int int_val; + char str_val[DFD_CFG_STR_MAX_LEN]; + int index1; + int index2; +} val_convert_node_t; + +void *dfd_ko_cfg_get_item(int key); + +void dfd_ko_cfg_show_item(int key); + +int32_t dfd_dev_cfg_init(void); + +void dfd_dev_cfg_exit(void); + +#endif /* __DFD_CFG_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_adapter.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_adapter.h new file mode 100644 index 000000000000..70d8b536c437 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_adapter.h @@ -0,0 +1,46 @@ +#ifndef __DFD_CFG_ADAPTER_H__ +#define __DFD_CFG_ADAPTER_H__ + +#define DFD_KO_CPLD_I2C_RETRY_SLEEP (10) /* ms */ +#define DFD_KO_CPLD_I2C_RETRY_TIMES (50 / DFD_KO_CPLD_I2C_RETRY_SLEEP) + +#define DFD_KO_CPLD_GET_SLOT(addr) ((addr >> 24) & 0xff) +#define DFD_KO_CPLD_GET_ID(addr) ((addr >> 16) & 0xff) +#define DFD_KO_CPLD_GET_INDEX(addr) (addr & 0xffff) +#define DFD_KO_CPLD_MODE_I2C_STRING "i2c" +#define DFD_KO_CPLD_MODE_LPC_STRING "lpc" + +typedef struct dfd_i2c_dev_s { + int bus; + int addr; +} dfd_i2c_dev_t; + +typedef enum dfd_i2c_dev_mem_s { + DFD_I2C_DEV_MEM_BUS, + DFD_I2C_DEV_MEM_ADDR, + DFD_I2C_DEV_MEM_END +} dfd_i2c_dev_mem_t; + +typedef enum cpld_mode_e { + DFD_CPLD_MODE_I2C, + DFD_CPLD_MODE_LPC, +} cpld_mode_t; + +typedef enum i2c_mode_e { + DFD_I2C_MODE_NORMAL_I2C, + DFD_I2C_MODE_SMBUS, +} i2c_mode_t; + +extern char *g_dfd_i2c_dev_mem_str[DFD_I2C_DEV_MEM_END]; + +int32_t dfd_ko_cpld_read(int32_t addr, uint8_t *buf); + +int32_t dfd_ko_cpld_write(int32_t addr, uint8_t val); + +int32_t dfd_ko_i2c_read(int bus, int addr, int offset, uint8_t *buf, uint32_t size); + +int32_t dfd_ko_i2c_write(int bus, int addr, int offset, uint8_t *buf, uint32_t size); + +int32_t dfd_ko_read_file(char *fpath, int32_t addr, uint8_t *val, int32_t read_bytes); + +#endif /* __DFD_CFG_ADAPTER_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_file.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_file.h new file mode 100644 index 000000000000..50d7a42d5564 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_file.h @@ -0,0 +1,37 @@ +#ifndef __DFD_CFG_FILE_H__ +#define __DFD_CFG_FILE_H__ + +#include + +#define KFILE_RV_OK (0) +#define KFILE_RV_INPUT_ERR (-1) +#define KFILE_RV_STAT_FAIL (-2) +#define KFILE_RV_OPEN_FAIL (-3) +#define KFILE_RV_MALLOC_FAIL (-4) +#define KFILE_RV_RD_FAIL (-5) +#define KFILE_RV_ADDR_ERR (-6) +#define KFILE_RV_WR_FAIL (-7) + +#define IS_CR(c) ((c) == '\n') + +typedef struct kfile_ctrl_s { + int32_t size; + int32_t pos; + char *buf; +} kfile_ctrl_t; + +int kfile_open(char *fname, kfile_ctrl_t *kfile_ctrl); + +void kfile_close(kfile_ctrl_t *kfile_ctrl); + +int kfile_gets(char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl); + +int kfile_read(int32_t addr, char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl); + +int kfile_iterate_dir(const char *dir_path, const char *obj_name, char *match_name, int len); + +#if 0 + +int kfile_write(char *fpath, int32_t addr, char *buf, int buf_size); +#endif +#endif /* __DFD_CFG_FILE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_info.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_info.h new file mode 100644 index 000000000000..dc1ed17651b9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_info.h @@ -0,0 +1,109 @@ +#ifndef __DFD_CFG_INFO_H__ +#define __DFD_CFG_INFO_H__ + +#include + +typedef int (*info_num_buf_to_value_f)(uint8_t *num_buf, int buf_len, int *num_val); + +typedef int (*info_buf_to_buf_f)(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new); + +#define IS_INFO_FRMT_BIT(frmt) ((frmt) == INFO_FRMT_BIT) +#define IS_INFO_FRMT_BYTE(frmt) (((frmt) == INFO_FRMT_BYTE) || ((frmt) == INFO_FRMT_NUM_BYTES)) +#define IS_INFO_FRMT_NUM_STR(frmt) ((frmt) == INFO_FRMT_NUM_STR) +#define IS_INFO_FRMT_NUM_BUF(frmt) ((frmt) == INFO_FRMT_NUM_BUF) +#define IS_INFO_FRMT_BUF(frmt) ((frmt) == INFO_FRMT_BUF) + +#define INFO_INT_MAX_LEN (32) +#define INFO_INT_LEN_VALAID(len) (((len) > 0) && ((len) < INFO_INT_MAX_LEN)) + +#define INFO_BUF_MAX_LEN (128) +#define INFO_BUF_LEN_VALAID(len) (((len) > 0) && ((len) < INFO_BUF_MAX_LEN)) + +#define INFO_BIT_OFFSET_VALID(bit_offset) (((bit_offset) >= 0) && ((bit_offset) < 8)) + +typedef enum info_ctrl_mode_e { + INFO_CTRL_MODE_NONE, + INFO_CTRL_MODE_CFG, + INFO_CTRL_MODE_CONS, + INFO_CTRL_MODE_TLV, + INFO_CTRL_MODE_SRT_CONS, + INFO_CTRL_MODE_END +} info_ctrl_mode_t; + +typedef enum info_frmt_e { + INFO_FRMT_NONE, + INFO_FRMT_BIT, + INFO_FRMT_BYTE, + INFO_FRMT_NUM_BYTES, + INFO_FRMT_NUM_STR, + INFO_FRMT_NUM_BUF, + INFO_FRMT_BUF, + INFO_FRMT_END +} info_frmt_t; + +typedef enum info_src_e { + INFO_SRC_NONE, + INFO_SRC_CPLD, + INFO_SRC_FPGA, + INFO_SRC_OTHER_I2C, + INFO_SRC_FILE, + INFO_SRC_END +} info_src_t; + +typedef enum info_pola_e { + INFO_POLA_NONE, + INFO_POLA_POSI, + INFO_POLA_NEGA, + INFO_POLA_END +} info_pola_t; + +#define INFO_FPATH_MAX_LEN (128) +#define INFO_STR_CONS_MAX_LEN (64) +typedef struct info_ctrl_s { + info_ctrl_mode_t mode; + int32_t int_cons; + info_src_t src; + info_frmt_t frmt; + info_pola_t pola; + char fpath[INFO_FPATH_MAX_LEN]; + int32_t addr; + int32_t len; + int32_t bit_offset; + char str_cons[INFO_STR_CONS_MAX_LEN]; + int32_t int_extra1; + int32_t int_extra2; +} info_ctrl_t; + +typedef enum info_ctrl_mem_s { + INFO_CTRL_MEM_MODE, + INFO_CTRL_MEM_INT_CONS, + INFO_CTRL_MEM_SRC, + INFO_CTRL_MEM_FRMT, + INFO_CTRL_MEM_POLA, + INFO_CTRL_MEM_FPATH, + INFO_CTRL_MEM_ADDR, + INFO_CTRL_MEM_LEN, + INFO_CTRL_MEM_BIT_OFFSET, + INFO_CTRL_MEM_STR_CONS, + INFO_CTRL_MEM_INT_EXTRA1, + INFO_CTRL_MEM_INT_EXTRA2, + INFO_CTRL_MEM_END +} info_ctrl_mem_t; + +typedef int (*info_hwmon_buf_f)(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new, info_ctrl_t *info_ctrl); + +extern char *g_info_ctrl_mem_str[INFO_CTRL_MEM_END]; +extern char *g_info_src_str[INFO_SRC_END]; +extern char *g_info_frmt_str[INFO_FRMT_END]; +extern char *g_info_pola_str[INFO_POLA_END]; +extern char *g_info_ctrl_mode_str[INFO_CTRL_MODE_END]; + +int dfd_info_get_int(int key, int *ret, info_num_buf_to_value_f pfun); + +int dfd_info_get_buf(int key, uint8_t *buf, int buf_len, info_buf_to_buf_f pfun); + +int dfd_info_set_int(int key, int val); + +int dfd_info_get_sensor(uint32_t key, char *buf, int buf_len, info_hwmon_buf_f pfun); + +#endif /* __DFD_CFG_INFO_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_listnode.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_listnode.h new file mode 100644 index 000000000000..955dfa96e42e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cfg_listnode.h @@ -0,0 +1,30 @@ +#ifndef __DFD_CFG_LISTNODE_H__ +#define __DFD_CFG_LISTNODE_H__ + +#include + +#define LNODE_RV_OK (0) +#define LNODE_RV_INPUT_ERR (-1) +#define LNODE_RV_NODE_EXIST (-2) +#define LNODE_RV_NOMEM (-3) + +typedef struct lnode_root_s { + struct list_head root; +} lnode_root_t; + +typedef struct lnode_node_s { + struct list_head lst; + + int key; + void *data; +} lnode_node_t; + +void *lnode_find_node(lnode_root_t *root, int key); + +int lnode_insert_node(lnode_root_t *root, int key, void *data); + +int lnode_init_root(lnode_root_t *root); + +void lnode_free_list(lnode_root_t *root); + +#endif /* __DFD_CFG_LISTNODE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cpld_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cpld_driver.h new file mode 100644 index 000000000000..f3c7f301168f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_cpld_driver.h @@ -0,0 +1,14 @@ +#ifndef _DFD_CPLD_DRIVER_H_ +#define _DFD_CPLD_DRIVER_H_ + +ssize_t dfd_get_cpld_name(unsigned int cpld_index, char *buf); + +ssize_t dfd_get_cpld_type(unsigned int cpld_index, char *buf); + +ssize_t dfd_get_cpld_version(unsigned int cpld_index, char *buf); + +int dfd_set_cpld_testreg(unsigned int cpld_index, int value); + +int dfd_get_cpld_testreg(unsigned int cpld_index, int *value); + +#endif /* _DFD_CPLD_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_fan_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_fan_driver.h new file mode 100644 index 000000000000..55f99c89bd6a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_fan_driver.h @@ -0,0 +1,32 @@ +#ifndef _DFD_FAN_DRIVER_H_ +#define _DFD_FAN_DRIVER_H_ + +int dfd_get_fan_status(unsigned int fan_index); + +ssize_t dfd_get_fan_info(unsigned int fan_index, uint8_t cmd, char *buf); + +ssize_t dfd_get_fan_speed(unsigned int fan_index, unsigned int motor_index,unsigned int *speed); + +int dfd_set_fan_pwm(unsigned int fan_index, unsigned int motor_index, int pwm); + +int dfd_get_fan_pwm(unsigned int fan_index, unsigned int motor_index, int *pwm); + +int dfd_get_fan_speed_tolerance(unsigned int fan_index, unsigned int motor_index, int *value); + +int dfd_get_fan_speed_target(unsigned int fan_index, unsigned int motor_index, int *value); + +int dfd_get_fan_direction(unsigned int fan_index, unsigned int motor_index, int *value); + +ssize_t dfd_get_fan_status_str(unsigned int fan_index, char *buf); + +ssize_t dfd_get_fan_direction_str(unsigned int fan_index, unsigned int motor_index, char *buf); + +int dfd_get_fan_present_status(unsigned int fan_index); + +int dfd_get_fan_roll_status(unsigned int fan_index, unsigned int motor_index); + +int dfd_get_fan_speed_level(unsigned int fan_index, unsigned int motor_index, int *level); + +int dfd_set_fan_speed_level(unsigned int fan_index, unsigned int motor_index, int level); + +#endif /* _DFD_FAN_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_frueeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_frueeprom.h new file mode 100644 index 000000000000..1b175154672f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_frueeprom.h @@ -0,0 +1,67 @@ +#ifndef DFD_FRUEEPROM_H +#define DFD_FRUEEPROM_H + +/* Per IPMI v2.0 FRU specification */ +typedef struct fru_common_header_s +{ + uint8_t fixed; + uint8_t internal_offset; + uint8_t chassis_offset; + uint8_t board_offset; + uint8_t product_offset; + uint8_t multi_offset; + uint8_t pad; + uint8_t crc; +}__attribute__((packed)) fru_common_header_t; + +/* first byte in header is 1h per IPMI V2 spec. */ + +#define IPMI_FRU_HDR_BYTE_ZERO 1 +#define IPMI_EIGHT_BYTES 8 + +#define IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX 512 +#define IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH 3 +#define IPMI_FRU_SENTINEL_VALUE 0xC1 +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK 0xC0 +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT 0x06 +#define IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK 0x3F +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE 0x03 + +struct ipmi_fru_field +{ + uint8_t type_length_field[IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX]; + /* store length of data stored in buffer */ + unsigned int type_length_field_length; +}; + +typedef struct ipmi_fru_field ipmi_fru_field_t; + +typedef struct ipmi_product_info_s { + uint8_t *language_code; + ipmi_fru_field_t *product_manufacturer_name; + ipmi_fru_field_t *product_name; + ipmi_fru_field_t *product_part_model_number; + ipmi_fru_field_t *product_version; + ipmi_fru_field_t *product_serial_number; + ipmi_fru_field_t *product_asset_tag; + ipmi_fru_field_t *product_fru_file_id; + ipmi_fru_field_t *product_custom_fields; + ipmi_fru_field_t *product_type_fields; +}ipmi_product_info_t; + +typedef struct ipmi_board_info_s { + uint8_t *language_code; + uint8_t *mfg_time; + ipmi_fru_field_t *board_manufacturer; + ipmi_fru_field_t *board_product_name; + ipmi_fru_field_t *board_serial_number; + ipmi_fru_field_t *board_part_number; + ipmi_fru_field_t *board_fru_file_id; + ipmi_fru_field_t *board_custom_fields; /*hw version */ +}ipmi_board_info_t; + +int dfd_get_fru_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len); + +int dfd_get_fru_board_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len); + +#endif /* endif DFD_OPENBMC_TLVEEPROM_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_led_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_led_driver.h new file mode 100644 index 000000000000..7d9daa8fe952 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_led_driver.h @@ -0,0 +1,6 @@ +#ifndef _DFD_LED_DRIVER_H_ +#define _DFD_LED_DRIVER_H_ + +ssize_t dfd_get_led_status(uint16_t led_id, uint8_t led_index, char *buf); + +#endif /* _DFD_LED_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_module.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_module.h new file mode 100644 index 000000000000..693dea50ce32 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_module.h @@ -0,0 +1,148 @@ +#ifndef __DFD_MODULE_H__ +#define __DFD_MODULE_H__ + +typedef enum dfd_rv_s { + DFD_RV_OK = 0, + DFD_RV_INIT_ERR = 1, + DFD_RV_SLOT_INVALID = 2, + DFD_RV_MODE_INVALID = 3, + DFD_RV_MODE_NOTSUPPORT = 4, + DFD_RV_TYPE_ERR = 5, + DFD_RV_DEV_NOTSUPPORT = 6, + DFD_RV_DEV_FAIL = 7, + DFD_RV_INDEX_INVALID = 8, + DFD_RV_NO_INTF = 9, + DFD_RV_NO_NODE = 10, + DFD_RV_NODE_FAIL = 11, + DFD_RV_INVALID_VALUE = 12, + DFD_RV_NO_MEMORY = 13, +} dfd_rv_t; + +typedef enum { + DBG_VERBOSE = 0x01, + DBG_WARN = 0x02, + DBG_ERROR = 0x04, +} dbg_level_t; + +typedef enum status_mem_e { + STATUS_ABSENT = 0, + STATUS_OK = 1, + STATUS_NOT_OK = 2, + STATUS_MEM_END = 3, +} status_mem_t; + +extern int g_dfd_dbg_level; +extern int g_dfd_fan_dbg_level; +extern int g_dfd_fru_dbg_level; +extern int g_dfd_syseeprom_dbg_level; +extern int g_dfd_cpld_dbg_level; +extern int g_dfd_sysled_dbg_level; +extern int g_dfd_slot_dbg_level; +extern int g_dfd_sensor_dbg_level; +extern int g_dfd_psu_dbg_level; +extern int g_dfd_sff_dbg_level; +extern char *g_status_mem_str[STATUS_MEM_END]; + +#define DBG_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_FAN_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fan_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_FRU_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fru_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_SYSE2_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_syseeprom_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_CPLD_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_cpld_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_SYSLED_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sysled_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SLOT_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_slot_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SENSOR_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sensor_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_PSU_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_psu_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SFF_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sff_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +int dfd_get_dev_number(unsigned int main_dev_id, unsigned int minor_dev_id); + +#endif /* __DFD_MODULE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_psu_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_psu_driver.h new file mode 100644 index 000000000000..d9875e8c54fa --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_psu_driver.h @@ -0,0 +1,14 @@ +#ifndef _DFD_PSU_DRIVER_H_ +#define _DFD_PSU_DRIVER_H_ + +ssize_t dfd_get_psu_info(unsigned int psu_index, uint8_t cmd, char *buf); + +ssize_t dfd_get_psu_status_str(unsigned int psu_index, char *buf); + +int dfd_get_psu_present_status(unsigned int psu_index); + +int dfd_get_psu_output_status(unsigned int psu_index); + +int dfd_get_psu_alert_status(unsigned int psu_index); + +#endif /* _DFD_PSU_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sensors_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sensors_driver.h new file mode 100644 index 000000000000..0ad232309564 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sensors_driver.h @@ -0,0 +1,12 @@ +#ifndef _DFD_SENSORS_DRIVER_H_ +#define _DFD_SENSORS_DRIVER_H_ + +ssize_t dfd_get_temp_info(uint8_t main_dev_id, uint8_t dev_index, + uint8_t temp_index, uint8_t temp_attr, char *buf); + +ssize_t dfd_get_voltage_info(uint8_t main_dev_id, uint8_t dev_index, + uint8_t in_index, uint8_t in_attr, char *buf); + +ssize_t dfd_get_psu_sensor_info(uint8_t psu_index, uint8_t sensor_type, char *buf); + +#endif /* _DFD_SENSORS_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sff_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sff_driver.h new file mode 100644 index 000000000000..defbdc4fb77f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sff_driver.h @@ -0,0 +1,18 @@ +#ifndef _DFD_SFF_DRIVER_H_ +#define _DFD_SFF_DRIVER_H_ + +int dfd_get_sff_id(unsigned int sff_index); + +int dfd_set_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, int value); + +ssize_t dfd_get_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, char *buf, int len); + +ssize_t dfd_get_sff_eeprom_info(unsigned int sff_index, const char *attr_name, char *buf, int buf_len); + +ssize_t dfd_get_sff_dir_name(unsigned int sff_index, char *buf, int buf_len); + +int dfd_get_sff_polling_size(void); + +ssize_t dfd_get_sff_polling_data(unsigned int sff_index, char *buf, loff_t offset, size_t count); + +#endif /* _DFD_SFF_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sfpparse.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sfpparse.h new file mode 100644 index 000000000000..f664259f68ea --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_sfpparse.h @@ -0,0 +1,558 @@ +#ifndef _DFD_SFPPARSE_H_ +#define _DFD_SFPPARSE_H_ + +struct rj_e2_enum_type_s { + char key[32]; + char value[128]; +}; + +struct sff_e2_spec_comp_s { + int offset; + char attr_name[128]; + struct rj_e2_enum_type_s *attr_value; +}; + +typedef enum { + E2_STR, + E2_INT, + E2_HEX, + E2_DATE, + E2_BITVALUE, + E2_BITMAP, + E2_ENUM, + E2_FUNC, + E2_BITVALUE4, +} rj_eeprom_type_t; + +struct rj_e2_enum_type_s sff8472_type_of_transceiver[] = { + {"00","Unknown"}, + {"01","GBIC"}, + {"02", "Module soldered to motherboard"}, + {"03", "SFP or SFP Plus"}, + {"04", "300 pin XBI"}, + {"05", "XENPAK"}, + {"06", "XFP"}, + {"07", "XFF"}, + {"08", "XFP-E"}, + {"09", "XPAK"}, + {"0a", "X2"}, + {"0b", "DWDM-SFP"}, + {"0d", "QSFP"}, + {"NULL", ""} +}; + +struct rj_e2_enum_type_s sff8472_exttypeoftransceiver[] = {{"00", "GBIC def not specified"}, + {"01","GBIC is compliant with MOD_DEF 1"}, + {"02","GBIC is compliant with MOD_DEF 2"}, + {"03","GBIC is compliant with MOD_DEF 3"}, + {"04","GBIC/SFP defined by twowire interface ID"}, + {"05","GBIC is compliant with MOD_DEF 5"}, + {"06","GBIC is compliant with MOD_DEF 6"}, + {"07","GBIC is compliant with MOD_DEF 7"}, + {"NULL", ""} +}; + +struct rj_e2_enum_type_s sff8472_connector[] = {{"00", "Unknown"}, + {"01", "SC"}, + {"02", "Fibre Channel Style 1 copper connector"}, + {"03", "Fibre Channel Style 2 copper connector"}, + {"04", "BNC/TNC"}, + {"05", "Fibre Channel coaxial headers"}, + {"06", "FibreJack"}, + {"07", "LC"}, + {"08", "MT-RJ"}, + {"09", "MU"}, + {"0a", "SG"}, + {"0b", "Optical pigtail"}, + {"0C", "MPO Parallel Optic"}, + {"20", "HSSDCII"}, + {"21", "CopperPigtail"}, + {"22", "RJ45"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8472_encoding_codes[] = {{"00","Unspecified"}, + {"01","8B/10B"}, + {"02","4B/5B"}, + {"03","NRZ"}, + {"04","Manchester"}, + {"05", "SONET Scrambled"}, + {"06","64B/66B"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8472_rate_identifier[] = {{"00","Unspecified"}, + {"01","Defined for SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"}, + {"02", "Defined for SFF-8431 (8/4/2G Rx Rate_Select only)"}, + {"03","Unspecified"}, + {"04", "Defined for SFF-8431 (8/4/2G Tx Rate_Select only)"}, + {"05","Unspecified"}, + {"06","Defined for SFF-8431 (8/4/2G Independent Rx & Tx Rate_select)"}, + {"07","Unspecified"}, + {"08", "Defined for FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G"}, + {"09", "Unspecified"}, + {"0a", "Defined for FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, Low=8G/4G"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8436_type_of_transceiver[] = { + {"00","Unknown or unspecified"}, + {"01","GBIC"}, + {"02", "Module/connector soldered to motherboard"}, + {"03", "SFP"}, + {"04", "300 pin XBI"}, + {"05", "XENPAK"}, + {"06", "XFP"}, + {"07", "XFF"}, + {"08", "XFP-E"}, + {"09", "XPAK"}, + {"0a", "X2"}, + {"0b", "DWDM-SFP"}, + {"0c", "QSFP"}, + {"0d", "QSFP+"}, + {"11", "QSFP28"}, + {"NULL", ""} +}; + +struct rj_e2_enum_type_s sff8436_ext_type_of_transceiver[] = { + {"00", "Power Class 1(1.5W max)"}, + {"04", "Power Class 1(1.5W max), CDR present in Tx"}, + {"08", "Power Class 1(1.5W max), CDR present in Rx"}, + {"0c", "Power Class 1(1.5W max), CDR present in Rx Tx"}, + {"10", "Power Class 1(1.5W max), CLEI present"}, + {"14", "Power Class 1(1.5W max), CLEI present, CDR present in Tx"}, + {"18", "Power Class 1(1.5W max), CLEI present, CDR present in Rx"}, + {"1c", "Power Class 1(1.5W max), CLEI present, CDR present in Rx Tx"}, + + {"40", "Power Class 2(2.0W max)"}, + {"44", "Power Class 2(2.0W max), CDR present in Rx"}, + {"48", "Power Class 2(2.0W max), CDR present in Tx"}, + {"4c", "Power Class 2(2.0W max), CDR present in Rx Tx"}, + {"50", "Power Class 2(2.0W max), CLEI present"}, + {"54", "Power Class 2(2.0W max), CLEI present, CDR present in Rx"}, + {"58", "Power Class 2(2.0W max), CLEI present, CDR present in Tx"}, + {"5c", "Power Class 2(2.0W max), CLEI present, CDR present in Rx Tx"}, + + {"80", "Power Class 3(2.5W max)"}, + {"84", "Power Class 3(2.5W max), CDR present in Rx"}, + {"88", "Power Class 3(2.5W max), CDR present in Tx"}, + {"8c", "Power Class 3(2.5W max), CDR present in Rx Tx"}, + {"90", "Power Class 3(2.5W max), CLEI present"}, + {"94", "Power Class 3(2.5W max), CLEI present, CDR present in Rx"}, + {"98", "Power Class 3(2.5W max), CLEI present, CDR present in Tx"}, + {"9c", "Power Class 3(2.5W max), CLEI present, CDR present in Rx Tx"}, + + {"c0", "Power Class 4(3.5W max)"}, + {"c4", "Power Class 4(3.5W max), CDR present in Rx"}, + {"c8", "Power Class 4(3.5W max), CDR present in Tx"}, + {"cc", "Power Class 4(3.5W max), CDR present in Rx Tx"}, + {"d0", "Power Class 4(3.5W max), CLEI present"}, + {"d4", "Power Class 4(3.5W max), CLEI present, CDR present in Rx"}, + {"d8", "Power Class 4(3.5W max), CLEI present, CDR present in Tx"}, + {"dc", "Power Class 4(3.5W max), CLEI present, CDR present in Rx Tx"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8436_connector[] = { + {"00", "Unknown or unspecified"}, + {"01", "SC"}, + {"02", "FC Style 1 copper connector"}, + {"03", "FC Style 2 copper connector"}, + {"04", "BNC/TNC"}, + {"05", "FC coax headers"}, + {"06", "Fiberjack"}, + {"07", "LC"}, + {"08", "MT-RJ"}, + {"09", "MU"}, + {"0a", "SG"}, + {"0b", "Optical Pigtail"}, + {"0c", "MPOx12"}, + {"0d", "MPOx16"}, + {"20", "HSSDC II"}, + {"21", "Copper pigtail"}, + {"22", "RJ45"}, + {"23", "No separable connector"}, + {"NULL", ""} +}; + +struct rj_e2_enum_type_s sff8436_encoding_codes[] = { + {"00","Unspecified"}, + {"01", "8B10B"}, + {"02", "4B5B"}, + {"03", "NRZ"}, + {"04", "SONET Scrambled"}, + {"05", "64B66B"}, + {"06", "Manchester"}, + {"07", "256B257B"}, + {"NULL", ""} + }; + +struct rj_e2_enum_type_s sff8436_rate_identifier[] = { + {"00","QSFP+ Rate Select Version 1"}, + {"NULL", ""} + }; + +/* qsfp sepecification compliance*/ +/* byte131 10/40G Ethernet Compliance Code */ +struct rj_e2_enum_type_s qsfp_comp_10_ethcc_bitmap[8] = { + {"0", "40G Active Cable (XLPPI)"}, + {"1", "40GBASE-LR4"}, + {"2", "40GBASE-SR4"}, + {"3", "40GBASE-CR4"}, + {"4", "10GBase-SR"}, + {"5", "10GBase-LR"}, + {"6", "10GBase-LRM"}, + {"NULL", ""}, +}; + +/* byte132 SONET Compliance codes */ +struct rj_e2_enum_type_s qsfp_comp_socc_bitmap[8] = { + {"0", "OC 48 short reach"}, + {"1", "OC 48, intermediate reach"}, + {"2", "OC 48, long reach"}, + {"3", "40G OTN (OTU3B/OTU3C)"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte133 SAS/SATA compliance codes */ +struct rj_e2_enum_type_s qsfp_comp_sscc_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"4", "SAS 3.0G"}, + {"5", "SAS 6.0G"}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte134 Gigabit Ethernet Compliant codes */ +struct rj_e2_enum_type_s qsfp_comp_gethcc_bitmap[8] = { + {"0", "1000BASE-SX"}, + {"1", "1000BASE-LX"}, + {"2", "1000BASE-CX"}, + {"3", "1000BASE-T"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte135 Fibre Channel link length */ +struct rj_e2_enum_type_s qsfp_comp_fcll_bitmap[8] = { + {"0", "Electrical inter-enclosure (EL)"}, + {"1", "Longwave laser (LC)"}, + {"NULL", ""}, + {"3", "Medium (M)"}, + {"4", "Long distance (L)"}, + {"5", "Intermediate distance (I)"}, + {"6", "Short distance (S)"}, + {"7", "Very long distance (V)"}, +}; + +/* byte136 Transmitter Technology */ +struct rj_e2_enum_type_s qsfp_comp_tt_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"4", "Longwave Laser (LL)"}, + {"5", "Shortwave laser w OFC (SL)"}, + {"6", "Shortwave laser w/o OFC (SN)"}, + {"7", "Electrical intra-enclosure"}, +}; + +/* byte137 Fibre Channel transmission media */ +struct rj_e2_enum_type_s qsfp_comp_fctm_bitmap[8] = { + {"0", "Single Mode (SM)"}, + {"1", "Multi-mode 50um (OM3)"}, + {"2", "Multi-mode 50m (M5)"}, + {"3", "Multi-mode 62.5m (M6)"}, + {"4", "Video Coax (TV)"}, + {"5", "Miniature Coax (MI)"}, + {"6", "Shielded Twisted Pair (TP)"}, + {"7", "Twin Axial Pair (TW)"}, +}; + +/* byte138 Fibre Channel Speed */ +struct rj_e2_enum_type_s qsfp_comp_fcs_bitmap[8] = { + {"0", "100 Mbytes/Sec"}, + {"NULL", ""}, + {"2", "200 Mbytes/Sec"}, + {"NULL", ""}, + {"4", "400 Mbytes/Sec"}, + {"5", "1600 Mbytes/Sec"}, + {"6", "800 Mbytes/Sec"}, + {"7", "1200 Mbytes/Sec"}, +}; + +/* sfp sepecification compliance*/ +/* byte3 10G Ethernet Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_10_ethcc_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"4", "10G Base-SR"}, + {"5", "10G Base-LR"}, + {"6", "10G Base-LRM"}, + {"7", "10G Base-ER"}, +}; + +/* byte3 Infiniband Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_infcc_bitmap[8] = { + {"0", "1X Copper Passive"}, + {"1", "1X Copper Active"}, + {"2", "1X LX"}, + {"3", "1X SX"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte4 ESCON Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_escc_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"6", "ESCON SMF, 1310nm Laser"}, + {"7", "ESCON MMF, 1310nm LED"}, +}; + +/* byte4 SONET Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_socc1_bitmap[8] = { + {"0", "OC-48, short reach"}, + {"1", "OC-48, intermediate reach"}, + {"2", "OC-48, long reach"}, + {"3", "SONET reach specifier bit 2"}, + {"4", "SONET reach specifier bit 1"}, + {"5", "OC-192, short reach"}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte5 SONET Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_socc2_bitmap[8] = { + {"0", "OC-3, short reach"}, + {"1", "OC-3, single mode, inter reach"}, + {"2", "OC-3, single mode, long reach"}, + {"NULL", ""}, + {"4", "OC-12, short reach"}, + {"5", "OC-12, single mode, inter reach"}, + {"6", "OC-12, single mode, long reach"}, + {"NULL", ""}, +}; + +/* byte6 Ethernet Compliance Codes */ +struct rj_e2_enum_type_s sfp_comp_ethcc_bitmap[8] = { + {"0", "1000BASE-SX"}, + {"1", "1000BASE-LX"}, + {"2", "1000BASE-CX"}, + {"3", "1000BASE-T"}, + {"4", "100BASE-LX/LX10"}, + {"5", "100BASE-FX"}, + {"6", "BASE-BX10"}, + {"7", "BASE-PX"}, +}; + +/* byte7 Fibre Channel Link Length */ +struct rj_e2_enum_type_s sfp_comp_fcll_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"3", "medium distance (M)"}, + {"4", "Long distance (L)"}, + {"5", "Intermediate distance (I)"}, + {"6", "short distance (S)"}, + {"7", "very long distance (V)"}, +}; + +/* byte7 Fibre Channel Technology */ +struct rj_e2_enum_type_s sfp_comp_fct1_bitmap[8] = { + {"0", "Electrical inter-enclosure (EL)"}, + {"1", "Longwave Laser (LC)"}, + {"2", "Shortwave laser, linear Rx (SA)"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte8 Fibre Channel Technology */ +struct rj_e2_enum_type_s sfp_comp_fct2_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"4", "Longwave laser (LL)"}, + {"5", "Shortwave laser with OFC (SL)"}, + {"6", "Shortwave laser w/o OFC (SN)"}, + {"7", "Electrical intra-enclosure (EL)"}, +}; + +/* byte8 SFP+ Cable Technology */ +struct rj_e2_enum_type_s sfp_comp_sfpct_bitmap[8] = { + {"NULL", ""}, + {"NULL", ""}, + {"2", "Passive Cable"}, + {"3", "Active Cable"}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, + {"NULL", ""}, +}; + +/* byte9 Fibre Channel Transmission Media */ +struct rj_e2_enum_type_s sfp_comp_fctm_bitmap[8] = { + {"0", "Single Mode (SM)"}, + {"NULL", ""}, + {"2", "Multimode, 50um (M5, M5E)"}, + {"3", "Multimode, 62.5um (M6)"}, + {"4", "Video Coax (TV)"}, + {"5", "Miniature Coax (MI)"}, + {"6", "Twisted Pair (TP)"}, + {"7", "Twin Axial Pair (TW)"}, +}; + +/* byte10 Fibre Channel Speed */ +struct rj_e2_enum_type_s sfp_comp_fcs_bitmap[8] = { + {"0", "100 MBytes/sec"}, + {"NULL", ""}, + {"2", "200 MBytes/sec"}, + {"NULL", ""}, + {"4", "400 MBytes/sec"}, + {"5", "1600 MBytes/sec"}, + {"6", "800 MBytes/sec"}, + {"7", "1200 MBytes/sec"}, +}; + +typedef enum { + DOM_NONE, + DOM_SFF8436, + DOM_SFF8472, +} rj_dom_type_t; + +typedef enum { + EXTCALB_RX_PWR_4, + EXTCALB_RX_PWR_3, + EXTCALB_RX_PWR_2, + EXTCALB_RX_PWR_1, + EXTCALB_RX_PWR_0, + EXTCALB_TX_I_Slope, + EXTCALB_TX_I_Offset, + EXTCALB_TX_PWR_Slope, + EXTCALB_TX_PWR_Offset, + EXTCALB_T_Slope, + EXTCALB_T_Offset, + EXTCALB_V_Slope, + EXTCALB_V_Offset, +} rj_dom_ext_calibration_t; + +struct rj_eeprom_parse_t_subaddr { + int offset; + int sub_offset; + int size; +}; + +struct rj_eeprom_parse_t_ext { + int subaddr_num; + char prefix[10]; + struct rj_eeprom_parse_t_subaddr subaddr[4]; +}; + +struct rj_eeprom_parse_t { + char attr_name[32]; + int addr; + int offset; + int sub_offset; + int size; + rj_eeprom_type_t type; + struct rj_e2_enum_type_s *enum_str; + rj_dom_type_t dom_type; + void (*calc_func) ( int sfp_bus, + struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); + struct rj_eeprom_parse_t_ext ext; +}; + +static void calc_temperature(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void calc_voltage(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_calc_rx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_calc_tx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_calc_tx_bias(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_calc_tx_bias(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_calc_rx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_calc_tx_power(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_cable_length_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_cable_length_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void qsfp_spec_comp_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); +static void sfp_spec_comp_display(int sfp_bus, struct rj_eeprom_parse_t *eep_parse, + unsigned char *data, char *out_buf, int buf_len); + +/* QSFP DOM EEPROM is also at addr 0x50 */ +struct rj_eeprom_parse_t ssf8436_interface_id[] = { + {"type", 0x50, 128, 0, 1, E2_ENUM, sff8436_type_of_transceiver, DOM_NONE, NULL}, + {"hw_version", 0x50, 184, 0, 2, E2_STR, NULL, DOM_NONE, NULL}, + {"serial_num", 0x50, 196, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"manufacture_name", 0x50, 148, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"model_name", 0x50, 168, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"connector", 0x50, 130, 0, 1, E2_ENUM, sff8436_connector, DOM_NONE, NULL}, + {"encoding", 0x50, 139, 0, 1, E2_ENUM, sff8436_encoding_codes, DOM_NONE, NULL}, + {"ext_identifier", 0x50, 129, 0, 1, E2_ENUM, sff8436_ext_type_of_transceiver, DOM_NONE, NULL}, + {"ext_rateselect_compliance", 0x50, 141, 0, 1, E2_ENUM, sff8436_rate_identifier, DOM_NONE, NULL}, + {"cable_length", 0x50, 142, 0, 5, E2_FUNC, NULL, DOM_NONE, qsfp_cable_length_display}, /* 142 - 146*/ + {"nominal_bit_rate", 0x50, 140, 0, 1, E2_INT, NULL, DOM_NONE, NULL}, + {"sepecification_compliance", 0x50, 131, 0, 8, E2_FUNC, NULL, DOM_NONE, qsfp_spec_comp_display}, /* 131 - 138 */ + {"vendor_date", 0x50, 212, 0, 8, E2_DATE, NULL, DOM_NONE, NULL}, + {"vendor_oui", 0x50, 165, 0, 3, E2_HEX, NULL, DOM_NONE, NULL}, + + {"temperature", 0x50, 22, 0, 2, E2_FUNC, NULL, DOM_SFF8436, calc_temperature}, + {"voltage", 0x50, 26, 0, 2, E2_FUNC, NULL, DOM_SFF8436, calc_voltage}, + {"rxpower", 0x50, 34, 0, 8, E2_FUNC, NULL, DOM_SFF8436, qsfp_calc_rx_power}, + {"txbias", 0x50, 42, 0, 8, E2_FUNC, NULL, DOM_SFF8436, qsfp_calc_tx_bias}, + {"txpower", 0x50, 50, 0, 8, E2_FUNC, NULL, DOM_SFF8436, qsfp_calc_tx_power}, +}; + +struct rj_eeprom_parse_t ssf8472_interface_id[] = { + {"type", 0x50, 0, 0, 1, E2_ENUM, sff8472_type_of_transceiver, DOM_NONE, NULL}, + {"hw_version", 0x50, 56, 0, 4, E2_STR, NULL, DOM_NONE, NULL}, + {"serial_num", 0x50, 68, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"manufacture_name", 0x50, 20, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"model_name", 0x50, 40, 0, 16, E2_STR, NULL, DOM_NONE, NULL}, + {"connector", 0x50, 2, 0, 1, E2_ENUM, sff8472_connector, DOM_NONE, NULL}, + {"encoding", 0x50, 11, 0, 1, E2_ENUM, sff8472_encoding_codes, DOM_NONE, NULL}, + {"ext_identifier", 0x50, 1, 0, 1, E2_ENUM, sff8472_exttypeoftransceiver, DOM_NONE, NULL}, + {"ext_rateselect_compliance", 0x50, 13, 0, 1, E2_ENUM, sff8472_rate_identifier, DOM_NONE, NULL}, + {"cable_length", 0x50, 14, 0, 6, E2_FUNC, NULL, DOM_NONE, sfp_cable_length_display}, /* 14~19 */ + {"nominal_bit_rate", 0x50, 12, 0, 1, E2_INT, NULL, DOM_NONE, NULL}, + {"sepecification_compliance", 0x50, 3, 0, 8, E2_FUNC, NULL, DOM_NONE, sfp_spec_comp_display}, /* 3~10 */ + {"vendor_date", 0x50, 84, 0, 8, E2_DATE, NULL, DOM_NONE, NULL}, + {"vendor_oui", 0x50, 37, 0, 3, E2_HEX, NULL, DOM_NONE, NULL}, + + {"temperature", 0x50, 352, 0, 2, E2_FUNC, NULL, DOM_SFF8472, calc_temperature}, + {"voltage", 0x50, 354, 0, 2, E2_FUNC, NULL, DOM_SFF8472, calc_voltage}, + {"rxpower", 0x50, 360, 0, 2, E2_FUNC, NULL, DOM_SFF8472, sfp_calc_rx_power}, + {"txbias", 0x50, 356, 0, 2, E2_FUNC, NULL, DOM_SFF8472, sfp_calc_tx_bias}, + {"txpower", 0x50, 358, 0, 2, E2_FUNC, NULL, DOM_SFF8472, sfp_calc_tx_power}, +}; + +#endif /* _DFD_SFPPARSE_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_slot_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_slot_driver.h new file mode 100644 index 000000000000..0db7e9417182 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_slot_driver.h @@ -0,0 +1,10 @@ +#ifndef _DFD_SLOT_DRIVER_H_ +#define _DFD_SLOT_DRIVER_H_ + +int dfd_get_slot_status(unsigned int slot_index); + +ssize_t dfd_get_slot_info(unsigned int slot_index, uint8_t cmd, char *buf); + +ssize_t dfd_get_slot_status_str(unsigned int slot_index, char *buf); + +#endif /* _DFD_SLOT_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_syseeprom_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_syseeprom_driver.h new file mode 100644 index 000000000000..3996d17cd6eb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_syseeprom_driver.h @@ -0,0 +1,6 @@ +#ifndef _DFD_SYSEEPROM_DRIVER_H_ +#define _DFD_SYSEEPROM_DRIVER_H_ + +ssize_t dfd_get_syseeprom_info(uint8_t type, char *buf); + +#endif /* _DFD_SYSEEPROM_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_tlveeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_tlveeprom.h new file mode 100644 index 000000000000..742bb44604c7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_cfg/include/dfd_tlveeprom.h @@ -0,0 +1,70 @@ +#ifndef DFD_TLVEEPROM_H +#define DFD_TLVEEPROM_H + +#ifndef be16_to_cpu +#define be16_to_cpu(x) ntohs(x) +#endif + +#ifndef cpu_to_be16 +#define cpu_to_be16(x) htons(x) +#endif + +#define TLV_CODE_NAME_LEN 64 + +/* + * Struct for displaying the TLV codes and names. + */ +struct tlv_code_desc { + uint8_t m_code; + char m_name[TLV_CODE_NAME_LEN]; +}; + +typedef struct dfd_tlv_type_s { + uint8_t main_type; + uint8_t ext_type; +} dfd_tlv_type_t; + +/* Header Field Constants */ +#define TLV_INFO_ID_STRING "TlvInfo" +#define TLV_INFO_VERSION 0x01 + +struct __attribute__ ((__packed__)) tlvinfo_header_s { + char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ + uint8_t version; /* 0x08 Structure version */ + uint16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ +}; +typedef struct tlvinfo_header_s tlvinfo_header_t; + +/* + * TlvInfo TLV: Layout of a TLV field + */ +struct __attribute__ ((__packed__)) tlvinfo_tlv_s { + uint8_t type; + uint8_t length; + uint8_t value[0]; +}; +typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; + +#define TLV_VALUE_MAX_LEN 255 +/* + * 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) + +typedef struct tlv_decode_value_s { + uint8_t value[TLV_DECODE_VALUE_MAX_LEN]; + uint32_t length; +} tlv_decode_value_t; + +typedef enum dfd_tlvinfo_ext_tlv_type_e { + DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE = 1, +} dfd_tlvinfo_ext_tlv_type_t; + +int dfd_tlvinfo_get_e2prom_info(uint8_t *eeprom, uint32_t size, dfd_tlv_type_t *tlv_type, uint8_t* buf, uint32_t *buf_len); + +#endif /* endif DFD_TLVEEPROM_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/Makefile new file mode 100755 index 000000000000..95c041c09eda --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/Makefile @@ -0,0 +1,20 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +KBUILD_EXTRA_SYMBOLS += $(RG_PLAT_SYSFS_DIR)/rg_dev_cfg/Module.symvers + +obj-m := rg_plat_switch.o +obj-m += rg_plat_fan.o +obj-m += rg_plat_psu.o +obj-m += rg_plat_sff.o +obj-m += rg_plat_sensor.o + +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(module_out_put_dir) ]; then mkdir -p $(module_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(module_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_plat_switch.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_plat_switch.h new file mode 100644 index 000000000000..4001940c4321 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_plat_switch.h @@ -0,0 +1,86 @@ +#ifndef _RG_PLAT_SWITCH_H_ +#define _RG_PLAT_SWITCH_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +enum LOG_LEVEL{ + INFO = 0x1, + ERR = 0x2, + DBG = 0x4, + ALL = 0xf +}; + +#define LOG_INFO(_prefix, fmt, args...) \ + do { \ + if (g_loglevel & INFO) \ + { \ + printk( KERN_INFO _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ + } while (0) + +#define LOG_ERR(_prefix, fmt, args...) \ + do { \ + if (g_loglevel & ERR) \ + { \ + printk( KERN_ERR _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ + } while (0) + +#define LOG_DBG(_prefix, fmt, args...) \ + do { \ + if (g_loglevel & DBG) \ + { \ + printk( KERN_DEBUG _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ + } while (0) + +#define check_pfun(p) \ + do { \ + if (p == NULL) { \ + printk( KERN_ERR "%s, %s = NULL.\n", __FUNCTION__, #p); \ + return -ENOSYS; \ + } \ + }while(0) + +#define check_p(p) check_pfun(p) + +#define to_switch_obj(x) container_of(x, struct switch_obj, kobj) +#define to_switch_attr(x) container_of(x, struct switch_attribute, attr) +#define to_switch_device_attr(x) container_of(x, struct switch_device_attribute, switch_attr) + +#define SWITCH_ATTR(_name, _mode, _show, _store, _type) \ + { .switch_attr = __ATTR(_name, _mode, _show, _store), \ + .type = _type } + +#define SWITCH_DEVICE_ATTR(_name, _mode, _show, _store, _type) \ +struct switch_device_attribute switch_dev_attr_##_name \ + = SWITCH_ATTR(_name, _mode, _show, _store, _type) + +struct switch_obj { + struct kobject kobj; + unsigned int index; +}; + +/* a custom attribute that works just for a struct switch_obj. */ +struct switch_attribute { + struct attribute attr; + ssize_t (*show)(struct switch_obj *foo, struct switch_attribute *attr, char *buf); + ssize_t (*store)(struct switch_obj *foo, struct switch_attribute *attr, const char *buf, size_t count); +}; + +struct switch_device_attribute { + struct switch_attribute switch_attr; + int type; +}; + +extern struct switch_obj *rg_plat_kobject_create(const char *name, struct kobject *parent); +extern void rg_plat_kobject_delete(struct switch_obj **obj); + +#endif /* _RG_PLAT_SWITCH_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_sysfs_common.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_sysfs_common.h new file mode 100644 index 000000000000..cc457c8702f7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/include/rg_sysfs_common.h @@ -0,0 +1,194 @@ +#ifndef _RG_SYSFS_COMMON_H_ +#define _RG_SYSFS_COMMON_H_ + +#define RG_GET_SFF_SLOT(port) (((port) >> 24) & 0xff) +#define RG_GET_SFF_INDEX(port) (((port) >> 16) & 0xff) +#define RG_GET_SFF_I2C_ADAPTER(port) (((port) >> 8) & 0xff) +#define RG_GET_SFF_SPEED_MODE(port) ((port) & 0xff) + +#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 DIR_NAME_MAX_LEN (64) + +#define RG_SYSFS_DEV_ERROR "no_support" +/* sysfs directory name */ +#define RG_FAN_SYSFS_NAME "fan" +#define RG_PSU_SYSFS_NAME "psu" +#define RG_SLOT_SYSFS_NAME "slot" +#define RG_CPLD_SYSFS_NAME "cpld" +#define RG_VOLTAGE_SYSFS_NAME "in" +#define RG_TEMP_SYSFS_NAME "temp" +#define RG_SFF_SYSFS_NAME "sff" +#define RG_SFF_25GE_SYSFS_NAME "Eth25GE" +#define RG_SFF_100GE_SYSFS_NAME "Eth100GE" + +typedef enum dfd_dev_info_type_e { + DFD_DEV_INFO_TYPE_MAC = 1, + DFD_DEV_INFO_TYPE_NAME = 2, + DFD_DEV_INFO_TYPE_SN = 3, + DFD_DEV_INFO_TYPE_PWR_CONS = 4, + DFD_DEV_INFO_TYPE_HW_INFO = 5, + DFD_DEV_INFO_TYPE_DEV_TYPE = 6, + DFD_DEV_INFO_TYPE_PART_NAME = 7, + DFD_DEV_INFO_TYPE_PART_NUMBER = 8, /* part number */ +} dfd_dev_tlv_type_t; + +typedef enum rg_led_e { + RG_SYS_LED_FRONT = 0, + RG_SYS_LED_REAR = 1, + RG_BMC_LED_FRONT = 2, + RG_BMC_LED_REAR = 3, + RG_FAN_LED_FRONT = 4, + RG_FAN_LED_REAR = 5, + RG_PSU_LED_FRONT = 6, + RG_PSU_LED_REAR = 7, + RG_ID_LED_FRONT = 8, + RG_ID_LED_REAR = 9, + RG_FAN_LED_MODULE = 10, + RG_PSU_LED_MODULE = 11, + RG_SLOT_LED_MODULE = 12, +} rg_led_t; + +typedef enum rg_main_dev_type_e { + RG_MAIN_DEV_MAINBOARD = 0, + RG_MAIN_DEV_FAN = 1, + RG_MAIN_DEV_PSU = 2, + RG_MAIN_DEV_SFF = 3, + RG_MAIN_DEV_CPLD = 4, /* CPLD */ + RG_MAIN_DEV_SLOT = 5, +} rg_main_dev_type_t; + +typedef enum rg_minor_dev_type_e { + RG_MINOR_DEV_NONE = 0, /* None */ + RG_MINOR_DEV_TEMP = 1, + RG_MINOR_DEV_IN = 2, + RG_MINOR_DEV_CURR = 3, + RG_MINOR_DEV_POWER = 4, + RG_MINOR_DEV_MOTOR = 5, + RG_MINOR_DEV_PSU = 6, +} rg_minor_dev_type_t; + +typedef enum rg_sensor_type_e { + RG_SENSOR_INPUT = 0, + RG_SENSOR_ALIAS = 1, + RG_SENSOR_TYPE = 2, + RG_SENSOR_MAX = 3, + RG_SENSOR_MAX_HYST = 4, + RG_SENSOR_MIN = 5, + RG_SENSOR_CRIT = 6, +} rg_sensor_type_t; + +typedef enum rg_sff_speed_type_e { + RG_SFF_SPEED_NONE = 0, /* None */ + RG_SFF_SPEED_25GE = 1, + RG_SFF_SPEED_100GE = 2, + RG_SFF_SPEED_50GE = 3, +} rg_sff_speed_type_t; + +typedef enum rg_sff_cpld_attr_e { + RG_SFF_POWER_ON = 0x01, + RG_SFF_TX_FAULT, + RG_SFF_TX_DIS, + RG_SFF_PRE_N, + RG_SFF_RX_LOS, + RG_SFF_RESET, + RG_SFF_LPMODE, + RG_SFF_MODULE_PRESENT, + RG_SFF_INTERRUPT, +} rg_sff_cpld_attr_t; + +typedef enum rg_sff_eeprom_attr_e { + RG_SFF_TYPE = 0x01, + RG_SFF_HW_VERSION, + RG_SFF_SERIAL_NUM, + RG_SFF_MANUFACTURE_NAME, + RG_SFF_MODEL_NAME, + RG_SFF_CONNECTOR, + RG_SFF_ENCODING, + RG_SFF_EXT_IDENTIFIER, + RG_SFF_EXT_RATESELECT_COMPLIANCE, + RG_SFF_CABLE_LENGTH, + RG_SFF_NOMINAL_BIT_RATE, + RG_SFF_SEPECIFICATION_COMPLIANCE, + RG_SFF_VENDOR_DATE, + RG_SFF_VENDOR_OUI, + RG_SFF_TEMPERATURE, + RG_SFF_VOLTAGE, + RG_SFF_RXPOWER, + RG_SFF_TXBIAS, + RG_SFF_TXPOWER, +} rg_sff_eeprom_attr_t; + +struct switch_drivers_t{ + /* device */ + int (*get_dev_number) (unsigned int main_dev_id, unsigned int minor_dev_id); + /* fan */ + int (*get_fan_number) (void); + int (*get_fan_status) (unsigned int fan_index); + ssize_t (*get_fan_info) (unsigned int fan_index, uint8_t cmd, char* buf); + ssize_t (*get_fan_speed) (unsigned int fan_index, unsigned int motor_index, unsigned int *speed); + int (*get_fan_pwm) (unsigned int fan_index, unsigned int motor_index, int *pwm); + int (*set_fan_pwm) (unsigned int fan_index, unsigned int motor_index, int pwm); + int (*get_fan_speed_tolerance) (unsigned int fan_index, unsigned int motor_index, int *value); + int (*get_fan_speed_target) (unsigned int fan_index, unsigned int motor_index, int *value); + int (*get_fan_direction) (unsigned int fan_index, unsigned int motor_index, int *value); + ssize_t (*get_fan_status_str) (unsigned int fan_index, char* buf); + ssize_t (*get_fan_direction_str) (unsigned int fan_index, unsigned int motor_index, char* buf); + int (*get_fan_present_status)(unsigned int fan_index); + int (*get_fan_roll_status)(unsigned int fan_index, unsigned int motor_index); + int (*get_fan_speed_level)(unsigned int fan_index, unsigned int motor_index, int *level); + int (*set_fan_speed_level)(unsigned int fan_index, unsigned int motor_index, int level); + /* syseeprom */ + ssize_t (*get_syseeprom_info) (uint8_t cmd, char* buf); + /* cpld */ + ssize_t (*get_cpld_name) (unsigned int cpld_index, char* buf); + ssize_t (*get_cpld_type) (unsigned int cpld_index, char* buf); + ssize_t (*get_cpld_version) (unsigned int cpld_index, char* buf); + int (*get_cpld_testreg) (unsigned int cpld_index, int *value); + int (*set_cpld_testreg) (unsigned int cpld_index, int value); + /* led */ + ssize_t (*get_led_status) (uint16_t led_id, uint8_t led_index, char *buf); + /* slot */ + ssize_t (*get_slot_status_str) (unsigned int slot_index, char* buf); + ssize_t (*get_slot_info) (unsigned int slot_index, uint8_t cmd, char *buf); + /* sensors */ + ssize_t (*get_temp_info)( uint8_t main_dev_id, uint8_t dev_index, + uint8_t temp_index, uint8_t temp_attr, char *buf); + ssize_t (*get_voltage_info)( uint8_t main_dev_id, uint8_t dev_index, + uint8_t in_index, uint8_t in_attr, char *buf); + /* psu */ + ssize_t (*get_psu_info)( unsigned int psu_index, uint8_t cmd, char *buf); + ssize_t (*get_psu_status_str) (unsigned int psu_index, char *buf); + ssize_t (*get_psu_sensor_info)( uint8_t psu_index, uint8_t sensor_type, char *buf); + int (*get_psu_present_status)(unsigned int psu_index); + int (*get_psu_output_status)(unsigned int psu_index); + int (*get_psu_alert_status)(unsigned int psu_index); + /* sff */ + int (*get_sff_id) (unsigned int sff_index); + int (*set_sff_cpld_info)(unsigned int sff_index, int cpld_reg_type, int value); + ssize_t (*get_sff_cpld_info)( unsigned int sff_index, int cpld_reg_type, char *buf, int len); + ssize_t (*get_sff_eeprom_info)(unsigned int sff_index, const char *attr_name, char *buf, int buf_len); + ssize_t (*get_sff_dir_name)(unsigned int sff_index, char *buf, int buf_len); + int (*get_sff_polling_size) (void); + ssize_t (*get_sff_polling_data)(unsigned int sff_index, char *buf, loff_t offset, size_t count); +}; + +extern struct switch_drivers_t * dfd_plat_driver_get(void); + +#endif /*_RG_SYSFS_COMMON_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_fan.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_fan.c new file mode 100644 index 000000000000..2e48149e4708 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_fan.c @@ -0,0 +1,544 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_fan.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create fan kobjects and attributes in /sys/rg_plat/fan + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "./include/rg_plat_switch.h" +#include "./include/rg_sysfs_common.h" + +#define FAN_INFO(fmt, args...) LOG_INFO("fan: ", fmt, ##args) +#define FAN_ERR(fmt, args...) LOG_ERR("fan: ", fmt, ##args) +#define FAN_DBG(fmt, args...) LOG_DBG("fan: ", fmt, ##args) + +struct motor_obj_t{ + struct switch_obj *obj; +}; + +struct fan_obj_t{ + unsigned int motor_number; + struct motor_obj_t *motor; + struct switch_obj *obj; +}; + +struct fan_t{ + unsigned int fan_number; + struct fan_obj_t *fan; +}; + +static int g_loglevel = 0; +static struct fan_t g_fan; +static struct switch_obj *g_fan_obj = NULL; +static struct switch_drivers_t *g_drv = NULL; + +static ssize_t fan_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_fan.fan_number); +} + +static ssize_t fan_motor_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int index; + + index = obj->index; + FAN_DBG("fan_motor_number_show,fan index:%d\n",index); + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_fan.fan[index-1].motor_number); +} + +static ssize_t fan_roll_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index; + struct switch_obj *p_obj; + int ret; + + check_p(g_drv); + check_p(g_drv->get_fan_roll_status); + + p_obj = to_switch_obj(obj->kobj.parent); + check_p(p_obj); + + fan_index = p_obj->index; + motor_index = obj->index; + + ret = g_drv->get_fan_roll_status(fan_index, motor_index); + if (ret < 0 ) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static ssize_t fan_present_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + fan_index = obj->index; + FAN_DBG("fan_present_status_show, fan index:%d\n",fan_index); + check_p(g_drv); + check_p(g_drv->get_fan_present_status); + + ret = g_drv->get_fan_present_status(fan_index); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static ssize_t fan_speed_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index, speed; + int ret; + struct switch_obj *p_obj; + + check_p(g_drv); + check_p(g_drv->get_fan_speed); + + p_obj = to_switch_obj(obj->kobj.parent); + check_p(p_obj); + + fan_index = p_obj->index; + motor_index = obj->index; + + ret = g_drv->get_fan_speed(fan_index, motor_index, &speed); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", speed); +} + +static ssize_t fan_motor_ratio_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index; + struct switch_obj *p_obj; + int ret, pwm; + + check_p(g_drv); + check_p(g_drv->get_fan_pwm); + + p_obj = to_switch_obj(obj->kobj.parent); + check_p(p_obj); + fan_index = p_obj->index; + motor_index = obj->index; + ret = g_drv->get_fan_pwm(fan_index, motor_index, &pwm); + + if (ret < 0 ) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", pwm); +} + +static ssize_t fan_motor_ratio_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int fan_index, motor_index; + struct switch_obj *p_obj; + int ret, pwm; + + check_p(g_drv); + check_p(g_drv->set_fan_pwm); + + p_obj = to_switch_obj(obj->kobj.parent); + check_p(p_obj); + + fan_index = p_obj->index; + motor_index = obj->index; + sscanf(buf, "%d", &pwm); + + if (pwm < 0 || pwm > 100) { + FAN_ERR("can not set pwm = %d.\n", pwm); + return -EINVAL; + } + ret = g_drv->set_fan_pwm(fan_index, motor_index, pwm); + if (ret < 0) { + FAN_ERR("can not set pwm = %d.\n", pwm); + return -EIO; + } + return count; +} + +/************************************fan dir and attrs*******************************************/ +static struct switch_attribute fan_number_att = __ATTR(num_fans, S_IRUGO, fan_number_show, NULL); + +static struct attribute *fan_dir_attrs[] = { + &fan_number_att.attr, + NULL, +}; + +static struct attribute_group fan_root_attr_group = { + .attrs = fan_dir_attrs, +}; + +/*******************************fan1 fan2 dir and attrs*******************************************/ +static struct switch_attribute fan_num_motors_att = __ATTR(num_motors, S_IRUGO, fan_motor_number_show, NULL); +static struct switch_attribute fan_present_att = __ATTR(present, S_IRUGO, fan_present_status_show, NULL); + +static struct attribute *fan_attrs[] = { + &fan_num_motors_att.attr, + &fan_present_att.attr, + NULL, +}; + +static struct attribute_group fan_attr_group = { + .attrs = fan_attrs, +}; + +/*******************************motor0 motor1 dir and attrs*******************************************/ +static struct switch_attribute motor_speed_att = __ATTR(speed, S_IRUGO, fan_speed_show, NULL); +static struct switch_attribute motor_status_att = __ATTR(status, S_IRUGO, fan_roll_status_show, NULL); +static struct switch_attribute motor_ratio_att = __ATTR(ratio, S_IRUGO | S_IWUSR, fan_motor_ratio_show, fan_motor_ratio_store); + +static struct attribute *motor_attrs[] = { + &motor_speed_att.attr, + &motor_status_att.attr, + &motor_ratio_att.attr, + NULL, +}; + +static struct attribute_group motor_attr_group = { + .attrs = motor_attrs, +}; + +static void fanindex_single_motor_remove_kobj_and_attrs(struct fan_obj_t * curr_fan, unsigned int motor_index) +{ + + struct motor_obj_t * curr_motor; /* point to motor0 motor1...*/ + + if (curr_fan == NULL) { + FAN_ERR("fan remove attrs failed, curr_fan is NULL.\n"); + return ; + } + + if (motor_index + 1 > curr_fan->motor_number) { + FAN_ERR("params error. motor index:%d.\n", motor_index); + return ; + } + curr_motor = &curr_fan->motor[motor_index]; + + if (curr_motor->obj) { + sysfs_remove_group(&curr_motor->obj->kobj, &motor_attr_group); + rg_plat_kobject_delete(&curr_motor->obj); + } + + FAN_DBG("delete fan:%d motor%d.\n", curr_fan->obj->index, motor_index); + return ; +} + +static int fanindex_single_motor_create_kobj_and_attrs(struct fan_obj_t * curr_fan, unsigned int motor_index) +{ + char name[8]; + struct motor_obj_t * curr_motor; /* point to motor0 motor1...*/ + + check_p(curr_fan); + + if (motor_index + 1 > curr_fan->motor_number) { + FAN_ERR("motor number = %d, motor%d error.\n", curr_fan->motor_number, motor_index); + return -EINVAL; + } + FAN_DBG("create fan_index:%d, motor%d ...\n", curr_fan->obj->index, motor_index); + + curr_motor = &curr_fan->motor[motor_index]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "motor%d", motor_index); + curr_motor->obj = rg_plat_kobject_create(name, &curr_fan->obj->kobj); + if (!curr_motor->obj) { + FAN_ERR("create fan_index:%d, motor%d object error!\n", curr_fan->obj->index, motor_index); + return -EBADRQC; + } + curr_motor->obj->index = motor_index; + if (sysfs_create_group(&curr_motor->obj->kobj, &motor_attr_group) != 0) { + FAN_ERR("create fan_index:%d, motor%d attrs error.\n", curr_fan->obj->index, motor_index); + rg_plat_kobject_delete(&curr_motor->obj); + return -EBADRQC; + } + FAN_DBG("create fan_index:%d, motor%d ok.\n", curr_fan->obj->index, motor_index); + return 0; +} + +static int fanindex_motor_create_kobj_and_attrs(struct fan_obj_t * curr_fan, int motor_num) +{ + int motor_index, i; + + check_p(curr_fan); + + curr_fan->motor = kzalloc(sizeof(struct motor_obj_t) * motor_num, GFP_KERNEL); + if (!curr_fan->motor) { + FAN_ERR("kzalloc motor error, fan index = %d, motor number = %d.\n", curr_fan->obj->index, motor_num); + return -ENOMEM; + } + curr_fan->motor_number = motor_num; + for(motor_index = 0; motor_index < motor_num; motor_index++) { + if(fanindex_single_motor_create_kobj_and_attrs(curr_fan, motor_index) != 0 ) { + goto motor_error; + } + } + return 0; +motor_error: + for(i = 0; i < motor_index; i++) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, i); + } + if(curr_fan->motor) { + kfree(curr_fan->motor); + curr_fan->motor = NULL; + } + return -EBADRQC; +} + +static void fanindex_motor_remove_kobj_and_attrs(struct fan_obj_t * curr_fan, int motor_num) +{ + unsigned int motor_index; + + if (motor_num < 0 || curr_fan == NULL) { + FAN_ERR("params error.motor number = %d \n", motor_num); + return ; + } + + for(motor_index = 0; motor_index < motor_num; motor_index++) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, motor_index); + } + return ; +} + +static int fan_motor_create(void) +{ + int fan_num, motor_num; + unsigned int fan_index, i; + struct fan_obj_t * curr_fan; /* point to fan1 fan2...*/ + + check_p(g_drv->get_dev_number); + + motor_num = g_drv->get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_MOTOR); + if (motor_num <= 0) { + FAN_ERR("get fan motor number error, motor_num:%d error.\n", motor_num); + return -ENODEV; + } + + fan_num = g_fan.fan_number; + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + curr_fan = &g_fan.fan[fan_index - 1]; + if(fanindex_motor_create_kobj_and_attrs(curr_fan, motor_num) != 0) { + goto error; + } + } + return 0; +error: + for(i = 1; i < fan_index; i++) { + curr_fan = &g_fan.fan[i - 1]; + motor_num = curr_fan->motor_number; + fanindex_motor_remove_kobj_and_attrs(curr_fan, motor_num); + } + return -EBADRQC; +} + +static void fan_motor_remove(void) +{ + unsigned int fan_index; + struct fan_obj_t * curr_fan; + if (g_fan.fan) { + for(fan_index = 1; fan_index <= g_fan.fan_number; fan_index++) { + curr_fan = &g_fan.fan[fan_index - 1]; + if (curr_fan->motor) { + fanindex_motor_remove_kobj_and_attrs(curr_fan,curr_fan->motor_number); + kfree(curr_fan->motor); + curr_fan->motor = NULL; + curr_fan->motor_number = 0; + } + } + } + return ; +} + +static int fan_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct fan_obj_t * curr_fan; + + if (index > g_fan.fan_number) { + FAN_ERR("fan number = %d, fan%d error.\n", g_fan.fan_number, index); + return -EINVAL; + } + curr_fan = &g_fan.fan[index-1]; + if (curr_fan->obj) { + sysfs_remove_group(&curr_fan->obj->kobj, &fan_attr_group); + rg_plat_kobject_delete(&curr_fan->obj); + } + + FAN_DBG("delete fan%d.\n", index); + return 0; +} + +static int fan_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct fan_obj_t * curr_fan; + + if (index > g_fan.fan_number) { + FAN_ERR("fan number = %d, fan%d error.\n", g_fan.fan_number, index); + return -EINVAL; + } + curr_fan = &g_fan.fan[index-1]; + FAN_DBG("create fan%d ...\n", index); + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fan%d", index); + curr_fan->obj = rg_plat_kobject_create(name, parent); + if (!curr_fan->obj) { + FAN_ERR("create fan%d object error!\n", index); + return -EBADRQC; + } + curr_fan->obj->index = index; + if (sysfs_create_group(&curr_fan->obj->kobj, &fan_attr_group) != 0) { + FAN_ERR("create fan%d attrs error.\n", index); + rg_plat_kobject_delete(&curr_fan->obj); + return -EBADRQC; + } + FAN_DBG("create fan%d ok.\n", index); + return 0; +} + +static int fan_sub_create_kobj_and_attrs(struct kobject *parent, int fan_num) +{ + unsigned int fan_index, i; + + if(fan_num < 0) { + FAN_ERR("fan number = %d error.\n", fan_num); + return -EINVAL; + } + g_fan.fan = kzalloc(sizeof(struct fan_obj_t) * fan_num, GFP_KERNEL); + if (!g_fan.fan) { + FAN_ERR("kzalloc fan.fan error, fan number = %d.\n", fan_num); + return -ENOMEM; + } + + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + if(fan_sub_single_create_kobj_and_attrs(parent, fan_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = 1; i < fan_index; i++) { + fan_sub_single_remove_kobj_and_attrs(i); + } + if(g_fan.fan) { + kfree(g_fan.fan); + g_fan.fan = NULL; + } + return -EBADRQC; +} + +static int fan_sub_create(void) +{ + int ret, fan_num; + + check_p(g_drv->get_dev_number); + fan_num = g_drv->get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_NONE); + if (fan_num < 0) { + FAN_ERR("fan number = %d error.\n", fan_num); + return -EINVAL; + } + g_fan.fan_number = fan_num; + ret = fan_sub_create_kobj_and_attrs(&g_fan_obj->kobj, fan_num); + return ret; +} + +static void fan_sub_remove(void) +{ + unsigned int fan_index; + + if (g_fan.fan) { + for (fan_index = 1; fan_index <= g_fan.fan_number; fan_index++) { + if (g_fan.fan[fan_index-1].obj) { + fan_sub_single_remove_kobj_and_attrs(fan_index); + } + } + kfree(g_fan.fan); + } + memset(&g_fan, 0, sizeof(struct fan_t)); + return ; +} + +static int fan_root_create(void) +{ + g_fan_obj = rg_plat_kobject_create("fan", NULL); + if (!g_fan_obj) + return -ENOMEM; + + if (sysfs_create_group(&g_fan_obj->kobj, &fan_root_attr_group) != 0) { + rg_plat_kobject_delete(&g_fan_obj); + FAN_ERR("create fan dir attrs error!\n"); + return -EBADRQC; + } + return 0; + +} + +static void fan_root_remove(void) +{ + if (g_fan_obj) { + sysfs_remove_group(&g_fan_obj->kobj, &fan_root_attr_group); + rg_plat_kobject_delete(&g_fan_obj); + } + + return ; +} + +static int fan_init(void) +{ + int ret; + + FAN_INFO("fan_init...\n"); + g_drv = dfd_plat_driver_get(); + check_p(g_drv); + + ret = fan_root_create(); + if (ret < 0) { + goto fan_root_error; + } + + ret = fan_sub_create(); + if (ret < 0) { + goto fan_sub_error; + } + + ret = fan_motor_create(); + if (ret < 0) { + goto fan_motor_error; + } + + FAN_INFO("fan_init ok.\n"); + return 0; +fan_motor_error: + fan_sub_remove(); +fan_sub_error: + fan_root_remove(); +fan_root_error: + return ret; +} + +static void fan_exit(void) +{ + fan_motor_remove(); + fan_sub_remove(); + fan_root_remove(); + FAN_INFO("fan_exit ok.\n"); + return ; +} + +module_init(fan_init); +module_exit(fan_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE fan sysfs driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_psu.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_psu.c new file mode 100644 index 000000000000..e5a04be1aeed --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_psu.c @@ -0,0 +1,458 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_psu.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create psu kobjects and attributes in /sys/rg_plat/psu + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "./include/rg_plat_switch.h" +#include "./include/rg_sysfs_common.h" + +#define PSU_INFO(fmt, args...) LOG_INFO("psu: ", fmt, ##args) +#define PSU_ERR(fmt, args...) LOG_ERR("psu: ", fmt, ##args) +#define PSU_DBG(fmt, args...) LOG_DBG("psu: ", fmt, ##args) + +struct temp_obj_t{ + struct switch_obj *obj; +}; + +struct psu_obj_t{ + unsigned int temp_number; + struct temp_obj_t *temp; + struct switch_obj *obj; +}; + +struct psu_t{ + unsigned int psu_number; + struct psu_obj_t *psu; +}; + +static int g_loglevel = 0; +static struct psu_t g_psu; +static struct switch_obj *g_psu_obj = NULL; +static struct switch_drivers_t *g_drv = NULL; + +static ssize_t psu_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_psu.psu_number); +} + +static ssize_t psu_present_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + psu_index = obj->index; + PSU_DBG("psu_present_status_show, psu index:%d\n",psu_index); + check_p(g_drv); + check_p(g_drv->get_psu_present_status); + + ret = g_drv->get_psu_present_status(psu_index); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static ssize_t psu_output_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + psu_index = obj->index; + PSU_DBG("psu_output_status_show, psu index:%d\n",psu_index); + check_p(g_drv); + check_p(g_drv->get_psu_output_status); + + ret = g_drv->get_psu_output_status(psu_index); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +static ssize_t psu_alert_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + psu_index = obj->index; + PSU_DBG("psu_alert_status_show, psu index:%d\n",psu_index); + check_p(g_drv); + check_p(g_drv->get_psu_alert_status); + + ret = g_drv->get_psu_alert_status(psu_index); + if(ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", ret); +} + +/************************************psu dir and attrs*******************************************/ +static struct switch_attribute psu_number_att = __ATTR(num_psus, S_IRUGO, psu_number_show, NULL); + +static struct attribute *psu_dir_attrs[] = { + &psu_number_att.attr, + NULL, +}; + +static struct attribute_group psu_root_attr_group = { + .attrs = psu_dir_attrs, +}; + +/*******************************psu1 psu2 dir and attrs*******************************************/ +static struct switch_attribute psu_present_status_att = __ATTR(present, S_IRUGO, psu_present_status_show, NULL); +static struct switch_attribute psu_output_status_att = __ATTR(output, S_IRUGO, psu_output_status_show, NULL); +static struct switch_attribute psu_alert_status_att = __ATTR(alert, S_IRUGO, psu_alert_status_show, NULL); + +static struct attribute *psu_attrs[] = { + &psu_present_status_att.attr, + &psu_output_status_att.attr, + &psu_alert_status_att.attr, + NULL, +}; + +static struct attribute_group psu_attr_group = { + .attrs = psu_attrs, +}; + +/*******************************psu temp0 temp1 dir and attrs*******************************************/ +static struct attribute *psu_temp_attrs[] = { + NULL, +}; + +static struct attribute_group psu_temp_attr_group = { + .attrs = psu_temp_attrs, +}; + +static void psuindex_single_temp_remove_kobj_and_attrs(struct psu_obj_t * curr_psu, unsigned int temp_index) +{ + + struct temp_obj_t * curr_temp; /* point to temp0 temp1...*/ + + if (curr_psu == NULL) { + PSU_ERR("psu remove attrs failed, curr_psu is NULL.\n"); + return ; + } + + if (temp_index + 1 > curr_psu->temp_number) { + PSU_ERR("params error. temp index:%d.\n", temp_index); + return ; + } + curr_temp = &curr_psu->temp[temp_index]; + + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &psu_temp_attr_group); + rg_plat_kobject_delete(&curr_temp->obj); + } + + PSU_DBG("delete psu:%d temp%d.\n", curr_psu->obj->index, temp_index); + return ; +} + +static int psuindex_single_temp_create_kobj_and_attrs(struct psu_obj_t * curr_psu, unsigned int temp_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct temp_obj_t * curr_temp; /* point to temp0 temp1...*/ + + check_p(curr_psu); + + PSU_DBG("create psu_index:%d, temp%d ...\n", curr_psu->obj->index, temp_index); + + curr_temp = &curr_psu->temp[temp_index]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%d", temp_index); + curr_temp->obj = rg_plat_kobject_create(name, &curr_psu->obj->kobj); + if (!curr_temp->obj) { + PSU_ERR("create psu_index:%d, temp%d object error!\n", curr_psu->obj->index, temp_index); + return -EBADRQC; + } + curr_temp->obj->index = temp_index; + if (sysfs_create_group(&curr_temp->obj->kobj, &psu_temp_attr_group) != 0) { + PSU_ERR("create psu_index:%d, temp%d attrs error.\n", curr_psu->obj->index, temp_index); + rg_plat_kobject_delete(&curr_temp->obj); + return -EBADRQC; + } + PSU_DBG("create psu_index:%d, temp%d ok.\n", curr_psu->obj->index, temp_index); + return 0; +} + +static int psuindex_temp_create_kobj_and_attrs(struct psu_obj_t * curr_psu, int temp_num) +{ + int temp_index, i; + + check_p(curr_psu); + + curr_psu->temp = kzalloc(sizeof(struct temp_obj_t) * temp_num, GFP_KERNEL); + if (!curr_psu->temp) { + PSU_ERR("kzalloc temp error, psu index = %d, temp number = %d.\n", curr_psu->obj->index, temp_num); + return -ENOMEM; + } + curr_psu->temp_number = temp_num; + for(temp_index = 0; temp_index < temp_num; temp_index++) { + if(psuindex_single_temp_create_kobj_and_attrs(curr_psu, temp_index) != 0 ) { + goto temp_error; + } + } + return 0; +temp_error: + for(i = 0; i < temp_index; i++) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, i); + } + if(curr_psu->temp) { + kfree(curr_psu->temp); + curr_psu->temp = NULL; + } + return -EBADRQC; +} + +static void psuindex_temp_remove_kobj_and_attrs(struct psu_obj_t * curr_psu, int temp_num) +{ + unsigned int temp_index; + + if (temp_num < 0 || curr_psu == NULL) { + PSU_ERR("params error.temp number = %d \n", temp_num); + return ; + } + + for(temp_index = 0; temp_index < temp_num; temp_index++) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, temp_index); + } + return ; +} + +static int psu_temp_create(void) +{ + int psu_num, temp_num; + unsigned int psu_index, i; + struct psu_obj_t * curr_psu; /* point to psu1 psu2...*/ + + check_p(g_drv->get_dev_number); + + temp_num = g_drv->get_dev_number(RG_MAIN_DEV_PSU, RG_MINOR_DEV_TEMP); + if (temp_num <= 0) { + PSU_INFO("psu temp_num:%d, don't need creat temp directory.\n", temp_num); + return 0; + } + + psu_num = g_psu.psu_number; + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + curr_psu = &g_psu.psu[psu_index - 1]; + if(psuindex_temp_create_kobj_and_attrs(curr_psu, temp_num) != 0) { + goto error; + } + } + return 0; +error: + for(i = 1; i < psu_index; i++) { + curr_psu = &g_psu.psu[i - 1]; + temp_num = curr_psu->temp_number; + psuindex_temp_remove_kobj_and_attrs(curr_psu, temp_num); + } + return -EBADRQC; +} + +static void psu_temp_remove(void) +{ + unsigned int psu_index; + struct psu_obj_t * curr_psu; + if (g_psu.psu) { + for(psu_index = 1; psu_index <= g_psu.psu_number; psu_index++) { + curr_psu = &g_psu.psu[psu_index - 1]; + if (curr_psu->temp) { + psuindex_temp_remove_kobj_and_attrs(curr_psu,curr_psu->temp_number); + kfree(curr_psu->temp); + curr_psu->temp = NULL; + curr_psu->temp_number = 0; + } + } + } + return ; +} + +static int psu_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct psu_obj_t * curr_psu; + + if (index > g_psu.psu_number) { + PSU_ERR("psu number = %d, psu%d error.\n", g_psu.psu_number, index); + return -EINVAL; + } + curr_psu = &g_psu.psu[index-1]; + if (curr_psu->obj) { + sysfs_remove_group(&curr_psu->obj->kobj, &psu_attr_group); + rg_plat_kobject_delete(&curr_psu->obj); + } + + PSU_DBG("delete psu%d.\n", index); + return 0; +} + +static int psu_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct psu_obj_t * curr_psu; + + curr_psu = &g_psu.psu[index-1]; + PSU_DBG("create psu%d ...\n", index); + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "%s%d",RG_PSU_SYSFS_NAME, index); + curr_psu->obj = rg_plat_kobject_create(name, parent); + if (!curr_psu->obj) { + PSU_ERR("create psu%d object error!\n", index); + return -EBADRQC; + } + curr_psu->obj->index = index; + if (sysfs_create_group(&curr_psu->obj->kobj, &psu_attr_group) != 0) { + PSU_ERR("create psu%d attrs error.\n", index); + rg_plat_kobject_delete(&curr_psu->obj); + return -EBADRQC; + } + PSU_DBG("create psu%d ok.\n", index); + return 0; +} + +static int psu_sub_create_kobj_and_attrs(struct kobject *parent, int psu_num) +{ + unsigned int psu_index, i; + + g_psu.psu = kzalloc(sizeof(struct psu_obj_t) * psu_num, GFP_KERNEL); + if (!g_psu.psu) { + PSU_ERR("kzalloc psu.psu error, psu number = %d.\n", psu_num); + return -ENOMEM; + } + + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + if(psu_sub_single_create_kobj_and_attrs(parent, psu_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = 1; i < psu_index; i++) { + psu_sub_single_remove_kobj_and_attrs(i); + } + if(g_psu.psu) { + kfree(g_psu.psu); + g_psu.psu = NULL; + } + return -EBADRQC; +} + +static int psu_sub_create(void) +{ + int ret, psu_num; + + check_p(g_drv->get_dev_number); + psu_num = g_drv->get_dev_number(RG_MAIN_DEV_PSU, RG_MINOR_DEV_NONE); + if (psu_num < 0) { + PSU_ERR("psu number = %d error.\n", psu_num); + return -EINVAL; + } + g_psu.psu_number = psu_num; + ret = psu_sub_create_kobj_and_attrs(&g_psu_obj->kobj, psu_num); + return ret; +} + +static void psu_sub_remove(void) +{ + unsigned int psu_index; + + if (g_psu.psu) { + for (psu_index = 1; psu_index <= g_psu.psu_number; psu_index++) { + if (g_psu.psu[psu_index-1].obj) { + psu_sub_single_remove_kobj_and_attrs(psu_index); + } + } + kfree(g_psu.psu); + } + memset(&g_psu, 0, sizeof(struct psu_t)); + return ; +} + +static int psu_root_create(void) +{ + g_psu_obj = rg_plat_kobject_create(RG_PSU_SYSFS_NAME, NULL); + if (!g_psu_obj) + return -ENOMEM; + + if (sysfs_create_group(&g_psu_obj->kobj, &psu_root_attr_group) != 0) { + rg_plat_kobject_delete(&g_psu_obj); + PSU_ERR("create psu dir attrs error!\n"); + return -EBADRQC; + } + return 0; + +} + +static void psu_root_remove(void) +{ + if (g_psu_obj) { + sysfs_remove_group(&g_psu_obj->kobj, &psu_root_attr_group); + rg_plat_kobject_delete(&g_psu_obj); + } + + return ; +} + +static int rg_psu_init(void) +{ + int ret; + + PSU_INFO("rg_psu_init...\n"); + g_drv = dfd_plat_driver_get(); + check_p(g_drv); + + ret = psu_root_create(); + if (ret < 0) { + goto psu_root_error; + } + + ret = psu_sub_create(); + if (ret < 0) { + goto psu_sub_error; + } + + ret = psu_temp_create(); + if (ret < 0) { + goto psu_temp_error; + } + + PSU_INFO("rg_psu_init ok.\n"); + return 0; +psu_temp_error: + psu_sub_remove(); +psu_sub_error: + psu_root_remove(); +psu_root_error: + return ret; +} + +static void rg_psu_exit(void) +{ + psu_temp_remove(); + psu_sub_remove(); + psu_root_remove(); + PSU_INFO("rg_psu_exit ok.\n"); + return ; +} + +module_init(rg_psu_init); +module_exit(rg_psu_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE psu sysfs driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sensor.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sensor.c new file mode 100644 index 000000000000..8514d871ac91 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sensor.c @@ -0,0 +1,494 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_sensor.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create sensor kobjects and attributes in /sys/rg_plat/sensor + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "./include/rg_plat_switch.h" +#include "./include/rg_sysfs_common.h" + +#define SENSOR_INFO(fmt, args...) LOG_INFO("sensor: ", fmt, ##args) +#define SENSOR_ERR(fmt, args...) LOG_ERR("sensor: ", fmt, ##args) +#define SENSOR_DBG(fmt, args...) LOG_DBG("sensor: ", fmt, ##args) + +struct sensor_t { + unsigned int in_number; + unsigned int temp_number; + struct sensor_in_t *in; + struct sensor_temp_t *temp; +}; + +struct sensor_temp_t { + struct switch_obj *obj; +}; + +struct sensor_in_t { + struct switch_obj *obj; +}; + +static int g_loglevel = 0; +static struct switch_drivers_t *g_drv = NULL; +static struct sensor_t g_sensor; +static struct switch_obj *g_sensor_obj = NULL; + +static ssize_t sensor_temp_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_sensor.temp_number); +} + +static ssize_t sensor_in_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_sensor.in_number); +} + +static ssize_t sensor_voltage_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int in_index; + int ret; + struct switch_device_attribute *in_attr; + + check_p(g_drv); + check_p(g_drv->get_voltage_info); + in_index = obj->index; + + in_attr = to_switch_device_attr(attr); + check_p(in_attr); + SENSOR_DBG("sensor_in_show, in index:0x%x, in type:0x%x\n",in_index, in_attr->type); + ret = g_drv->get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, in_index, in_attr->type, buf); + if (ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t sensor_temp_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + struct switch_device_attribute *temp_attr; + + check_p(g_drv); + check_p(g_drv->get_temp_info); + temp_index = obj->index; + + temp_attr = to_switch_device_attr(attr); + check_p(temp_attr); + SENSOR_DBG("sensor_temp_show, temp index:0x%x, temp type:0x%x\n", temp_index, temp_attr->type); + ret = g_drv->get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, temp_attr->type, buf); + if (ret < 0) { + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + return ret; +} + +/************************************sensor dir and attrs*******************************************/ +static struct switch_attribute num_temp_att = __ATTR(num_temp_sensors, S_IRUGO, sensor_temp_number_show, NULL); +static struct switch_attribute num_in_att = __ATTR(num_in_sensors, S_IRUGO, sensor_in_number_show, NULL); + +static struct attribute *sensor_dir_attrs[] = { + &num_temp_att.attr, + &num_in_att.attr, + NULL, +}; + +static struct attribute_group sensor_root_attr_group = { + .attrs = sensor_dir_attrs, +}; + +/*******************************temp0 temp1 dir and attrs*******************************************/ +static SWITCH_DEVICE_ATTR(temp_input, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_INPUT); +static SWITCH_DEVICE_ATTR(temp_alias, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_ALIAS); +static SWITCH_DEVICE_ATTR(temp_type, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_TYPE); +static SWITCH_DEVICE_ATTR(temp_max, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_MAX); +static SWITCH_DEVICE_ATTR(temp_max_hyst, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_MAX_HYST); +static SWITCH_DEVICE_ATTR(temp_min, S_IRUGO, sensor_temp_show, NULL, RG_SENSOR_MIN); + +static struct attribute *sensor_temp_attrs[] = { + &switch_dev_attr_temp_input.switch_attr.attr, + &switch_dev_attr_temp_alias.switch_attr.attr, + &switch_dev_attr_temp_type.switch_attr.attr, + &switch_dev_attr_temp_max.switch_attr.attr, + &switch_dev_attr_temp_max_hyst.switch_attr.attr, + &switch_dev_attr_temp_min.switch_attr.attr, + NULL, +}; + +static struct attribute_group sensor_temp_attr_group = { + .attrs = sensor_temp_attrs, +}; + +/*******************************in0 in1 dir and attrs*******************************************/ +static SWITCH_DEVICE_ATTR(in_input, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_INPUT); +static SWITCH_DEVICE_ATTR(in_alias, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_ALIAS); +static SWITCH_DEVICE_ATTR(in_type, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_TYPE); +static SWITCH_DEVICE_ATTR(in_max, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_MAX); +static SWITCH_DEVICE_ATTR(in_min, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_MIN); +static SWITCH_DEVICE_ATTR(in_crit, S_IRUGO, sensor_voltage_show, NULL, RG_SENSOR_CRIT); + +static struct attribute *sensor_in_attrs[] = { + &switch_dev_attr_in_input.switch_attr.attr, + &switch_dev_attr_in_alias.switch_attr.attr, + &switch_dev_attr_in_type.switch_attr.attr, + &switch_dev_attr_in_max.switch_attr.attr, + &switch_dev_attr_in_min.switch_attr.attr, + &switch_dev_attr_in_crit.switch_attr.attr, + NULL, +}; + +static struct attribute_group sensor_in_attr_group = { + .attrs = sensor_in_attrs, +}; + +static int sensor_root_create(void) +{ + g_sensor_obj = rg_plat_kobject_create("sensor", NULL); + if (!g_sensor_obj) { + return -ENOMEM; + } + if (sysfs_create_group(&g_sensor_obj->kobj, &sensor_root_attr_group) != 0) { + rg_plat_kobject_delete(&g_sensor_obj); + SENSOR_ERR("create sensor dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +static int sensor_in_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct sensor_in_t *curr_sensor; + + if (index >= g_sensor.in_number) { + SENSOR_ERR("sensor in number = %d, in%d error.\n", g_sensor.in_number, index); + return -EINVAL; + } + curr_sensor = &g_sensor.in[index]; + SENSOR_DBG("create sensor in%d ...\n", index); + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "in%d", index); + curr_sensor->obj = rg_plat_kobject_create(name, parent); + if (!curr_sensor->obj) { + SENSOR_ERR("create sensor in%d object error!\n", index); + return -EBADRQC; + } + curr_sensor->obj->index = index; + if (sysfs_create_group(&curr_sensor->obj->kobj, &sensor_in_attr_group) != 0) { + SENSOR_ERR("create sensor in%d attrs error.\n", index); + rg_plat_kobject_delete(&curr_sensor->obj); + return -EBADRQC; + } + SENSOR_DBG("create sensor in%d ok.\n", index); + return 0; + +} + +static int sensor_in_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sensor_in_t *curr_in; + + if (index >= g_sensor.in_number) { + SENSOR_ERR("in number = %d, in%d error.\n", g_sensor.in_number, index); + return -EINVAL; + } + curr_in = &g_sensor.in[index]; + if (curr_in->obj) { + sysfs_remove_group(&curr_in->obj->kobj, &sensor_in_attr_group); + rg_plat_kobject_delete(&curr_in->obj); + } + + SENSOR_DBG("delete in%d.\n", index); + return 0; +} + +static int sensor_temp_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct sensor_temp_t *curr_sensor; + + if (index >= g_sensor.temp_number) { + SENSOR_ERR("sensor temp number = %d, temp%d error.\n", g_sensor.temp_number, index); + return -EINVAL; + } + curr_sensor = &g_sensor.temp[index]; + SENSOR_DBG("create sensor temp%d ...\n", index); + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%d", index); + curr_sensor->obj = rg_plat_kobject_create(name, parent); + if (!curr_sensor->obj) { + SENSOR_ERR("create sensor temp%d object error!\n", index); + return -EBADRQC; + } + curr_sensor->obj->index = index; + if (sysfs_create_group(&curr_sensor->obj->kobj, &sensor_temp_attr_group) != 0) { + SENSOR_ERR("create sensor temp%d attrs error.\n", index); + rg_plat_kobject_delete(&curr_sensor->obj); + return -EBADRQC; + } + SENSOR_DBG("create sensor temp%d ok.\n", index); + return 0; + +} + +static int sensor_temp_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sensor_temp_t *curr_temp; + + if (index >= g_sensor.temp_number) { + SENSOR_ERR("temp number = %d, temp%d error.\n", g_sensor.temp_number, index); + return -EINVAL; + } + curr_temp = &g_sensor.temp[index]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &sensor_temp_attr_group); + rg_plat_kobject_delete(&curr_temp->obj); + } + + SENSOR_DBG("delete temp%d.\n", index); + return 0; +} + +static int sensor_temp_sub_create_kobj_and_attrs(struct kobject *parent, int temp_num) +{ + unsigned int temp_index, i; + if (temp_num <= 0) { + SENSOR_ERR("sensor number = %d error.\n", temp_num); + return -EINVAL; + } + g_sensor.temp = kzalloc(sizeof(struct sensor_temp_t) * temp_num, GFP_KERNEL); + if (!g_sensor.temp ) { + SENSOR_ERR("kzalloc g_sensor.temp error, temp number = %d.\n", temp_num); + return -ENOMEM; + } + for (temp_index = 0; temp_index < temp_num; temp_index++) { + if (sensor_temp_sub_single_create_kobj_and_attrs(parent, temp_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = 0; i < temp_index; i++) { + sensor_temp_sub_single_remove_kobj_and_attrs(i); + } + + if (g_sensor.temp) { + kfree(g_sensor.temp); + g_sensor.temp = NULL; + } + return -EBADRQC; +} + +static int sensor_in_sub_create_kobj_and_attrs(struct kobject *parent, int in_num) +{ + unsigned int in_index, i; + if (in_num <= 0) { + SENSOR_ERR("sensor number = %d error.\n", in_num); + return -EINVAL; + } + g_sensor.in = kzalloc(sizeof(struct sensor_in_t) * in_num, GFP_KERNEL); + if (!g_sensor.in ) { + SENSOR_ERR("kzalloc g_sensor.in error, in number = %d.\n", in_num); + return -ENOMEM; + } + + for (in_index = 0; in_index < in_num; in_index++) { + if (sensor_in_sub_single_create_kobj_and_attrs(parent, in_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = 0; i < in_index; i++) { + sensor_in_sub_single_remove_kobj_and_attrs(i); + } + + if (g_sensor.in) { + kfree(g_sensor.in); + g_sensor.in = NULL; + } + return -EBADRQC; +} + +static int sensor_temp_sub_create(void) +{ + int ret, temp_num; + + check_p(g_drv->get_dev_number); + temp_num = g_drv->get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_TEMP); + g_sensor.temp_number = temp_num; + + if (temp_num <= 0) { + SENSOR_DBG("Warning:sensor temp number = %d \n", temp_num); + return 0; + } + ret = sensor_temp_sub_create_kobj_and_attrs(&g_sensor_obj->kobj, temp_num); + return ret; +} + +static int sensor_in_sub_create(void) +{ + int ret, in_num; + + check_p(g_drv->get_dev_number); + in_num = g_drv->get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_IN); + g_sensor.in_number = in_num; + + if (in_num <= 0) { + SENSOR_DBG("Warning:sensor in number = %d \n", in_num); + return 0; + } + ret = sensor_in_sub_create_kobj_and_attrs(&g_sensor_obj->kobj, in_num); + return ret; +} + +static int temp_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sensor_temp_t * curr_temp; + + if (index >= g_sensor.temp_number) { + SENSOR_ERR("temp number = %d, temp%d error.\n", g_sensor.temp_number, index); + return -EINVAL; + } + curr_temp = &g_sensor.temp[index]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &sensor_temp_attr_group); + rg_plat_kobject_delete(&curr_temp->obj); + } + + SENSOR_DBG("delete sensor temp%d.\n", index); + return 0; +} + +static int in_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sensor_in_t * curr_in; + + if (index >= g_sensor.in_number) { + SENSOR_ERR("in number = %d, in%d error.\n", g_sensor.in_number, index); + return -EINVAL; + } + curr_in = &g_sensor.in[index]; + if (curr_in->obj) { + sysfs_remove_group(&curr_in->obj->kobj, &sensor_in_attr_group); + rg_plat_kobject_delete(&curr_in->obj); + } + + SENSOR_DBG("delete sensor in%d.\n", index); + return 0; +} + +static void sensor_temp_sub_remove(void) +{ + unsigned int temp_index; + if (g_sensor.temp) { + for (temp_index = 0; temp_index < g_sensor.temp_number; temp_index++) { + if (g_sensor.temp[temp_index].obj) { + temp_sub_single_remove_kobj_and_attrs(temp_index); + } + } + kfree(g_sensor.temp); + } + g_sensor.temp = NULL; + return ; +} + +static void sensor_in_sub_remove(void) +{ + unsigned int in_index; + if (g_sensor.in) { + for (in_index = 0; in_index < g_sensor.in_number; in_index++) { + if (g_sensor.in[in_index].obj) { + in_sub_single_remove_kobj_and_attrs(in_index); + } + } + kfree(g_sensor.in); + } + g_sensor.in = NULL; + return ; +} + +static void sensor_sub_remove(void) +{ + sensor_temp_sub_remove(); + sensor_in_sub_remove(); +} + +static void sensor_root_remove(void) +{ + if (g_sensor_obj) { + sysfs_remove_group(&g_sensor_obj->kobj, &sensor_root_attr_group); + rg_plat_kobject_delete(&g_sensor_obj); + } + + return ; +} + +static int sensor_sub_create(void) +{ + int ret; + /* temp creat */ + ret = sensor_temp_sub_create(); + if (ret < 0) { + goto temp_err; + } + /* Voltage creat */ + ret = sensor_in_sub_create(); + if (ret < 0) { + goto in_err; + } + return 0; +in_err: + sensor_temp_sub_remove(); +temp_err: + return ret; +} + +static int rg_sensor_init(void) +{ + int ret; + + SENSOR_INFO("rg_sensor_init...\n"); + g_drv = dfd_plat_driver_get(); + check_p(g_drv); + + ret = sensor_root_create(); + if (ret < 0) { + goto sensor_root_error; + } + + ret = sensor_sub_create(); + if (ret < 0) { + goto sensor_sub_error; + } + SENSOR_INFO("sensor_init ok.\n"); + return 0; +sensor_sub_error: + sensor_root_remove(); +sensor_root_error: + return ret; +} + +static void rg_sensor_exit(void) +{ + sensor_sub_remove(); + sensor_root_remove(); + SENSOR_INFO("sensor_exit ok.\n"); + return ; +} + +module_init(rg_sensor_init); +module_exit(rg_sensor_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE sensors sysfs driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sff.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sff.c new file mode 100644 index 000000000000..ca2d5ae3be1a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_sff.c @@ -0,0 +1,391 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_sff.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create sff kobjects and attributes in /sys/rg_plat/xcvr + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "./include/rg_plat_switch.h" +#include "./include/rg_sysfs_common.h" + +#define SFF_INFO(fmt, args...) LOG_INFO("sff: ", fmt, ##args) +#define SFF_ERR(fmt, args...) LOG_ERR("sff: ", fmt, ##args) +#define SFF_DBG(fmt, args...) LOG_DBG("sff: ", fmt, ##args) + +struct sff_obj_t{ + struct switch_obj *sff_obj; + struct bin_attribute bin; + int sff_creat_bin_flag; +}; + +struct sff_t{ + unsigned int sff_number; + struct sff_obj_t *sff; +}; + +static int g_loglevel = 0; +static struct sff_t g_sff; +static struct switch_obj *g_sff_obj = NULL; +static struct switch_drivers_t *g_drv = NULL; + +static ssize_t sff_cpld_info_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int sff_index; + int ret; + struct switch_device_attribute *sff_cpld_attr; + + check_p(g_drv); + check_p(g_drv->get_sff_cpld_info); + + sff_index = obj->index; + sff_cpld_attr = to_switch_device_attr(attr); + check_p(sff_cpld_attr); + SFF_DBG("sff_cpld_info_show, sff index:0x%x, sff cpld attr type:0x%x\n", sff_index, sff_cpld_attr->type); + ret = g_drv->get_sff_cpld_info(sff_index, sff_cpld_attr->type, buf, PAGE_SIZE); + if(ret < 0) { + SFF_ERR("sff_cpld_info_show error. sff index:0x%x, sff cpld attr type:0x%x, ret:%d\n", + sff_index, sff_cpld_attr->type,ret ); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", RG_SYSFS_DEV_ERROR); + } + SFF_DBG("sff_cpld_info_show ok. sff index:0x%x, sff cpld attr type:0x%x, ret:%d\n", sff_index, sff_cpld_attr->type, ret); + return ret; +} + +static ssize_t sff_polling_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + struct switch_obj *sff_obj; + ssize_t rd_len; + unsigned int sff_index; + + check_p(g_drv); + check_p(g_drv->get_sff_polling_data); + + sff_obj = to_switch_obj(kobj); + sff_index = sff_obj->index; + + memset(buf, 0, count); + + rd_len = g_drv->get_sff_polling_data(sff_index, buf, offset, count); + if (rd_len < 0) { + SFF_ERR("sff_polling_read error. sff index:%u, offset:0x%llx, read len:%lu, ret:%ld.\n", + sff_index, offset,count, rd_len); + return -EIO; + } + + SFF_DBG("sff_polling_read, sff index:%u, offset:0x%llx, read len:%lu, really read len:%ld.\n", + sff_index, offset, count, rd_len); + + return rd_len; +} + +#if 0 +static ssize_t sff_cpld_info_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int sff_index; + int ret, value; + struct switch_device_attribute *sff_cpld_attr; + + check_p(g_drv); + check_p(g_drv->set_sff_cpld_info); + + sscanf(buf, "%d", &value); + if (value < 0 || value > 1) { + SFF_DBG(" invalid value:%d, can't set.\n", value); + return -EINVAL; + } + + sff_index = obj->index; + sff_cpld_attr = to_switch_device_attr(attr); + check_p(sff_cpld_attr); + SFF_DBG("sff_cpld_info_show, sff index:%d, sff cpld attr type:0x%x, set value:%d.\n", sff_index, sff_cpld_attr->type, value); + + ret = g_drv->set_sff_cpld_info(sff_index, sff_cpld_attr->type, value); + if(ret < 0) { + SFF_DBG("can not set cpld register = %d. sff index:%d, sff cpld attr type:0x%x,\n", value, sff_index, sff_cpld_attr->type); + return -EIO; + } + + return count; +} +#endif + +static ssize_t sff_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_sff.sff_number); +} + +/************************************sff attrs*******************************************/ +static struct switch_attribute sff_number_att = __ATTR(num_sffs, S_IRUGO, sff_number_show, NULL); +static SWITCH_DEVICE_ATTR(present, S_IRUGO, sff_cpld_info_show, NULL, RG_SFF_MODULE_PRESENT); + +/*******************************xcvr dir and attrs*******************************************/ +static struct attribute *xcvr_dir_attrs[] = { + &sff_number_att.attr, + NULL, +}; + +static struct attribute_group sff_xcvr_attr_group = { + .attrs = xcvr_dir_attrs, +}; + +/*******************************sff dir and attrs*******************************************/ +static struct attribute *sff_attrs[] = { + &switch_dev_attr_present.switch_attr.attr, + NULL, +}; + +static struct attribute_group sff_attr_group = { + .attrs = sff_attrs, +}; + +static int sff_sub_single_create_attrs(unsigned int index) +{ + struct sff_obj_t * curr_sff; + + curr_sff = &g_sff.sff[index-1]; + if (sysfs_create_group(&curr_sff->sff_obj->kobj, &sff_attr_group) != 0) { + rg_plat_kobject_delete(&curr_sff->sff_obj); + return -EBADRQC; + } + + return 0; +} + +static int sff_sub_single_create_kobj(struct kobject *parent, unsigned int index) +{ + struct sff_obj_t * curr_sff; + char sff_dir_name[DIR_NAME_MAX_LEN]; + int ret; + + check_p(g_drv->get_sff_dir_name); + ret = g_drv->get_sff_dir_name(index, sff_dir_name, sizeof(sff_dir_name)); + if (ret < 0) { + SFF_ERR("sff index:%d, get sff dir name error. please check sff config.\n", index); + return -ENOSYS; + } + + curr_sff = &g_sff.sff[index-1]; + + curr_sff->sff_obj = rg_plat_kobject_create(sff_dir_name, parent); + if (!curr_sff->sff_obj) { + SFF_ERR("sff index:%d, create %s object error! \n", index, sff_dir_name); + return -EBADRQC; + } + + SFF_DBG("create sff kobj ok. sff index:%d, dir name:%s\n",index, sff_dir_name); + curr_sff->sff_obj->index = index; + + return 0; +} + +static void sff_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sff_obj_t * curr_sff; + + curr_sff = &g_sff.sff[index-1]; + /* remove sff dir and attr */ + if (curr_sff->sff_obj) { + SFF_DBG("delete sff%d attrs.\n", curr_sff->sff_obj->index); + curr_sff->sff_obj->index = 0; + if (curr_sff->sff_creat_bin_flag) { + sysfs_remove_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + } + sysfs_remove_group(&curr_sff->sff_obj->kobj, &sff_attr_group); + rg_plat_kobject_delete(&curr_sff->sff_obj); + } + + return; +} + +static int sff_sub_single_create_eeprom_attrs(unsigned int index) +{ + int ret, eeprom_size; + struct sff_obj_t * curr_sff; + + check_p(g_drv->get_sff_polling_size); + + eeprom_size = g_drv->get_sff_polling_size(); + if (eeprom_size < 0) { + SFF_INFO("sff index:%u, don't support sff polling, ret:%d.\n", index, eeprom_size); + return 0; + } + + curr_sff = &g_sff.sff[index-1]; + + sysfs_bin_attr_init(&curr_sff->bin); + curr_sff->bin.attr.name = "eeprom"; + curr_sff->bin.attr.mode = 0444; + curr_sff->bin.read = sff_polling_read; + curr_sff->bin.size = eeprom_size; + + ret = sysfs_create_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + if (ret) { + SFF_ERR("sff index:%d, create eeprom bin error, ret:%d. \n", index, ret); + sysfs_remove_group(&curr_sff->sff_obj->kobj, &sff_attr_group); + rg_plat_kobject_delete(&curr_sff->sff_obj); + return -EBADRQC; + } + + SFF_DBG("sff index:%u, create bin file success, eeprom size:%d.\n", index, eeprom_size); + curr_sff->sff_creat_bin_flag = 1; + + return 0; +} + +static int sff_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + int ret; + + ret = sff_sub_single_create_kobj(parent, index); + if (ret < 0) { + SFF_ERR("sff index:%d, create sff dir error.\n", index); + return ret; + } + + ret = sff_sub_single_create_attrs(index); + if (ret < 0) { + SFF_ERR("sff index:%d, create sff attr error.\n", index); + return ret; + } + + ret = sff_sub_single_create_eeprom_attrs(index); + + return ret; +} + +static int sff_sub_create_kobj_and_attrs(struct kobject *parent, int sff_num) +{ + unsigned int sff_index, i; + + g_sff.sff = kzalloc(sizeof(struct sff_obj_t) * sff_num, GFP_KERNEL); + if (!g_sff.sff) { + SFF_ERR("kzalloc g_sff.sff error, sff number = %d.\n", sff_num); + return -ENOMEM; + } + + for (sff_index = 1; sff_index <= sff_num; sff_index++) { + if (sff_sub_single_create_kobj_and_attrs(parent, sff_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = 1; i < sff_index; i++) { + sff_sub_single_remove_kobj_and_attrs(i); + } + if (g_sff.sff) { + kfree(g_sff.sff); + g_sff.sff = NULL; + } + return -EBADRQC; +} + +static int sff_sub_create(void) +{ + int ret, sff_num; + + check_p(g_drv->get_dev_number); + sff_num = g_drv->get_dev_number(RG_MAIN_DEV_SFF, RG_MINOR_DEV_NONE); + g_sff.sff_number = sff_num; + if (sff_num <= 0) { + SFF_ERR("ERROR. port number:%d\n", sff_num); + return -EINVAL; + } + + ret = sff_sub_create_kobj_and_attrs(&g_sff_obj->kobj, sff_num); + + return ret; +} + +static void sff_sub_remove(void) +{ + unsigned int sff_index; + + if (g_sff.sff) { + for (sff_index = 1; sff_index <= g_sff.sff_number; sff_index++) { + sff_sub_single_remove_kobj_and_attrs(sff_index); + } + kfree(g_sff.sff); + } + memset(&g_sff, 0, sizeof(struct sff_t)); + return ; +} + +static int sff_xcvr_create(void) +{ + g_sff_obj = rg_plat_kobject_create(RG_SFF_SYSFS_NAME, NULL); + if (!g_sff_obj) { + return -ENOMEM; + } + + g_sff_obj->index = 0; + if (sysfs_create_group(&g_sff_obj->kobj, &sff_xcvr_attr_group) != 0) { + rg_plat_kobject_delete(&g_sff_obj); + SFF_ERR("create sff dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +static void sff_xcvr_remove(void) +{ + if (g_sff_obj) { + sysfs_remove_group(&g_sff_obj->kobj, &sff_xcvr_attr_group); + rg_plat_kobject_delete(&g_sff_obj); + } + + return ; +} + +static int rg_sff_init(void) +{ + int ret; + + SFF_INFO("rg_sff_init...\n"); + g_drv = dfd_plat_driver_get(); + check_p(g_drv); + + ret = sff_xcvr_create(); + if (ret < 0) { + goto sff_root_error; + } + + ret = sff_sub_create(); + if (ret < 0) { + goto sff_sub_error; + } + SFF_INFO("rg_sff_init ok.\n"); + return 0; + +sff_sub_error: + sff_xcvr_remove(); +sff_root_error: + return ret; +} + +static void rg_sff_exit(void) +{ + sff_sub_remove(); + sff_xcvr_remove(); + SFF_INFO("rg_sff_exit ok.\n"); + return ; +} + +module_init(rg_sff_init); +module_exit(rg_sff_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE sff sysfs driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_switch.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_switch.c new file mode 100644 index 000000000000..9f4b6aef6876 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_plat_sysfs/rg_dev_sysfs/rg_plat_switch.c @@ -0,0 +1,141 @@ +/* + * Copyright(C) 2001-2012 Ruijie Network. All rights reserved. + */ +/* + * rg_plat_switch.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * This module create a kset in sysfs called /sys/rg_plat + * Then other switch kobjects are created and assigned to this kset, + * such as "board", "cpld", "fan", "psu", "sff", ... + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include "./include/rg_plat_switch.h" + +#define SWITCH_INFO(fmt, args...) LOG_INFO("switch: ", fmt, ##args) +#define SWITCH_ERR(fmt, args...) LOG_ERR("switch: ", fmt, ##args) +#define SWITCH_DBG(fmt, args...) LOG_DBG("switch: ", fmt, ##args) + +static int g_loglevel = 0; + +static ssize_t switch_attr_show(struct kobject *kobj, + struct attribute *attr, + char *buf) +{ + struct switch_attribute *attribute; + struct switch_obj *device; + + attribute = to_switch_attr(attr); + device = to_switch_obj(kobj); + + if (!attribute->show) + return -ENOSYS; + + return attribute->show(device, attribute, buf); +} + +static ssize_t switch_attr_store(struct kobject *kobj, + struct attribute *attr, + const char *buf, size_t len) +{ + struct switch_attribute *attribute; + struct switch_obj *obj; + + attribute = to_switch_attr(attr); + obj = to_switch_obj(kobj); + + if (!attribute->store) + return -ENOSYS; + + return attribute->store(obj, attribute, buf, len); +} + +static const struct sysfs_ops switch_sysfs_ops = { + .show = switch_attr_show, + .store = switch_attr_store, +}; + +static void switch_obj_release(struct kobject *kobj) +{ + struct switch_obj *obj; + + obj = to_switch_obj(kobj); + kfree(obj); +} + +static struct kobj_type switch_ktype = { + .sysfs_ops = &switch_sysfs_ops, + .release = switch_obj_release, + .default_attrs = NULL, +}; + +static struct kset *switch_kset; + +struct switch_obj *rg_plat_kobject_create(const char *name, struct kobject *parent) +{ + struct switch_obj *obj = NULL; + int ret = 0; + + obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) { + SWITCH_DBG("rg_plat_kobject_create %s kzalloc error", name); + return NULL; + } + + obj->kobj.kset = switch_kset; + + ret = kobject_init_and_add(&obj->kobj, &switch_ktype, parent, "%s", name); + if (ret) { + kobject_put(&obj->kobj); + SWITCH_DBG("kobject_init_and_add %s error", name); + return NULL; + } + + return obj; +} + +void rg_plat_kobject_delete(struct switch_obj **obj) +{ + if (*obj) { + SWITCH_DBG("%s delete %s.\n", (*obj)->kobj.parent->name, (*obj)->kobj.name); + kobject_put(&((*obj)->kobj)); + *obj = NULL; + } +} + +static int __init switch_init(void) +{ + SWITCH_INFO("...\n"); + + switch_kset = kset_create_and_add("rg_plat", NULL, NULL); + if (!switch_kset) { + SWITCH_ERR("create switch_kset error.\n"); + return -ENOMEM; + } + + SWITCH_INFO("ok.\n"); + return 0; +} + +static void __exit switch_exit(void) +{ + if (switch_kset) { + kset_unregister(switch_kset); + } + + SWITCH_INFO("ok.\n"); +} + +module_init(switch_init); +module_exit(switch_exit); +EXPORT_SYMBOL(rg_plat_kobject_create); +EXPORT_SYMBOL(rg_plat_kobject_delete); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("RUIJIE Switch driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus.h new file mode 100644 index 000000000000..a714bbb99056 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus.h @@ -0,0 +1,466 @@ +/* + * 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 RG_PMBUS_H +#define RG_PMBUS_H + +#include +#include + +/* + * Registers + */ +enum pmbus_regs { + PMBUS_PAGE = 0x00, + PMBUS_OPERATION = 0x01, + PMBUS_ON_OFF_CONFIG = 0x02, + PMBUS_CLEAR_FAULTS = 0x03, + PMBUS_PHASE = 0x04, + + PMBUS_CAPABILITY = 0x19, + PMBUS_QUERY = 0x1A, + + PMBUS_VOUT_MODE = 0x20, + PMBUS_VOUT_COMMAND = 0x21, + PMBUS_VOUT_TRIM = 0x22, + PMBUS_VOUT_CAL_OFFSET = 0x23, + PMBUS_VOUT_MAX = 0x24, + PMBUS_VOUT_MARGIN_HIGH = 0x25, + PMBUS_VOUT_MARGIN_LOW = 0x26, + PMBUS_VOUT_TRANSITION_RATE = 0x27, + PMBUS_VOUT_DROOP = 0x28, + PMBUS_VOUT_SCALE_LOOP = 0x29, + PMBUS_VOUT_SCALE_MONITOR = 0x2A, + + PMBUS_COEFFICIENTS = 0x30, + PMBUS_POUT_MAX = 0x31, + + PMBUS_FAN_CONFIG_12 = 0x3A, + PMBUS_FAN_COMMAND_1 = 0x3B, + PMBUS_FAN_COMMAND_2 = 0x3C, + PMBUS_FAN_CONFIG_34 = 0x3D, + PMBUS_FAN_COMMAND_3 = 0x3E, + PMBUS_FAN_COMMAND_4 = 0x3F, + + PMBUS_VOUT_OV_FAULT_LIMIT = 0x40, + PMBUS_VOUT_OV_FAULT_RESPONSE = 0x41, + PMBUS_VOUT_OV_WARN_LIMIT = 0x42, + PMBUS_VOUT_UV_WARN_LIMIT = 0x43, + PMBUS_VOUT_UV_FAULT_LIMIT = 0x44, + PMBUS_VOUT_UV_FAULT_RESPONSE = 0x45, + PMBUS_IOUT_OC_FAULT_LIMIT = 0x46, + PMBUS_IOUT_OC_FAULT_RESPONSE = 0x47, + PMBUS_IOUT_OC_LV_FAULT_LIMIT = 0x48, + PMBUS_IOUT_OC_LV_FAULT_RESPONSE = 0x49, + PMBUS_IOUT_OC_WARN_LIMIT = 0x4A, + PMBUS_IOUT_UC_FAULT_LIMIT = 0x4B, + PMBUS_IOUT_UC_FAULT_RESPONSE = 0x4C, + + PMBUS_OT_FAULT_LIMIT = 0x4F, + PMBUS_OT_FAULT_RESPONSE = 0x50, + PMBUS_OT_WARN_LIMIT = 0x51, + PMBUS_UT_WARN_LIMIT = 0x52, + PMBUS_UT_FAULT_LIMIT = 0x53, + PMBUS_UT_FAULT_RESPONSE = 0x54, + PMBUS_VIN_OV_FAULT_LIMIT = 0x55, + PMBUS_VIN_OV_FAULT_RESPONSE = 0x56, + PMBUS_VIN_OV_WARN_LIMIT = 0x57, + PMBUS_VIN_UV_WARN_LIMIT = 0x58, + PMBUS_VIN_UV_FAULT_LIMIT = 0x59, + + PMBUS_IIN_OC_FAULT_LIMIT = 0x5B, + PMBUS_IIN_OC_WARN_LIMIT = 0x5D, + + PMBUS_POUT_OP_FAULT_LIMIT = 0x68, + PMBUS_POUT_OP_WARN_LIMIT = 0x6A, + PMBUS_PIN_OP_WARN_LIMIT = 0x6B, + + PMBUS_STATUS_BYTE = 0x78, + PMBUS_STATUS_WORD = 0x79, + PMBUS_STATUS_VOUT = 0x7A, + PMBUS_STATUS_IOUT = 0x7B, + PMBUS_STATUS_INPUT = 0x7C, + PMBUS_STATUS_TEMPERATURE = 0x7D, + PMBUS_STATUS_CML = 0x7E, + PMBUS_STATUS_OTHER = 0x7F, + PMBUS_STATUS_MFR_SPECIFIC = 0x80, + PMBUS_STATUS_FAN_12 = 0x81, + PMBUS_STATUS_FAN_34 = 0x82, + + PMBUS_READ_VIN = 0x88, + PMBUS_READ_IIN = 0x89, + PMBUS_READ_VCAP = 0x8A, + PMBUS_READ_VOUT = 0x8B, + PMBUS_READ_IOUT = 0x8C, + PMBUS_READ_TEMPERATURE_1 = 0x8D, + PMBUS_READ_TEMPERATURE_2 = 0x8E, + PMBUS_READ_TEMPERATURE_3 = 0x8F, + PMBUS_READ_FAN_SPEED_1 = 0x90, + PMBUS_READ_FAN_SPEED_2 = 0x91, + PMBUS_READ_FAN_SPEED_3 = 0x92, + PMBUS_READ_FAN_SPEED_4 = 0x93, + PMBUS_READ_DUTY_CYCLE = 0x94, + PMBUS_READ_FREQUENCY = 0x95, + PMBUS_READ_POUT = 0x96, + PMBUS_READ_PIN = 0x97, + + PMBUS_REVISION = 0x98, + PMBUS_MFR_ID = 0x99, + PMBUS_MFR_MODEL = 0x9A, + PMBUS_MFR_REVISION = 0x9B, + PMBUS_MFR_LOCATION = 0x9C, + PMBUS_MFR_DATE = 0x9D, + 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. + */ + PMBUS_VIRT_BASE = 0x100, + PMBUS_VIRT_READ_TEMP_AVG, + PMBUS_VIRT_READ_TEMP_MIN, + PMBUS_VIRT_READ_TEMP_MAX, + PMBUS_VIRT_RESET_TEMP_HISTORY, + PMBUS_VIRT_READ_VIN_AVG, + PMBUS_VIRT_READ_VIN_MIN, + PMBUS_VIRT_READ_VIN_MAX, + PMBUS_VIRT_RESET_VIN_HISTORY, + PMBUS_VIRT_READ_IIN_AVG, + PMBUS_VIRT_READ_IIN_MIN, + PMBUS_VIRT_READ_IIN_MAX, + PMBUS_VIRT_RESET_IIN_HISTORY, + PMBUS_VIRT_READ_PIN_AVG, + PMBUS_VIRT_READ_PIN_MIN, + PMBUS_VIRT_READ_PIN_MAX, + PMBUS_VIRT_RESET_PIN_HISTORY, + PMBUS_VIRT_READ_POUT_AVG, + PMBUS_VIRT_READ_POUT_MIN, + PMBUS_VIRT_READ_POUT_MAX, + PMBUS_VIRT_RESET_POUT_HISTORY, + PMBUS_VIRT_READ_VOUT_AVG, + PMBUS_VIRT_READ_VOUT_MIN, + PMBUS_VIRT_READ_VOUT_MAX, + PMBUS_VIRT_RESET_VOUT_HISTORY, + PMBUS_VIRT_READ_IOUT_AVG, + PMBUS_VIRT_READ_IOUT_MIN, + PMBUS_VIRT_READ_IOUT_MAX, + PMBUS_VIRT_RESET_IOUT_HISTORY, + PMBUS_VIRT_READ_TEMP2_AVG, + PMBUS_VIRT_READ_TEMP2_MIN, + PMBUS_VIRT_READ_TEMP2_MAX, + PMBUS_VIRT_RESET_TEMP2_HISTORY, + + PMBUS_VIRT_READ_VMON, + PMBUS_VIRT_VMON_UV_WARN_LIMIT, + PMBUS_VIRT_VMON_OV_WARN_LIMIT, + PMBUS_VIRT_VMON_UV_FAULT_LIMIT, + PMBUS_VIRT_VMON_OV_FAULT_LIMIT, + PMBUS_VIRT_STATUS_VMON, + + /* + * RPM and PWM Fan control + * + * Drivers wanting to expose PWM control must define the behaviour of + * PMBUS_VIRT_PWM_[1-4] and PMBUS_VIRT_PWM_ENABLE_[1-4] in the + * {read,write}_word_data callback. + * + * pmbus core provides a default implementation for + * PMBUS_VIRT_FAN_TARGET_[1-4]. + * + * TARGET, PWM and PWM_ENABLE members must be defined sequentially; + * pmbus core uses the difference between the provided register and + * it's _1 counterpart to calculate the FAN/PWM ID. + */ + PMBUS_VIRT_FAN_TARGET_1, + PMBUS_VIRT_FAN_TARGET_2, + PMBUS_VIRT_FAN_TARGET_3, + PMBUS_VIRT_FAN_TARGET_4, + PMBUS_VIRT_PWM_1, + PMBUS_VIRT_PWM_2, + PMBUS_VIRT_PWM_3, + PMBUS_VIRT_PWM_4, + PMBUS_VIRT_PWM_ENABLE_1, + PMBUS_VIRT_PWM_ENABLE_2, + PMBUS_VIRT_PWM_ENABLE_3, + PMBUS_VIRT_PWM_ENABLE_4, +}; + +/* + * OPERATION + */ +#define PB_OPERATION_CONTROL_ON BIT(7) + +/* + * CAPABILITY + */ +#define PB_CAPABILITY_SMBALERT BIT(4) +#define PB_CAPABILITY_ERROR_CHECK BIT(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 (BIT(0) | BIT(1)) +#define PB_FAN_2_RPM BIT(2) +#define PB_FAN_2_INSTALLED BIT(3) +#define PB_FAN_1_PULSE_MASK (BIT(4) | BIT(5)) +#define PB_FAN_1_RPM BIT(6) +#define PB_FAN_1_INSTALLED BIT(7) + +enum pmbus_fan_mode { percent = 0, rpm }; + +/* + * STATUS_BYTE, STATUS_WORD (lower) + */ +#define PB_STATUS_NONE_ABOVE BIT(0) +#define PB_STATUS_CML BIT(1) +#define PB_STATUS_TEMPERATURE BIT(2) +#define PB_STATUS_VIN_UV BIT(3) +#define PB_STATUS_IOUT_OC BIT(4) +#define PB_STATUS_VOUT_OV BIT(5) +#define PB_STATUS_OFF BIT(6) +#define PB_STATUS_BUSY BIT(7) + +/* + * STATUS_WORD (upper) + */ +#define PB_STATUS_UNKNOWN BIT(8) +#define PB_STATUS_OTHER BIT(9) +#define PB_STATUS_FANS BIT(10) +#define PB_STATUS_POWER_GOOD_N BIT(11) +#define PB_STATUS_WORD_MFR BIT(12) +#define PB_STATUS_INPUT BIT(13) +#define PB_STATUS_IOUT_POUT BIT(14) +#define PB_STATUS_VOUT BIT(15) + +/* + * STATUS_IOUT + */ +#define PB_POUT_OP_WARNING BIT(0) +#define PB_POUT_OP_FAULT BIT(1) +#define PB_POWER_LIMITING BIT(2) +#define PB_CURRENT_SHARE_FAULT BIT(3) +#define PB_IOUT_UC_FAULT BIT(4) +#define PB_IOUT_OC_WARNING BIT(5) +#define PB_IOUT_OC_LV_FAULT BIT(6) +#define PB_IOUT_OC_FAULT BIT(7) + +/* + * STATUS_VOUT, STATUS_INPUT + */ +#define PB_VOLTAGE_UV_FAULT BIT(4) +#define PB_VOLTAGE_UV_WARNING BIT(5) +#define PB_VOLTAGE_OV_WARNING BIT(6) +#define PB_VOLTAGE_OV_FAULT BIT(7) + +/* + * STATUS_INPUT + */ +#define PB_PIN_OP_WARNING BIT(0) +#define PB_IIN_OC_WARNING BIT(1) +#define PB_IIN_OC_FAULT BIT(2) + +/* + * STATUS_TEMPERATURE + */ +#define PB_TEMP_UT_FAULT BIT(4) +#define PB_TEMP_UT_WARNING BIT(5) +#define PB_TEMP_OT_WARNING BIT(6) +#define PB_TEMP_OT_FAULT BIT(7) + +/* + * STATUS_FAN + */ +#define PB_FAN_AIRFLOW_WARNING BIT(0) +#define PB_FAN_AIRFLOW_FAULT BIT(1) +#define PB_FAN_FAN2_SPEED_OVERRIDE BIT(2) +#define PB_FAN_FAN1_SPEED_OVERRIDE BIT(3) +#define PB_FAN_FAN2_WARNING BIT(4) +#define PB_FAN_FAN1_WARNING BIT(5) +#define PB_FAN_FAN2_FAULT BIT(6) +#define PB_FAN_FAN1_FAULT BIT(7) + +/* + * CML_FAULT_STATUS + */ +#define PB_CML_FAULT_OTHER_MEM_LOGIC BIT(0) +#define PB_CML_FAULT_OTHER_COMM BIT(1) +#define PB_CML_FAULT_PROCESSOR BIT(3) +#define PB_CML_FAULT_MEMORY BIT(4) +#define PB_CML_FAULT_PACKET_ERROR BIT(5) +#define PB_CML_FAULT_INVALID_DATA BIT(6) +#define PB_CML_FAULT_INVALID_COMMAND BIT(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_PWM, + PSC_NUM_CLASSES /* Number of power sensor classes */ +}; + +#define PMBUS_PAGES 32 /* Per PMBus specification */ + +/* Functionality bit mask */ +#define PMBUS_HAVE_VIN BIT(0) +#define PMBUS_HAVE_VCAP BIT(1) +#define PMBUS_HAVE_VOUT BIT(2) +#define PMBUS_HAVE_IIN BIT(3) +#define PMBUS_HAVE_IOUT BIT(4) +#define PMBUS_HAVE_PIN BIT(5) +#define PMBUS_HAVE_POUT BIT(6) +#define PMBUS_HAVE_FAN12 BIT(7) +#define PMBUS_HAVE_FAN34 BIT(8) +#define PMBUS_HAVE_TEMP BIT(9) +#define PMBUS_HAVE_TEMP2 BIT(10) +#define PMBUS_HAVE_TEMP3 BIT(11) +#define PMBUS_HAVE_STATUS_VOUT BIT(12) +#define PMBUS_HAVE_STATUS_IOUT BIT(13) +#define PMBUS_HAVE_STATUS_INPUT BIT(14) +#define PMBUS_HAVE_STATUS_TEMP BIT(15) +#define PMBUS_HAVE_STATUS_FAN12 BIT(16) +#define PMBUS_HAVE_STATUS_FAN34 BIT(17) +#define PMBUS_HAVE_VMON BIT(18) +#define PMBUS_HAVE_STATUS_VMON BIT(19) +#define PMBUS_HAVE_PWM12 BIT(20) +#define PMBUS_HAVE_PWM34 BIT(21) + +#define PMBUS_PAGE_VIRTUAL BIT(31) + +enum pmbus_data_format { linear = 0, direct, vid }; +enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv }; + +struct pmbus_driver_info { + int pages; /* Total number of pages */ + enum pmbus_data_format format[PSC_NUM_CLASSES]; + enum vrm_version vrm_version[PMBUS_PAGES]; /* vrm version per page */ + /* + * 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); + + /* Regulator functionality, if supported by this chip driver. */ + int num_regulators; + const struct regulator_desc *reg_desc; +}; + +/* Regulator ops */ + +extern const struct regulator_ops rg_pmbus_regulator_ops; + +/* Macro for filling in array of struct regulator_desc */ +#define PMBUS_REGULATOR(_name, _id) \ + [_id] = { \ + .name = (_name # _id), \ + .id = (_id), \ + .of_match = of_match_ptr(_name # _id), \ + .regulators_node = of_match_ptr("regulators"), \ + .ops = &rg_pmbus_regulator_ops, \ + .type = REGULATOR_VOLTAGE, \ + .owner = THIS_MODULE, \ + } + +/* Function declarations */ + +void rg_pmbus_clear_cache(struct i2c_client *client); +int rg_pmbus_set_page(struct i2c_client *client, int page); +int rg_pmbus_read_word_data(struct i2c_client *client, int page, u8 reg); +int rg_pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, u16 word); +int rg_pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); +int rg_pmbus_write_byte(struct i2c_client *client, int page, u8 value); +int rg_pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, + u8 value); +int rg_pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg, + u8 mask, u8 value); +void rg_pmbus_clear_faults(struct i2c_client *client); +bool rg_pmbus_check_byte_register(struct i2c_client *client, int page, int reg); +bool rg_pmbus_check_word_register(struct i2c_client *client, int page, int reg); +int rg_pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, + struct pmbus_driver_info *info); +int rg_pmbus_do_remove(struct i2c_client *client); +const struct pmbus_driver_info *rg_pmbus_get_driver_info(struct i2c_client + *client); +int rg_pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode); +int rg_pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode); +int rg_pmbus_update_fan(struct i2c_client *client, int page, int id, + u8 config, u8 mask, u16 command); +struct dentry *rg_pmbus_get_debugfs_dir(struct i2c_client *client); + +#endif /* RG_PMBUS_H */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus_core.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus_core.c new file mode 100644 index 000000000000..825b03b67792 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_pmbus_core.c @@ -0,0 +1,2570 @@ +/* + * Hardware monitoring driver 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rg_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_RETRY_SLEEP_TIME (10000) /* 10ms */ +#define PMBUS_RETRY_TIME (3) + +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 */ + bool convert; /* Whether or not to apply linear/vid/direct */ + 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_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_attr_status { + char name[PMBUS_NAME_SIZE]; /* sysfs label name */ + struct device_attribute attribute; +}; +#define to_pmbus_attr_status(_attr) \ + container_of(_attr, struct pmbus_attr_status, 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 dentry *debugfs; /* debugfs device directory */ + + 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. + */ + u16 status[PB_NUM_STATUS_REG]; + + bool has_status_word; /* device uses STATUS_WORD register */ + int (*read_status)(struct i2c_client *client, int page); + + u8 currpage; +}; + +struct pmbus_debugfs_entry { + struct i2c_client *client; + u8 page; + u8 reg; +}; + +static const int pmbus_fan_rpm_mask[] = { + PB_FAN_1_RPM, + PB_FAN_2_RPM, + PB_FAN_1_RPM, + PB_FAN_2_RPM, +}; + +static const int pmbus_fan_config_registers[] = { + PMBUS_FAN_CONFIG_12, + PMBUS_FAN_CONFIG_12, + PMBUS_FAN_CONFIG_34, + PMBUS_FAN_CONFIG_34 +}; + +static const int pmbus_fan_command_registers[] = { + PMBUS_FAN_COMMAND_1, + PMBUS_FAN_COMMAND_2, + PMBUS_FAN_COMMAND_3, + PMBUS_FAN_COMMAND_4, +}; + +void rg_pmbus_clear_cache(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + data->valid = false; +} +EXPORT_SYMBOL_GPL(rg_pmbus_clear_cache); + +int rg_pmbus_set_page(struct i2c_client *client, int page) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + int rv; + + if (page < 0 || page == data->currpage) + return 0; + + if (!(data->info->func[page] & PMBUS_PAGE_VIRTUAL)) { + rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); + if (rv < 0) + return rv; + + rv = i2c_smbus_read_byte_data(client, PMBUS_PAGE); + if (rv < 0) + return rv; + + if (rv != page) + return -EIO; + } + + data->currpage = page; + + return 0; +} +EXPORT_SYMBOL_GPL(rg_pmbus_set_page); + +int rg_pmbus_write_byte(struct i2c_client *client, int page, u8 value) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_write_byte(client, value); +} +EXPORT_SYMBOL_GPL(rg_pmbus_write_byte); + +/* + * _pmbus_write_byte() is similar to rg_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 rg_pmbus_write_byte(client, page, value); +} + +int rg_pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, + u16 word) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_write_word_data(client, reg, word); +} +EXPORT_SYMBOL_GPL(rg_pmbus_write_word_data); + +static int pmbus_write_virt_reg(struct i2c_client *client, int page, int reg, + u16 word) +{ + int bit; + int id; + int rv; + + switch (reg) { + case PMBUS_VIRT_FAN_TARGET_1 ... PMBUS_VIRT_FAN_TARGET_4: + id = reg - PMBUS_VIRT_FAN_TARGET_1; + bit = pmbus_fan_rpm_mask[id]; + rv = rg_pmbus_update_fan(client, page, id, bit, bit, word); + break; + default: + rv = -ENXIO; + break; + } + + return rv; +} + +/* + * _pmbus_write_word_data() is similar to rg_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 pmbus_write_virt_reg(client, page, reg, word); + + return rg_pmbus_write_word_data(client, page, reg, word); +} + +int rg_pmbus_update_fan(struct i2c_client *client, int page, int id, + u8 config, u8 mask, u16 command) +{ + int from; + int rv; + u8 to; + + from = rg_pmbus_read_byte_data(client, page, + pmbus_fan_config_registers[id]); + if (from < 0) + return from; + + to = (from & ~mask) | (config & mask); + if (to != from) { + rv = rg_pmbus_write_byte_data(client, page, + pmbus_fan_config_registers[id], to); + if (rv < 0) + return rv; + } + + return _pmbus_write_word_data(client, page, + pmbus_fan_command_registers[id], command); +} +EXPORT_SYMBOL_GPL(rg_pmbus_update_fan); + +static int pmbus_read_word_data_tmp(struct i2c_client *client, int page, u8 reg) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_read_word_data(client, reg); +} + +int rg_pmbus_read_word_data(struct i2c_client *client, int page, u8 reg) +{ + int rv, i; + struct device *dev = &client->dev; + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + rv = pmbus_read_word_data_tmp(client, page, reg); + if(rv >= 0){ + return rv; + } + if ((i + 1) < PMBUS_RETRY_TIME) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + } + } + dev_info(dev, "rg_pmbus_read_word_data, page=%d, reg=0x%x, value=%d\r\n", page, reg, rv); + return rv; +} +EXPORT_SYMBOL_GPL(rg_pmbus_read_word_data); + +static int pmbus_read_virt_reg(struct i2c_client *client, int page, int reg) +{ + int rv; + int id; + + switch (reg) { + case PMBUS_VIRT_FAN_TARGET_1 ... PMBUS_VIRT_FAN_TARGET_4: + id = reg - PMBUS_VIRT_FAN_TARGET_1; + rv = rg_pmbus_get_fan_rate_device(client, page, id, rpm); + break; + default: + rv = -ENXIO; + break; + } + + return rv; +} + +/* + * _pmbus_read_word_data() is similar to rg_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 pmbus_read_virt_reg(client, page, reg); + + return rg_pmbus_read_word_data(client, page, reg); +} + +static int pmbus_read_byte_data_tmp(struct i2c_client *client, int page, u8 reg) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_read_byte_data(client, reg); +} + +int rg_pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg) +{ + int rv, i; + struct device *dev = &client->dev; + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + rv = pmbus_read_byte_data_tmp(client, page, reg); + if(rv >= 0){ + return rv; + } + if ((i + 1) < PMBUS_RETRY_TIME) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + } + } + dev_info(dev, "rg_pmbus_read_byte_data, page=%d, reg=0x%x, value=%d\r\n", page, reg, rv); + return rv;; +} +EXPORT_SYMBOL_GPL(rg_pmbus_read_byte_data); + +int rg_pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, u8 value) +{ + int rv; + + rv = rg_pmbus_set_page(client, page); + if (rv < 0) + return rv; + + return i2c_smbus_write_byte_data(client, reg, value); +} +EXPORT_SYMBOL_GPL(rg_pmbus_write_byte_data); + +int rg_pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg, + u8 mask, u8 value) +{ + unsigned int tmp; + int rv; + + rv = rg_pmbus_read_byte_data(client, page, reg); + if (rv < 0) + return rv; + + tmp = (rv & ~mask) | (value & mask); + + if (tmp != rv) + rv = rg_pmbus_write_byte_data(client, page, reg, tmp); + + return rv; +} +EXPORT_SYMBOL_GPL(rg_pmbus_update_byte_data); + +/* + * _pmbus_read_byte_data() is similar to rg_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 rg_pmbus_read_byte_data(client, page, reg); +} + +static struct pmbus_sensor *pmbus_find_sensor(struct pmbus_data *data, int page, + int reg) +{ + struct pmbus_sensor *sensor; + + for (sensor = data->sensors; sensor; sensor = sensor->next) { + if (sensor->page == page && sensor->reg == reg) + return sensor; + } + + return ERR_PTR(-EINVAL); +} + +static int pmbus_get_fan_rate(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode, + bool from_cache) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + bool want_rpm, have_rpm; + struct pmbus_sensor *s; + int config; + int reg; + + want_rpm = (mode == rpm); + + if (from_cache) { + reg = want_rpm ? PMBUS_VIRT_FAN_TARGET_1 : PMBUS_VIRT_PWM_1; + s = pmbus_find_sensor(data, page, reg + id); + if (IS_ERR(s)) + return PTR_ERR(s); + + return s->data; + } + + config = rg_pmbus_read_byte_data(client, page, + pmbus_fan_config_registers[id]); + if (config < 0) + return config; + + have_rpm = !!(config & pmbus_fan_rpm_mask[id]); + if (want_rpm == have_rpm) + return rg_pmbus_read_word_data(client, page, + pmbus_fan_command_registers[id]); + + /* Can't sensibly map between RPM and PWM, just return zero */ + return 0; +} + +int rg_pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode) +{ + return pmbus_get_fan_rate(client, page, id, mode, false); +} +EXPORT_SYMBOL_GPL(rg_pmbus_get_fan_rate_device); + +int rg_pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id, + enum pmbus_fan_mode mode) +{ + return pmbus_get_fan_rate(client, page, id, mode, true); +} +EXPORT_SYMBOL_GPL(rg_pmbus_get_fan_rate_cached); + +static void pmbus_clear_fault_page(struct i2c_client *client, int page) +{ + _pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS); +} + +void rg_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); +} +EXPORT_SYMBOL_GPL(rg_pmbus_clear_faults); + +static int pmbus_check_status_cml(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + int status, status2; + + status = data->read_status(client, -1); + 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; +} + +static bool pmbus_check_status_register(struct i2c_client *client, int page) +{ + int status; + struct pmbus_data *data = i2c_get_clientdata(client); + + status = data->read_status(client, page); + if (status >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK) && + (status & PB_STATUS_CML)) { + status = _pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); + if (status < 0 || (status & PB_CML_FAULT_INVALID_COMMAND)) + status = -EIO; + } + + pmbus_clear_fault_page(client, -1); + return status >= 0; +} + +bool rg_pmbus_check_byte_register(struct i2c_client *client, int page, int reg) +{ + return pmbus_check_register(client, _pmbus_read_byte_data, page, reg); +} +EXPORT_SYMBOL_GPL(rg_pmbus_check_byte_register); + +bool rg_pmbus_check_word_register(struct i2c_client *client, int page, int reg) +{ + return pmbus_check_register(client, _pmbus_read_word_data, page, reg); +} +EXPORT_SYMBOL_GPL(rg_pmbus_check_word_register); + +const struct pmbus_driver_info *rg_pmbus_get_driver_info(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + return data->info; +} +EXPORT_SYMBOL_GPL(rg_pmbus_get_driver_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_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; + + 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] + = data->read_status(client, i); + 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); + } + rg_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) +{ + s64 b, val = (s16)sensor->data; + s32 m, 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 || sensor->class == PSC_PWM)) { + 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_s64(val + 5LL, 10L); /* round closest */ + R++; + } + + val = div_s64(val - b, m); + return clamp_val(val, LONG_MIN, LONG_MAX); +} + +/* + * Convert VID sensor values to milli- or micro-units + * depending on sensor type. + */ +static long pmbus_reg2data_vid(struct pmbus_data *data, + struct pmbus_sensor *sensor) +{ + long val = sensor->data; + long rv = 0; + + switch (data->info->vrm_version[sensor->page]) { + case vr11: + if (val >= 0x02 && val <= 0xb2) + rv = DIV_ROUND_CLOSEST(160000 - (val - 2) * 625, 100); + break; + case vr12: + if (val >= 0x01) + rv = 250 + (val - 1) * 5; + break; + case vr13: + if (val >= 0x01) + rv = 500 + (val - 1) * 10; + break; + case imvp9: + if (val >= 0x01) + rv = 200 + (val - 1) * 10; + break; + case amd625mv: + if (val >= 0x0 && val <= 0xd8) + rv = DIV_ROUND_CLOSEST(155000 - val * 625, 100); + break; + } + return rv; +} + +static long pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor) +{ + long val; + + if (!sensor->convert) + return sensor->data; + + 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) +{ + s64 b, val64 = val; + s32 m, 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 || sensor->class == PSC_PWM)) { + R -= 3; /* Adjust R and b for data in milli-units */ + b *= 1000; + } + val64 = val64 * m + b; + + while (R > 0) { + val64 *= 10; + R--; + } + while (R < 0) { + val64 = div_s64(val64 + 5LL, 10L); /* round closest */ + R++; + } + + return (u16)clamp_val(val64, S16_MIN, S16_MAX); +} + +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; + + if (!sensor->convert) + return val; + + 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 >> 16) & 0xffff; + u16 mask = index & 0xffff; + int ret, status; + u16 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_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 ssize_t pmbus_show_status(struct device *dev, + struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct pmbus_data *data = pmbus_update_device(dev); + u16 reg; + int index, status; + + index = attr->index; + reg = (index >> 16) & 0xffff; + status = data->status[reg]; + + return snprintf(buf, PAGE_SIZE, "0x%04x\n", status); +} + +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, u16 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 << 16) | 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, + bool convert) +{ + struct pmbus_sensor *sensor; + struct device_attribute *a; + + sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL); + if (!sensor) + return NULL; + a = &sensor->attribute; + + if (type) + snprintf(sensor->name, sizeof(sensor->name), "%s%d_%s", + name, seq, type); + else + snprintf(sensor->name, sizeof(sensor->name), "%s%d", + name, seq); + + sensor->page = page; + sensor->reg = reg; + sensor->class = class; + sensor->update = update; + sensor->convert = convert; + 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_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); +} + +static int pmbus_add_status(struct pmbus_data *data, int page) +{ + struct pmbus_attr_status *attr_status; + struct device_attribute *a; + + attr_status = devm_kzalloc(data->dev, sizeof(*attr_status), GFP_KERNEL); + if (!attr_status) + return -ENOMEM; + + snprintf(attr_status->name, sizeof(attr_status->name), "status%d", page); + a = &attr_status->attribute; + + pmbus_dev_attr_init(a, attr_status->name, S_IRUGO, pmbus_show_status, 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 */ + u16 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 (rg_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, true); + 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, + bool paged) +{ + struct pmbus_sensor *base; + bool upper = !!(attr->gbit & 0xff00); /* need to check STATUS_WORD */ + int ret; + + if (attr->label) { + ret = pmbus_add_label(data, name, index, attr->label, + paged ? page + 1 : 0); + if (ret) + return ret; + } + base = pmbus_add_sensor(data, name, "input", index, page, attr->reg, + attr->class, true, 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 (word or byte, depending on + * which global bit is set) for this page is accessible. + */ + if (!ret && attr->gbit && + (!upper || (upper && data->has_status_word)) && + pmbus_check_status_register(client, page)) { + ret = pmbus_add_boolean(data, name, "alarm", index, + NULL, NULL, + PB_STATUS_BASE + page, + attr->gbit); + if (ret) + return ret; + } + } + return 0; +} + +static bool pmbus_sensor_is_paged(const struct pmbus_driver_info *info, + const struct pmbus_sensor_attr *attr) +{ + int p; + + if (attr->paged) + return true; + + /* + * Some attributes may be present on more than one page despite + * not being marked with the paged attribute. If that is the case, + * then treat the sensor as being paged and add the page suffix to the + * attribute name. + * We don't just add the paged attribute to all such attributes, in + * order to maintain the un-suffixed labels in the case where the + * attribute is only on page 0. + */ + for (p = 1; p < info->pages; p++) { + if (info->func[p] & attr->func) + return true; + } + return false; +} + +static int pmbus_add_status_attrs(struct i2c_client *client, struct pmbus_data *data) +{ + const struct pmbus_driver_info *info = data->info; + int i; + int ret; + + for (i = 0; i < info->pages; i++) { + ret = pmbus_add_status(data, i); + 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; + bool paged = pmbus_sensor_is_paged(info, attrs); + + pages = 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, paged); + if (ret) + return ret; + index++; + } + attrs++; + } + return 0; +} + +static const struct pmbus_limit_attr vin_limit_attrs[] = { + { + .reg = PMBUS_VIN_UV_WARN_LIMIT, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_VOLTAGE_UV_WARNING, + }, { + .reg = PMBUS_VIN_UV_FAULT_LIMIT, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_VOLTAGE_UV_FAULT, + }, { + .reg = PMBUS_VIN_OV_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_VOLTAGE_OV_WARNING, + }, { + .reg = PMBUS_VIN_OV_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_VOLTAGE_OV_FAULT, + }, { + .reg = PMBUS_VIRT_READ_VIN_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_VIN_MIN, + .update = true, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_VIN_MAX, + .update = true, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_VIN_HISTORY, + .attr = "reset_history", + }, +}; + +static const struct pmbus_limit_attr vmon_limit_attrs[] = { + { + .reg = PMBUS_VIRT_VMON_UV_WARN_LIMIT, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_VOLTAGE_UV_WARNING, + }, { + .reg = PMBUS_VIRT_VMON_UV_FAULT_LIMIT, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_VOLTAGE_UV_FAULT, + }, { + .reg = PMBUS_VIRT_VMON_OV_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_VOLTAGE_OV_WARNING, + }, { + .reg = PMBUS_VIRT_VMON_OV_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_VOLTAGE_OV_FAULT, + } +}; + +static const struct pmbus_limit_attr vout_limit_attrs[] = { + { + .reg = PMBUS_VOUT_UV_WARN_LIMIT, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_VOLTAGE_UV_WARNING, + }, { + .reg = PMBUS_VOUT_UV_FAULT_LIMIT, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_VOLTAGE_UV_FAULT, + }, { + .reg = PMBUS_VOUT_OV_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_VOLTAGE_OV_WARNING, + }, { + .reg = PMBUS_VOUT_OV_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_VOLTAGE_OV_FAULT, + }, { + .reg = PMBUS_VIRT_READ_VOUT_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_VOUT_MIN, + .update = true, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_VOUT_MAX, + .update = true, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_VOUT_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_sensor_attr voltage_attributes[] = { + { + .reg = PMBUS_READ_VIN, + .class = PSC_VOLTAGE_IN, + .label = "vin", + .func = PMBUS_HAVE_VIN, + .sfunc = PMBUS_HAVE_STATUS_INPUT, + .sbase = PB_STATUS_INPUT_BASE, + .gbit = PB_STATUS_VIN_UV, + .limit = vin_limit_attrs, + .nlimit = 0, + }, { + .reg = PMBUS_VIRT_READ_VMON, + .class = PSC_VOLTAGE_IN, + .label = "vmon", + .func = PMBUS_HAVE_VMON, + .sfunc = PMBUS_HAVE_STATUS_VMON, + .sbase = PB_STATUS_VMON_BASE, + .limit = vmon_limit_attrs, + .nlimit = 0, + }, { + .reg = PMBUS_READ_VCAP, + .class = PSC_VOLTAGE_IN, + .label = "vcap", + .func = PMBUS_HAVE_VCAP, + }, { + .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, + .limit = vout_limit_attrs, + .nlimit = 0, + } +}; + +/* Current attributes */ + +static const struct pmbus_limit_attr iin_limit_attrs[] = { + { + .reg = PMBUS_IIN_OC_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_IIN_OC_WARNING, + }, { + .reg = PMBUS_IIN_OC_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_IIN_OC_FAULT, + }, { + .reg = PMBUS_VIRT_READ_IIN_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_IIN_MIN, + .update = true, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_IIN_MAX, + .update = true, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_IIN_HISTORY, + .attr = "reset_history", + } +}; + +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_UC_FAULT_LIMIT, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_IOUT_UC_FAULT, + }, { + .reg = PMBUS_IOUT_OC_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_IOUT_OC_FAULT, + }, { + .reg = PMBUS_VIRT_READ_IOUT_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_IOUT_MIN, + .update = true, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_IOUT_MAX, + .update = true, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_IOUT_HISTORY, + .attr = "reset_history", + } +}; + +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, + .gbit = PB_STATUS_INPUT, + .limit = iin_limit_attrs, + .nlimit = 0, + }, { + .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 = 0, + } +}; + +/* Power attributes */ + +static const struct pmbus_limit_attr pin_limit_attrs[] = { + { + .reg = PMBUS_PIN_OP_WARN_LIMIT, + .attr = "max", + .alarm = "alarm", + .sbit = PB_PIN_OP_WARNING, + }, { + .reg = PMBUS_VIRT_READ_PIN_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_PIN_MIN, + .update = true, + .attr = "input_lowest", + }, { + .reg = PMBUS_VIRT_READ_PIN_MAX, + .update = true, + .attr = "input_highest", + }, { + .reg = PMBUS_VIRT_RESET_PIN_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_limit_attr pout_limit_attrs[] = { + { + .reg = PMBUS_POUT_MAX, + .attr = "cap", + .alarm = "cap_alarm", + .sbit = PB_POWER_LIMITING, + }, { + .reg = PMBUS_POUT_OP_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_POUT_OP_WARNING, + }, { + .reg = PMBUS_POUT_OP_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_POUT_OP_FAULT, + }, { + .reg = PMBUS_VIRT_READ_POUT_AVG, + .update = true, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_POUT_MIN, + .update = true, + .attr = "input_lowest", + }, { + .reg = PMBUS_VIRT_READ_POUT_MAX, + .update = true, + .attr = "input_highest", + }, { + .reg = PMBUS_VIRT_RESET_POUT_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_sensor_attr power_attributes[] = { + { + .reg = PMBUS_READ_PIN, + .class = PSC_POWER, + .label = "pin", + .func = PMBUS_HAVE_PIN, + .sfunc = PMBUS_HAVE_STATUS_INPUT, + .sbase = PB_STATUS_INPUT_BASE, + .gbit = PB_STATUS_INPUT, + .limit = pin_limit_attrs, + .nlimit = 0, + }, { + .reg = PMBUS_READ_POUT, + .class = PSC_POWER, + .label = "pout", + .paged = true, + .func = PMBUS_HAVE_POUT, + .sfunc = PMBUS_HAVE_STATUS_IOUT, + .sbase = PB_STATUS_IOUT_BASE, + .limit = pout_limit_attrs, + .nlimit = 0, + } +}; + +/* Temperature atributes */ + +static const struct pmbus_limit_attr temp_limit_attrs[] = { + { + .reg = PMBUS_UT_WARN_LIMIT, + .low = true, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_TEMP_UT_WARNING, + }, { + .reg = PMBUS_UT_FAULT_LIMIT, + .low = true, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_TEMP_UT_FAULT, + }, { + .reg = PMBUS_OT_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_TEMP_OT_WARNING, + }, { + .reg = PMBUS_OT_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_TEMP_OT_FAULT, + }, { + .reg = PMBUS_VIRT_READ_TEMP_MIN, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_TEMP_AVG, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_TEMP_MAX, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_TEMP_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_limit_attr temp_limit_attrs2[] = { + { + .reg = PMBUS_UT_WARN_LIMIT, + .low = true, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_TEMP_UT_WARNING, + }, { + .reg = PMBUS_UT_FAULT_LIMIT, + .low = true, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_TEMP_UT_FAULT, + }, { + .reg = PMBUS_OT_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_TEMP_OT_WARNING, + }, { + .reg = PMBUS_OT_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_TEMP_OT_FAULT, + }, { + .reg = PMBUS_VIRT_READ_TEMP2_MIN, + .attr = "lowest", + }, { + .reg = PMBUS_VIRT_READ_TEMP2_AVG, + .attr = "average", + }, { + .reg = PMBUS_VIRT_READ_TEMP2_MAX, + .attr = "highest", + }, { + .reg = PMBUS_VIRT_RESET_TEMP2_HISTORY, + .attr = "reset_history", + } +}; + +static const struct pmbus_limit_attr temp_limit_attrs3[] = { + { + .reg = PMBUS_UT_WARN_LIMIT, + .low = true, + .attr = "min", + .alarm = "min_alarm", + .sbit = PB_TEMP_UT_WARNING, + }, { + .reg = PMBUS_UT_FAULT_LIMIT, + .low = true, + .attr = "lcrit", + .alarm = "lcrit_alarm", + .sbit = PB_TEMP_UT_FAULT, + }, { + .reg = PMBUS_OT_WARN_LIMIT, + .attr = "max", + .alarm = "max_alarm", + .sbit = PB_TEMP_OT_WARNING, + }, { + .reg = PMBUS_OT_FAULT_LIMIT, + .attr = "crit", + .alarm = "crit_alarm", + .sbit = PB_TEMP_OT_FAULT, + } +}; + +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 = 0, + }, { + .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 = 0, + }, { + .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 = 0, + } +}; + +static const int pmbus_fan_registers[] = { + PMBUS_READ_FAN_SPEED_1, + PMBUS_READ_FAN_SPEED_2, + PMBUS_READ_FAN_SPEED_3, + PMBUS_READ_FAN_SPEED_4 +}; + +static const int pmbus_fan_status_registers[] = { + PMBUS_STATUS_FAN_12, + PMBUS_STATUS_FAN_12, + PMBUS_STATUS_FAN_34, + PMBUS_STATUS_FAN_34 +}; + +static const u32 pmbus_fan_flags[] = { + PMBUS_HAVE_FAN12, + PMBUS_HAVE_FAN12, + PMBUS_HAVE_FAN34, + PMBUS_HAVE_FAN34 +}; + +static const u32 pmbus_fan_status_flags[] = { + PMBUS_HAVE_STATUS_FAN12, + PMBUS_HAVE_STATUS_FAN12, + PMBUS_HAVE_STATUS_FAN34, + PMBUS_HAVE_STATUS_FAN34 +}; + +/* Fans */ + +/* Precondition: FAN_CONFIG_x_y and FAN_COMMAND_x must exist for the fan ID */ +static int pmbus_add_fan_ctrl(struct i2c_client *client, + struct pmbus_data *data, int index, int page, int id, + u8 config) +{ + struct pmbus_sensor *sensor; + + sensor = pmbus_add_sensor(data, "fan", "target", index, page, + PMBUS_VIRT_FAN_TARGET_1 + id, PSC_FAN, + false, false, true); + + if (!sensor) + return -ENOMEM; + + if (!((data->info->func[page] & PMBUS_HAVE_PWM12) || + (data->info->func[page] & PMBUS_HAVE_PWM34))) + return 0; + + sensor = pmbus_add_sensor(data, "pwm", NULL, index, page, + PMBUS_VIRT_PWM_1 + id, PSC_PWM, + false, false, true); + + if (!sensor) + return -ENOMEM; + + sensor = pmbus_add_sensor(data, "pwm", "enable", index, page, + PMBUS_VIRT_PWM_ENABLE_1 + id, PSC_PWM, + true, false, false); + + if (!sensor) + return -ENOMEM; + + return 0; +} + +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 (!rg_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, true) == NULL) + return -ENOMEM; + + /* Fan control */ + if (rg_pmbus_check_word_register(client, page, + pmbus_fan_command_registers[f])) { + ret = pmbus_add_fan_ctrl(client, data, index, + page, f, regval); + if (ret < 0) + return ret; + } + + /* + * Each fan status register covers multiple fans, + * so we have to do some magic. + */ + if ((info->func[page] & pmbus_fan_status_flags[f]) && + rg_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; +} + +static int pmbus_find_attributes(struct i2c_client *client, + struct pmbus_data *data) +{ + int ret; + + /* status attrs */ + ret = pmbus_add_status_attrs(client, data); + if (ret) + return 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; + + /* Power sensors */ + ret = pmbus_add_sensor_attrs(client, data, "power", power_attributes, + ARRAY_SIZE(power_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); + 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 (rg_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_read_status_byte(struct i2c_client *client, int page) +{ + return _pmbus_read_byte_data(client, page, PMBUS_STATUS_BYTE); +} + +static int pmbus_read_status_word(struct i2c_client *client, int page) +{ + return _pmbus_read_word_data(client, page, PMBUS_STATUS_WORD); +} + +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, i; + + /* + * Some PMBus chips don't support PMBUS_STATUS_WORD, so try + * to use PMBUS_STATUS_BYTE instead if that is the case. + * Bail out if both registers are not supported. + */ + data->read_status = pmbus_read_status_word; + /* retry read PMBUS_STATUS_WORD */ + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + ret = i2c_smbus_read_word_data(client, PMBUS_STATUS_WORD); + if (ret < 0 || ret == 0xffff) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + continue; + } + break; + } + + /* retry read PMBUS_STATUS_WORD fail, instead of retrying read PMBUS_STATUS_BYTE */ + if(i == PMBUS_RETRY_TIME) { + dev_info(dev, "pmbus read status word failed, next retry read status byte.\n"); + data->read_status = pmbus_read_status_byte; + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE); + if (ret < 0 || ret == 0xff) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + continue; + } + break; + } + } + + if(i == PMBUS_RETRY_TIME) { + dev_err(dev, "PMBus status register not found\n"); + return -ENODEV; + } + data->has_status_word = true; + + /* Enable PEC if the controller supports it */ + for(i = 0; i < PMBUS_RETRY_TIME; i++) { + ret = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); + if(ret < 0) { + usleep_range(PMBUS_RETRY_SLEEP_TIME, PMBUS_RETRY_SLEEP_TIME + 1); + continue; + } else if (ret & PB_CAPABILITY_ERROR_CHECK) { + client->flags |= I2C_CLIENT_PEC; + } + break; + } + + if (data->info->pages) + rg_pmbus_clear_faults(client); + else + pmbus_clear_fault_page(client, -1); + + 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; + } + + 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; +} + +#if IS_ENABLED(CONFIG_REGULATOR) +static int pmbus_regulator_is_enabled(struct regulator_dev *rdev) +{ + struct device *dev = rdev_get_dev(rdev); + struct i2c_client *client = to_i2c_client(dev->parent); + u8 page = rdev_get_id(rdev); + int ret; + + ret = rg_pmbus_read_byte_data(client, page, PMBUS_OPERATION); + if (ret < 0) + return ret; + + return !!(ret & PB_OPERATION_CONTROL_ON); +} + +static int _pmbus_regulator_on_off(struct regulator_dev *rdev, bool enable) +{ + struct device *dev = rdev_get_dev(rdev); + struct i2c_client *client = to_i2c_client(dev->parent); + u8 page = rdev_get_id(rdev); + + return rg_pmbus_update_byte_data(client, page, PMBUS_OPERATION, + PB_OPERATION_CONTROL_ON, + enable ? PB_OPERATION_CONTROL_ON : 0); +} + +static int pmbus_regulator_enable(struct regulator_dev *rdev) +{ + return _pmbus_regulator_on_off(rdev, 1); +} + +static int pmbus_regulator_disable(struct regulator_dev *rdev) +{ + return _pmbus_regulator_on_off(rdev, 0); +} + +const struct regulator_ops rg_pmbus_regulator_ops = { + .enable = pmbus_regulator_enable, + .disable = pmbus_regulator_disable, + .is_enabled = pmbus_regulator_is_enabled, +}; +EXPORT_SYMBOL_GPL(rg_pmbus_regulator_ops); + +static int pmbus_regulator_register(struct pmbus_data *data) +{ + struct device *dev = data->dev; + const struct pmbus_driver_info *info = data->info; + const struct pmbus_platform_data *pdata = dev_get_platdata(dev); + struct regulator_dev *rdev; + int i; + + for (i = 0; i < info->num_regulators; i++) { + struct regulator_config config = { }; + + config.dev = dev; + config.driver_data = data; + + if (pdata && pdata->reg_init_data) + config.init_data = &pdata->reg_init_data[i]; + + rdev = devm_regulator_register(dev, &info->reg_desc[i], + &config); + if (IS_ERR(rdev)) { + dev_err(dev, "Failed to register %s regulator\n", + info->reg_desc[i].name); + return PTR_ERR(rdev); + } + } + + return 0; +} +#else +static int pmbus_regulator_register(struct pmbus_data *data) +{ + return 0; +} +#endif + +static struct dentry *pmbus_debugfs_dir; /* pmbus debugfs directory */ + +/* #if IS_ENABLED(CONFIG_DEBUG_FS) */ +#if 0 +static int pmbus_debugfs_get(void *data, u64 *val) +{ + int rc; + struct pmbus_debugfs_entry *entry = data; + + rc = _pmbus_read_byte_data(entry->client, entry->page, entry->reg); + if (rc < 0) + return rc; + + *val = rc; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops, pmbus_debugfs_get, NULL, + "0x%02llx\n"); + +static int pmbus_debugfs_get_status(void *data, u64 *val) +{ + int rc; + struct pmbus_debugfs_entry *entry = data; + struct pmbus_data *pdata = i2c_get_clientdata(entry->client); + + rc = pdata->read_status(entry->client, entry->page); + if (rc < 0) + return rc; + + *val = rc; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_status, + NULL, "0x%04llx\n"); + +static int pmbus_init_debugfs(struct i2c_client *client, + struct pmbus_data *data) +{ + int i, idx = 0; + char name[PMBUS_NAME_SIZE]; + struct pmbus_debugfs_entry *entries; + + if (!pmbus_debugfs_dir) + return -ENODEV; + + /* + * Create the debugfs directory for this device. Use the hwmon device + * name to avoid conflicts (hwmon numbers are globally unique). + */ + data->debugfs = debugfs_create_dir(dev_name(data->hwmon_dev), + pmbus_debugfs_dir); + if (IS_ERR_OR_NULL(data->debugfs)) { + data->debugfs = NULL; + return -ENODEV; + } + + /* Allocate the max possible entries we need. */ + entries = devm_kcalloc(data->dev, + data->info->pages * 10, sizeof(*entries), + GFP_KERNEL); + if (!entries) + return -ENOMEM; + + for (i = 0; i < data->info->pages; ++i) { + /* Check accessibility of status register if it's not page 0 */ + if (!i || pmbus_check_status_register(client, i)) { + /* No need to set reg as we have special read op. */ + entries[idx].client = client; + entries[idx].page = i; + scnprintf(name, PMBUS_NAME_SIZE, "status%d", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops_status); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_VOUT) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_VOUT; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_vout", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_IOUT) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_IOUT; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_iout", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_INPUT) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_INPUT; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_input", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_TEMP) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_TEMPERATURE; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_temp", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (rg_pmbus_check_byte_register(client, i, PMBUS_STATUS_CML)) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_CML; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_cml", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (rg_pmbus_check_byte_register(client, i, PMBUS_STATUS_OTHER)) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_OTHER; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_other", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (rg_pmbus_check_byte_register(client, i, + PMBUS_STATUS_MFR_SPECIFIC)) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_MFR_SPECIFIC; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_mfr", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_FAN12) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_FAN_12; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_fan12", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + + if (data->info->func[i] & PMBUS_HAVE_STATUS_FAN34) { + entries[idx].client = client; + entries[idx].page = i; + entries[idx].reg = PMBUS_STATUS_FAN_34; + scnprintf(name, PMBUS_NAME_SIZE, "status%d_fan34", i); + debugfs_create_file(name, 0444, data->debugfs, + &entries[idx++], + &pmbus_debugfs_ops); + } + } + + return 0; +} +#else +static int pmbus_init_debugfs(struct i2c_client *client, + struct pmbus_data *data) +{ + return 0; +} +#endif /* IS_ENABLED(CONFIG_DEBUG_FS) */ + +int rg_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; + } + + ret = pmbus_regulator_register(data); + if (ret) + goto out_unregister; + + ret = pmbus_init_debugfs(client, data); + if (ret) + dev_warn(dev, "Failed to register debugfs\n"); + + return 0; + +out_unregister: + hwmon_device_unregister(data->hwmon_dev); +out_kfree: + kfree(data->group.attrs); + return ret; +} +EXPORT_SYMBOL_GPL(rg_pmbus_do_probe); + +int rg_pmbus_do_remove(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + debugfs_remove_recursive(data->debugfs); + + hwmon_device_unregister(data->hwmon_dev); + kfree(data->group.attrs); + return 0; +} +EXPORT_SYMBOL_GPL(rg_pmbus_do_remove); + +struct dentry *rg_pmbus_get_debugfs_dir(struct i2c_client *client) +{ + struct pmbus_data *data = i2c_get_clientdata(client); + + return data->debugfs; +} +EXPORT_SYMBOL_GPL(rg_pmbus_get_debugfs_dir); + +static int __init pmbus_core_init(void) +{ + pmbus_debugfs_dir = debugfs_create_dir("pmbus", NULL); + if (IS_ERR(pmbus_debugfs_dir)) + pmbus_debugfs_dir = NULL; + + return 0; +} + +static void __exit pmbus_core_exit(void) +{ + debugfs_remove_recursive(pmbus_debugfs_dir); +} + +module_init(pmbus_core_init); +module_exit(pmbus_core_exit); + +MODULE_AUTHOR("Guenter Roeck"); +MODULE_DESCRIPTION("PMBus core driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_93xx46.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_93xx46.c new file mode 100644 index 000000000000..d1e7ce6e84a2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_93xx46.c @@ -0,0 +1,111 @@ +/* + * EEPROMs access control driver for display configuration EEPROMs + * on DigsyMTC board. + * + * (C) 2011 DENX Software Engineering, Anatolij Gustschin + * + * 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 + +#define DEFAULT_SPI_BUS_NUM (0) +#define DEFAULT_SPI_CS_NUM (0) +#define DEFAULT_SPI_HZ (100000) + +#define GPIO_EEPROM_CS (-1) + +int g_rg_spi_93xx46_debug = 0; +int g_rg_spi_93xx46_error = 0; +int spi_bus_num = DEFAULT_SPI_BUS_NUM; +int spi_cs_gpio = GPIO_EEPROM_CS; + +module_param(g_rg_spi_93xx46_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_spi_93xx46_error, int, S_IRUGO | S_IWUSR); +module_param(spi_bus_num, int, S_IRUGO | S_IWUSR); +module_param(spi_cs_gpio, int, S_IRUGO | S_IWUSR); + +#define SPI_93xx46_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_spi_93xx46_debug) { \ + printk(KERN_INFO "[SPI-93xx46][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SPI_93xx46_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_spi_93xx46_error) { \ + printk(KERN_ERR "[SPI-93xx46][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct eeprom_93xx46_platform_data eeprom_data = { + .flags = EE_ADDR16, + .quirks = EEPROM_93XX46_QUIRK_SINGLE_WORD_READ, +}; + +struct spi_board_info eeprom_93xx46_info __initdata = { + .modalias = "rg_93xx46", + .max_speed_hz = DEFAULT_SPI_HZ, + .bus_num = DEFAULT_SPI_BUS_NUM, + .chip_select = DEFAULT_SPI_CS_NUM, + .mode = SPI_MODE_0 | SPI_CS_HIGH, + .controller_data = (void *)GPIO_EEPROM_CS, + .platform_data = &eeprom_data, +}; + +static struct spi_device *g_spi_device; + +static int __init rg_spi_93xx46_init(void) +{ + struct spi_master *master; + + SPI_93xx46_DEBUG_VERBOSE("Enter.\n"); + + eeprom_93xx46_info.bus_num = spi_bus_num; + eeprom_93xx46_info.controller_data = (void *)(long)spi_cs_gpio; + master = spi_busnum_to_master(eeprom_93xx46_info.bus_num); + if (!master) { + SPI_93xx46_DEBUG_ERROR("get bus_num %u spi master failed.\n", + eeprom_93xx46_info.bus_num); + return -EINVAL; + } + + g_spi_device = spi_new_device(master, &eeprom_93xx46_info); + put_device(&master->dev); + if (!g_spi_device) { + SPI_93xx46_DEBUG_ERROR("register spi new device failed.\n"); + return -EPERM; + } + + if (g_rg_spi_93xx46_debug) { + dev_info(&g_spi_device->dev, "register %u bus_num spi 93xx46 eeprom success\n", + eeprom_93xx46_info.bus_num); + } + + return 0; +} + +static void __exit rg_spi_93xx46_exit(void) +{ + spi_unregister_device(g_spi_device); + + if (g_rg_spi_93xx46_debug) { + dev_info(&g_spi_device->dev, "unregister spi 93xx46 eeprom success\n"); + } + + return; +} + +module_init(rg_spi_93xx46_init); +module_exit(rg_spi_93xx46_exit); + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("create 93xx46 eeprom device"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio.c new file mode 100644 index 000000000000..0deb57b06eb9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio.c @@ -0,0 +1,477 @@ +/* + * SPI master driver using generic bitbanged GPIO + * + * Copyright (C) 2006,2008 David Brownell + * Copyright (C) 2017 Linus Walleij + * + * 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 +#include +#include + +/* + * This bitbanging SPI master driver should help make systems usable + * when a native hardware SPI engine is not available, perhaps because + * its driver isn't yet working or because the I/O pins it requires + * are used for other purposes. + * + * platform_device->driver_data ... points to spi_gpio + * + * spi->controller_state ... reserved for bitbang framework code + * spi->controller_data ... holds chipselect GPIO + * + * spi->master->dev.driver_data ... points to spi_gpio->bitbang + */ + +struct spi_gpio { + struct spi_bitbang bitbang; + struct spi_gpio_platform_data pdata; + struct platform_device *pdev; + struct gpio_desc *sck; + struct gpio_desc *miso; + struct gpio_desc *mosi; + struct gpio_desc **cs_gpios; + bool has_cs; +}; + +/*----------------------------------------------------------------------*/ + +/* + * Because the overhead of going through four GPIO procedure calls + * per transferred bit can make performance a problem, this code + * is set up so that you can use it in either of two ways: + * + * - The slow generic way: set up platform_data to hold the GPIO + * numbers used for MISO/MOSI/SCK, and issue procedure calls for + * each of them. This driver can handle several such busses. + * + * - The quicker inlined way: only helps with platform GPIO code + * that inlines operations for constant GPIOs. This can give + * you tight (fast!) inner loops, but each such bus needs a + * new driver. You'll define a new C file, with Makefile and + * Kconfig support; the C code can be a total of six lines: + * + * #define DRIVER_NAME "myboard_spi2" + * #define SPI_MISO_GPIO 119 + * #define SPI_MOSI_GPIO 120 + * #define SPI_SCK_GPIO 121 + * #define SPI_N_CHIPSEL 4 + * #include "spi-gpio.c" + */ + +#ifndef DRIVER_NAME +#define DRIVER_NAME "rg_spi_gpio" + +#define GENERIC_BITBANG /* vs tight inlines */ + +#endif + +/*----------------------------------------------------------------------*/ + +static inline struct spi_gpio *__pure +spi_to_spi_gpio(const struct spi_device *spi) +{ + const struct spi_bitbang *bang; + struct spi_gpio *spi_gpio; + + bang = spi_master_get_devdata(spi->master); + spi_gpio = container_of(bang, struct spi_gpio, bitbang); + return spi_gpio; +} + +static inline struct spi_gpio_platform_data *__pure +spi_to_pdata(const struct spi_device *spi) +{ + return &spi_to_spi_gpio(spi)->pdata; +} + +/* These helpers are in turn called by the bitbang inlines */ +static inline void setsck(const struct spi_device *spi, int is_on) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + gpiod_set_value_cansleep(spi_gpio->sck, is_on); +} + +static inline void setmosi(const struct spi_device *spi, int is_on) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + gpiod_set_value_cansleep(spi_gpio->mosi, is_on); +} + +static inline int getmiso(const struct spi_device *spi) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + if (spi->mode & SPI_3WIRE) + return !!gpiod_get_value_cansleep(spi_gpio->mosi); + else + return !!gpiod_get_value_cansleep(spi_gpio->miso); +} + +/* + * NOTE: this clocks "as fast as we can". It "should" be a function of the + * requested device clock. Software overhead means we usually have trouble + * reaching even one Mbit/sec (except when we can inline bitops), so for now + * we'll just assume we never need additional per-bit slowdowns. + */ +#define spidelay(nsecs) do {} while (0) + +#include "spi-bitbang-txrx.h" + +/* + * These functions can leverage inline expansion of GPIO calls to shrink + * costs for a txrx bit, often by factors of around ten (by instruction + * count). That is particularly visible for larger word sizes, but helps + * even with default 8-bit words. + * + * REVISIT overheads calling these functions for each word also have + * significant performance costs. Having txrx_bufs() calls that inline + * the txrx_word() logic would help performance, e.g. on larger blocks + * used with flash storage or MMC/SD. There should also be ways to make + * GCC be less stupid about reloading registers inside the I/O loops, + * even without inlined GPIO calls; __attribute__((hot)) on GCC 4.3? + */ + +static u32 spi_gpio_txrx_word_mode0(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits); +} + +static u32 spi_gpio_txrx_word_mode1(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits); +} + +static u32 spi_gpio_txrx_word_mode2(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits); +} + +static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits); +} + +/* + * These functions do not call setmosi or getmiso if respective flag + * (SPI_MASTER_NO_RX or SPI_MASTER_NO_TX) is set, so they are safe to + * call when such pin is not present or defined in the controller. + * A separate set of callbacks is defined to get highest possible + * speed in the generic case (when both MISO and MOSI lines are + * available), as optimiser will remove the checks when argument is + * constant. + */ + +static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + flags = spi->master->flags; + return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits); +} + +static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + flags = spi->master->flags; + return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits); +} + +static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + flags = spi->master->flags; + return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits); +} + +static u32 spi_gpio_spec_txrx_word_mode3(struct spi_device *spi, + unsigned nsecs, u32 word, u8 bits, unsigned flags) +{ + flags = spi->master->flags; + return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits); +} + +/*----------------------------------------------------------------------*/ + +static void spi_gpio_chipselect(struct spi_device *spi, int is_active) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + /* set initial clock line level */ + if (is_active) + gpiod_set_value_cansleep(spi_gpio->sck, spi->mode & SPI_CPOL); + + /* Drive chip select line, if we have one */ + if (spi_gpio->has_cs) { + struct gpio_desc *cs = spi_gpio->cs_gpios[spi->chip_select]; + + /* SPI chip selects are normally active-low */ + gpiod_set_value_cansleep(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active); + } +} + +static int spi_gpio_setup(struct spi_device *spi) +{ + struct gpio_desc *cs; + int status = 0; + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + /* + * The CS GPIOs have already been + * initialized from the descriptor lookup. + */ + cs = spi_gpio->cs_gpios[spi->chip_select]; + if (!spi->controller_state && cs) + status = gpiod_direction_output(cs, + !(spi->mode & SPI_CS_HIGH)); + + if (!status) + status = spi_bitbang_setup(spi); + + return status; +} + +static int spi_gpio_set_direction(struct spi_device *spi, bool output) +{ + struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); + + if (output) + return gpiod_direction_output(spi_gpio->mosi, 1); + else + return gpiod_direction_input(spi_gpio->mosi); +} + +static void spi_gpio_cleanup(struct spi_device *spi) +{ + spi_bitbang_cleanup(spi); +} + +/* + * It can be convenient to use this driver with pins that have alternate + * functions associated with a "native" SPI controller if a driver for that + * controller is not available, or is missing important functionality. + * + * On platforms which can do so, configure MISO with a weak pullup unless + * there's an external pullup on that signal. That saves power by avoiding + * floating signals. (A weak pulldown would save power too, but many + * drivers expect to see all-ones data as the no slave "response".) + */ +static int spi_gpio_request(struct device *dev, + struct spi_gpio *spi_gpio, + unsigned int num_chipselects, + u16 *mflags) +{ + int i; + + spi_gpio->mosi = devm_gpiod_get_optional(dev, "mosi", GPIOD_OUT_LOW); + if (IS_ERR(spi_gpio->mosi)) + return PTR_ERR(spi_gpio->mosi); + if (!spi_gpio->mosi) + /* HW configuration without MOSI pin */ + *mflags |= SPI_MASTER_NO_TX; + + spi_gpio->miso = devm_gpiod_get_optional(dev, "miso", GPIOD_IN); + if (IS_ERR(spi_gpio->miso)) + return PTR_ERR(spi_gpio->miso); + /* + * No setting SPI_MASTER_NO_RX here - if there is only a MOSI + * pin connected the host can still do RX by changing the + * direction of the line. + */ + + spi_gpio->sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); + if (IS_ERR(spi_gpio->sck)) + return PTR_ERR(spi_gpio->sck); + + for (i = 0; i < num_chipselects; i++) { + spi_gpio->cs_gpios[i] = devm_gpiod_get_index(dev, "cs", + i, GPIOD_OUT_HIGH); + if (IS_ERR(spi_gpio->cs_gpios[i])) + return PTR_ERR(spi_gpio->cs_gpios[i]); + } + + return 0; +} + +#ifdef CONFIG_OF +static const struct of_device_id spi_gpio_dt_ids[] = { + { .compatible = "rg-spi-gpio" }, + {} +}; +MODULE_DEVICE_TABLE(of, spi_gpio_dt_ids); + +static int spi_gpio_probe_dt(struct platform_device *pdev) +{ + int ret; + u32 tmp; + struct spi_gpio_platform_data *pdata; + struct device_node *np = pdev->dev.of_node; + const struct of_device_id *of_id = + of_match_device(spi_gpio_dt_ids, &pdev->dev); + + if (!of_id) + return 0; + + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + ret = of_property_read_u32(np, "num-chipselects", &tmp); + if (ret < 0) { + dev_err(&pdev->dev, "num-chipselects property not found\n"); + goto error_free; + } + + pdata->num_chipselect = tmp; + pdev->dev.platform_data = pdata; + + return 1; + +error_free: + devm_kfree(&pdev->dev, pdata); + return ret; +} +#else +static inline int spi_gpio_probe_dt(struct platform_device *pdev) +{ + return 0; +} +#endif + +static int spi_gpio_probe(struct platform_device *pdev) +{ + int status; + struct spi_master *master; + struct spi_gpio *spi_gpio; + struct spi_gpio_platform_data *pdata; + u16 master_flags = 0; + bool use_of = 0; + + status = spi_gpio_probe_dt(pdev); + if (status < 0) + return status; + if (status > 0) + use_of = 1; + + pdata = dev_get_platdata(&pdev->dev); +#ifdef GENERIC_BITBANG + if (!pdata || (!use_of && !pdata->num_chipselect)) + return -ENODEV; +#endif + + master = spi_alloc_master(&pdev->dev, sizeof(*spi_gpio)); + if (!master) + return -ENOMEM; + + spi_gpio = spi_master_get_devdata(master); + + spi_gpio->cs_gpios = devm_kcalloc(&pdev->dev, + pdata->num_chipselect, + sizeof(*spi_gpio->cs_gpios), + GFP_KERNEL); + if (!spi_gpio->cs_gpios) + return -ENOMEM; + + platform_set_drvdata(pdev, spi_gpio); + + /* Determine if we have chip selects connected */ + spi_gpio->has_cs = !!pdata->num_chipselect; + + spi_gpio->pdev = pdev; + if (pdata) + spi_gpio->pdata = *pdata; + + status = spi_gpio_request(&pdev->dev, spi_gpio, + pdata->num_chipselect, &master_flags); + if (status) + return status; + + master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32); + master->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL | SPI_CS_HIGH; + master->flags = master_flags; + master->bus_num = pdev->id; + /* The master needs to think there is a chipselect even if not connected */ + master->num_chipselect = spi_gpio->has_cs ? pdata->num_chipselect : 1; + master->setup = spi_gpio_setup; + master->cleanup = spi_gpio_cleanup; + + if (pdev->dev.of_node) { + master->dev.of_node = pdev->dev.of_node; + } + + spi_gpio->bitbang.master = master; + spi_gpio->bitbang.chipselect = spi_gpio_chipselect; + spi_gpio->bitbang.set_line_direction = spi_gpio_set_direction; + + if ((master_flags & SPI_MASTER_NO_TX) == 0) { + spi_gpio->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_txrx_word_mode0; + spi_gpio->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_txrx_word_mode1; + spi_gpio->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_txrx_word_mode2; + spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_txrx_word_mode3; + } else { + spi_gpio->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_spec_txrx_word_mode0; + spi_gpio->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_spec_txrx_word_mode1; + spi_gpio->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_spec_txrx_word_mode2; + spi_gpio->bitbang.txrx_word[SPI_MODE_3] = spi_gpio_spec_txrx_word_mode3; + } + spi_gpio->bitbang.setup_transfer = spi_bitbang_setup_transfer; + + status = spi_bitbang_start(&spi_gpio->bitbang); + if (status) + spi_master_put(master); + + return status; +} + +static int spi_gpio_remove(struct platform_device *pdev) +{ + struct spi_gpio *spi_gpio; + struct spi_gpio_platform_data *pdata; + + spi_gpio = platform_get_drvdata(pdev); + pdata = dev_get_platdata(&pdev->dev); + + /* stop() unregisters child devices too */ + spi_bitbang_stop(&spi_gpio->bitbang); + + spi_master_put(spi_gpio->bitbang.master); + + return 0; +} + +MODULE_ALIAS("platform:" DRIVER_NAME); + +static struct platform_driver spi_gpio_driver = { + .driver = { + .name = DRIVER_NAME, + .of_match_table = of_match_ptr(spi_gpio_dt_ids), + }, + .probe = spi_gpio_probe, + .remove = spi_gpio_remove, +}; +module_platform_driver(spi_gpio_driver); + +MODULE_DESCRIPTION("SPI master driver using generic bitbanged GPIO "); +MODULE_AUTHOR("David Brownell"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio_device.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio_device.c new file mode 100644 index 000000000000..0c5adfaa2f4e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_spi_gpio_device.c @@ -0,0 +1,150 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define DEFAULT_GPIO_SCK (67) +#define DEFAULT_GPIO_MISO (32) +#define DEFAULT_GPIO_MOSI (65) +#define DEFAULT_GPIO_CS (6) +#define DEFAULT_SPI_BUS (0) + +static int sck = DEFAULT_GPIO_SCK; +module_param(sck, int, S_IRUGO | S_IWUSR); + +static int miso = DEFAULT_GPIO_MISO; +module_param(miso, int, S_IRUGO | S_IWUSR); + +static int mosi = DEFAULT_GPIO_MOSI; +module_param(mosi, int, S_IRUGO | S_IWUSR); + +static int cs = DEFAULT_GPIO_CS; +module_param(cs, int, S_IRUGO | S_IWUSR); + +static int bus = DEFAULT_SPI_BUS; +module_param(bus, int, S_IRUGO | S_IWUSR); + +static int g_rg_spi_gpio_device_debug = 0; +static int g_rg_spi_gpio_device_error = 0; + +module_param(g_rg_spi_gpio_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_spi_gpio_device_error, int, S_IRUGO | S_IWUSR); + +static char gpiod_lookup_table_devid[64]; + +#define RG_SPI_GPIO_DEVICE_VERBOSE(fmt, args...) do { \ + if (g_rg_spi_gpio_device_debug) { \ + printk(KERN_INFO "[RG_SPI_GPIO_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_SPI_GPIO_DEVICE_ERROR(fmt, args...) do { \ + if (g_rg_spi_gpio_device_error) { \ + printk(KERN_ERR "[RG_SPI_GPIO_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static struct gpiod_lookup_table rg_spi_gpio_table = { + .table = { + GPIO_LOOKUP("rg_gpio_d1500", DEFAULT_GPIO_SCK, + "sck", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("rg_gpio_d1500", DEFAULT_GPIO_MOSI, + "mosi", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("rg_gpio_d1500", DEFAULT_GPIO_MISO, + "miso", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("rg_gpio_d1500", DEFAULT_GPIO_CS, + "cs", GPIO_ACTIVE_HIGH), + { }, + }, +}; + +static struct spi_gpio_platform_data spi_pdata = { + .num_chipselect = 1, +}; + +static void spi_gpio_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_spi_gpio_device = { + .name = "rg_spi_gpio", + .num_resources = 0, + .id = -1, + + .dev = { + .platform_data = &spi_pdata, + .release = spi_gpio_release, + } +}; + +static void rg_spi_gpio_table_devid_name_set(void) { + int size; + + size = sizeof(gpiod_lookup_table_devid); + rg_spi_gpio_device.id = bus; + + memset(gpiod_lookup_table_devid, 0, size); + switch (bus) { + case PLATFORM_DEVID_NONE: + snprintf(gpiod_lookup_table_devid, size, "%s", rg_spi_gpio_device.name); + break; + case PLATFORM_DEVID_AUTO: + snprintf(gpiod_lookup_table_devid, size, "%s.%d.auto", rg_spi_gpio_device.name, bus); + break; + default: + snprintf(gpiod_lookup_table_devid, size, "%s.%d", rg_spi_gpio_device.name, bus); + break; + } + + rg_spi_gpio_table.dev_id = gpiod_lookup_table_devid; + return ; +} +static int __init rg_spi_gpio_device_init(void) +{ + int err; + struct gpiod_lookup *p; + + RG_SPI_GPIO_DEVICE_VERBOSE("enter!\n"); + rg_spi_gpio_table.table[0].chip_hwnum = sck; + rg_spi_gpio_table.table[1].chip_hwnum = mosi; + rg_spi_gpio_table.table[2].chip_hwnum = miso; + rg_spi_gpio_table.table[3].chip_hwnum = cs; + rg_spi_gpio_table_devid_name_set(); + RG_SPI_GPIO_DEVICE_VERBOSE("spi gpi device table bus[%d] dev id[%s]\n", bus, rg_spi_gpio_table.dev_id); + for (p = &rg_spi_gpio_table.table[0]; p->key; p++) { + RG_SPI_GPIO_DEVICE_VERBOSE("con_id:%s gpio:%d\n", p->con_id, p->chip_hwnum); + } + + gpiod_add_lookup_table(&rg_spi_gpio_table); + err = platform_device_register(&rg_spi_gpio_device); + if (err < 0) { + printk(KERN_ERR "register spi gpio device fail(%d). \n", err); + gpiod_remove_lookup_table(&rg_spi_gpio_table); + return -1; + } + + return 0; +} + +static void __exit rg_spi_gpio_device_exit(void) +{ + RG_SPI_GPIO_DEVICE_VERBOSE("enter!\n"); + platform_device_unregister(&rg_spi_gpio_device); + gpiod_remove_lookup_table(&rg_spi_gpio_table); +} + +module_init(rg_spi_gpio_device_init); +module_exit(rg_spi_gpio_device_exit); +MODULE_DESCRIPTION("SPI GPIO Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_tps53622.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_tps53622.c new file mode 100644 index 000000000000..8a14e3a8d114 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_tps53622.c @@ -0,0 +1,120 @@ +/* + * Hardware monitoring driver for Texas Instruments TPS53622 + * + * Copyright (c) 2017 Ruijie Networks. All rights reserved. + * + * 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 "rg_pmbus.h" + +#define TPS53622_PROT_VR12_5MV 0x01 /* VR12.0 mode, 5-mV DAC */ +#define TPS53622_PROT_VR12_5_10MV 0x02 /* VR12.5 mode, 10-mV DAC */ +#define TPS53622_PROT_VR13_10MV 0x04 /* VR13.0 mode, 10-mV DAC */ +#define TPS53622_PROT_IMVP8_5MV 0x05 /* IMVP8 mode, 5-mV DAC */ +#define TPS53622_PROT_VR13_5MV 0x07 /* VR13.0 mode, 5-mV DAC */ +#define TPS53622_PAGE_NUM 2 + +static int tps53622_identify(struct i2c_client *client, + struct pmbus_driver_info *info) +{ + u8 vout_params; + int ret, i; + + /* Read the register with VOUT scaling value.*/ + for (i = 0; i < TPS53622_PAGE_NUM; i++) { + ret = rg_pmbus_read_byte_data(client, i, PMBUS_VOUT_MODE); + if (ret < 0) + return ret; + + vout_params = ret & GENMASK(4, 0); + + switch (vout_params) { + case TPS53622_PROT_VR13_10MV: + case TPS53622_PROT_VR12_5_10MV: + info->vrm_version[i] = vr13; + break; + case TPS53622_PROT_VR13_5MV: + case TPS53622_PROT_VR12_5MV: + case TPS53622_PROT_IMVP8_5MV: + info->vrm_version[i] = vr12; + break; + default: + return -EINVAL; + } + } + + return 0; + +} + +static struct pmbus_driver_info tps53622_info = { + .pages = TPS53622_PAGE_NUM, + .format[PSC_VOLTAGE_IN] = linear, + .format[PSC_VOLTAGE_OUT] = vid, + .format[PSC_TEMPERATURE] = linear, + .format[PSC_CURRENT_OUT] = linear, + .format[PSC_POWER] = linear, + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_POUT, + .func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | + PMBUS_HAVE_POUT, + .identify = tps53622_identify, +}; + +static int tps53622_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct pmbus_driver_info *info; + + info = devm_kmemdup(&client->dev, &tps53622_info, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + return rg_pmbus_do_probe(client, id, info); +} + +static const struct i2c_device_id tps53622_id[] = { + {"rg_tps53622", 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, tps53622_id); + +static const struct of_device_id tps53622_of_match[] = { + {.compatible = "ruijie,rg_tps53622"}, + {} +}; +MODULE_DEVICE_TABLE(of, tps53622_of_match); + +static struct i2c_driver tps53622_driver = { + .driver = { + .name = "rg_tps53622", + .of_match_table = of_match_ptr(tps53622_of_match), + }, + .probe = tps53622_probe, + .remove = rg_pmbus_do_remove, + .id_table = tps53622_id, +}; + +module_i2c_driver(tps53622_driver); + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("PMBus driver for Texas Instruments TPS53622"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ucd9000.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ucd9000.c new file mode 100644 index 000000000000..44821c5db7ba --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_ucd9000.c @@ -0,0 +1,294 @@ +/* + * 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 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,152) +#include +#else +#include +#endif +#include +#include "rg_pmbus.h" + +enum chips { ucd9000, ucd90120, ucd90124, ucd90160, 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 +#define UCD9000_RETRY_SLEEP_TIME (10000) /* 10ms */ +#define UCD9000_RETRY_TIME (10) +#define RG_DEV_NAME_MAX_LEN (64) + +int g_rg_ucd9000_debug = 0; +int g_rg_ucd9000_error = 0; + +module_param(g_rg_ucd9000_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_ucd9000_error, int, S_IRUGO | S_IWUSR); + +#define RG_UDC9000_VERBOSE(fmt, args...) do { \ + if (g_rg_ucd9000_debug) { \ + printk(KERN_INFO "[RG_UCD9000][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_UDC9000_ERROR(fmt, args...) do { \ + if (g_rg_ucd9000_error) { \ + printk(KERN_ERR "[RG_UCD9000][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +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 rg_i2c_smbus_read_block_data(const struct i2c_client *client, u8 command, u8 *values) +{ + int rv, i; + for(i = 0; i < UCD9000_RETRY_TIME; i++) { + rv = i2c_smbus_read_block_data(client, command, values); + if(rv >= 0){ + return rv; + } + usleep_range(UCD9000_RETRY_SLEEP_TIME, UCD9000_RETRY_SLEEP_TIME + 1); + } + RG_UDC9000_ERROR("read_block_data failed. nr:%d, addr:0x%x, reg:0x%x, rv:%d.", + client->adapter->nr, client->addr, command, rv); + return rv; +} + +static int ucd9000_get_fan_config(struct i2c_client *client, int fan) +{ + int fan_config = 0; + struct ucd9000_data *data + = to_ucd9000_data(rg_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[] = { + {"rg_ucd9000", ucd9000}, + {"rg_ucd90120", ucd90120}, + {"rg_ucd90124", ucd90124}, + {"rg_ucd90160", ucd90160}, + {"rg_ucd9090", ucd9090}, + {"rg_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]; + u8 rg_device_name[RG_DEV_NAME_MAX_LEN]; + 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 = rg_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); + + memset(rg_device_name, 0, sizeof(rg_device_name)); + snprintf(rg_device_name, sizeof(rg_device_name), "rg_%s", block_buffer); + + for (mid = ucd9000_id; mid->name[0]; mid++) { + if (!strncasecmp(mid->name, rg_device_name, 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 = rg_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 = rg_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 rg_pmbus_do_probe(client, mid, info); +} + +/* This is the driver that will be inserted */ +static struct i2c_driver ucd9000_driver = { + .driver = { + .name = "rg_ucd9000", + }, + .probe = ucd9000_probe, + .remove = rg_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/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.c new file mode 100644 index 000000000000..5e00621a97d1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.c @@ -0,0 +1,1041 @@ +/* + * Copyright(C) 2016 Ruijie Network. All rights reserved. + * + * rg_wdt.c + * ko for watchdog function + * Original Author: sonic_rd@ruijie.com.cn 2020-09-28 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rg_wdt.h" + +#define GPIO_FEED_WDT_MODE (1) +#define LOGIC_FEED_WDT_MODE (2) + +#define SYMBOL_I2C_DEV_MODE (1) +#define SYMBOL_PCIE_DEV_MODE (2) +#define SYMBOL_IO_DEV_MODE (3) +#define FILE_MODE (4) + +#define ONE_BYTE (1) + +#define WDT_OFF (0) +#define WDT_ON (1) + +#define MS_TO_S (1000) +#define MS_TO_NS (1000 * 1000) + +#define MAX_REG_VAL (255) + +extern int i2c_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int i2c_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int pcie_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int pcie_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int io_device_func_write(const char *path, uint32_t offset, uint8_t *buf, size_t count); +extern int io_device_func_read(const char *path, uint32_t offset, uint8_t *buf, size_t count); + +int g_rg_wdt_debug = 0; +int g_rg_wdt_error = 0; + +module_param(g_rg_wdt_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_wdt_error, int, S_IRUGO | S_IWUSR); + +#define WDT_VERBOSE(fmt, args...) do { \ + if (g_rg_wdt_debug) { \ + printk(KERN_INFO "[WDT][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define WDT_ERROR(fmt, args...) do { \ + if (g_rg_wdt_error) { \ + printk(KERN_ERR "[WDT][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +enum { + HW_ALGO_TOGGLE, + HW_ALGO_LEVEL, +}; + +enum { + WATCHDOG_DEVICE_TYPE = 0, + HRTIMER_TYPE, + THREAD_TYPE, +}; + +typedef struct rg_wdt_priv_s { + + struct task_struct *thread; + struct hrtimer hrtimer; + ktime_t m_kt; + const char *config_dev_name; + uint8_t config_mode; + uint8_t hw_algo; + uint8_t enable_val; + uint8_t disable_val; + uint8_t enable_mask; + uint8_t priv_func_mode; + uint8_t feed_wdt_type; + uint32_t enable_reg; + uint32_t timeout_cfg_reg; + uint32_t timeleft_cfg_reg; + uint32_t hw_margin; + uint32_t feed_time; + uint32_t timer_accuracy; + gpio_wdt_info_t gpio_wdt; + logic_wdt_info_t logic_wdt; + struct device *dev; + const struct attribute_group *sysfs_group; + uint8_t sysfs_index; + struct mutex update_lock; + struct watchdog_device wdd; +}rg_wdt_priv_t; + +static int wdt_file_read(const char *path, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDONLY, 0); + if (IS_ERR(filp)) { + WDT_ERROR("read open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_read(filp, val, size, &tmp_pos); + if (ret < 0) { + WDT_ERROR("kernel_read failed, path=%s, addr=0x%x, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; +} + +static int wdt_file_write(const char *path, uint32_t pos, uint8_t *val, size_t size) +{ + int ret; + struct file *filp; + loff_t tmp_pos; + + filp = filp_open(path, O_RDWR, 777); + if (IS_ERR(filp)) { + WDT_ERROR("write open failed errno = %ld\r\n", -PTR_ERR(filp)); + filp = NULL; + goto exit; + } + + tmp_pos = (loff_t)pos; + ret = kernel_write(filp, val, size, &tmp_pos); + if (ret < 0) { + WDT_ERROR("kernel_write failed, path=%s, addr=0x%x, size=%ld, ret=%d\r\n", path, pos, size, ret); + goto exit; + } + + vfs_fsync(filp, 1); + filp_close(filp, NULL); + + return ret; + +exit: + if (filp != NULL) { + filp_close(filp, NULL); + } + + return -1; +} + +static int rg_wdt_read(uint8_t mode, const char *path, + uint32_t offset, uint8_t *buf, size_t count) +{ + int ret; + + switch (mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_read(path, offset, buf, count); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_read(path, offset, buf, count); + break; + case SYMBOL_IO_DEV_MODE: + ret = io_device_func_read(path, offset, buf, count); + break; + case FILE_MODE: + ret = wdt_file_read(path, offset, buf, count); + break; + default: + WDT_ERROR("mode %u error, wdt func read failed.\n", mode); + return -EINVAL; + } + + WDT_VERBOSE("wdt func read mode:%u,dev_nam:%s, offset:0x%x, read_val:0x%x, size:%lu.\n", + mode, path, offset, *buf, count); + + return ret; +} + +static int rg_wdt_write(uint8_t mode, const char *path, + uint32_t offset, uint8_t *buf, size_t count) +{ + int ret; + + switch (mode) { + case SYMBOL_I2C_DEV_MODE: + ret = i2c_device_func_write(path, offset, buf, count); + break; + case SYMBOL_PCIE_DEV_MODE: + ret = pcie_device_func_write(path, offset, buf, count); + break; + case SYMBOL_IO_DEV_MODE: + ret = io_device_func_write(path, offset, buf, count); + break; + case FILE_MODE: + ret = wdt_file_write(path, offset, buf, count); + break; + default: + WDT_ERROR("mode %u error, wdt func write failed.\n", mode); + return -EINVAL; + } + + WDT_VERBOSE("wdt func write mode:%u, dev_nam:%s, offset:0x%x, write_val:0x%x, size:%lu.\n", + mode, path, offset, *buf, count); + + return ret; +} + +static int rg_wdt_enable_ctrl(rg_wdt_priv_t *priv, uint8_t flag) +{ + int ret; + uint8_t val; + uint8_t ctrl_val; + + switch (flag) { + case WDT_ON: + ctrl_val = priv->enable_val; + break; + case WDT_OFF: + ctrl_val = priv->disable_val; + break; + default: + WDT_ERROR("unsupport wdt enable ctrl:%u.\n", flag); + return -EINVAL; + } + + ret = rg_wdt_read(priv->priv_func_mode, priv->config_dev_name, + priv->enable_reg, &val, ONE_BYTE); + if (ret < 0) { + dev_err(priv->dev, "read wdt control reg error.\n"); + return ret; + } + + val &= ~priv->enable_mask; + + val |= ctrl_val & priv->enable_mask; + + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->enable_reg, &val, ONE_BYTE); + if (ret < 0) { + dev_err(priv->dev, "write wdt control reg error.\n"); + return ret; + } + + return 0; +} + +static void wdt_hwping(rg_wdt_priv_t *priv) +{ + gpio_wdt_info_t *gpio_wdt; + logic_wdt_info_t *logic_wdt; + uint8_t tmp_val; + int ret; + + if (priv->config_mode == GPIO_FEED_WDT_MODE) { + gpio_wdt = &priv->gpio_wdt; + switch (priv->hw_algo) { + case HW_ALGO_TOGGLE: + gpio_wdt = &priv->gpio_wdt; + gpio_wdt->state = !gpio_wdt->state; + gpio_set_value_cansleep(gpio_wdt->gpio, gpio_wdt->state); + WDT_VERBOSE("gpio toggle wdt work. val:%u\n", gpio_wdt->state); + break; + case HW_ALGO_LEVEL: + gpio_wdt = &priv->gpio_wdt; + /* Pulse */ + gpio_set_value_cansleep(gpio_wdt->gpio, !gpio_wdt->active_low); + udelay(1); + gpio_set_value_cansleep(gpio_wdt->gpio, gpio_wdt->active_low); + WDT_VERBOSE("gpio level wdt work.\n"); + break; + } + } else { + logic_wdt = &priv->logic_wdt; + switch (priv->hw_algo) { + case HW_ALGO_TOGGLE: + logic_wdt->active_val = !logic_wdt->active_val; + ret = rg_wdt_write(logic_wdt->logic_func_mode, logic_wdt->feed_dev_name, + logic_wdt->feed_reg, &logic_wdt->active_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("logic toggle wdt write failed.ret = %d\n", ret); + } + WDT_VERBOSE("logic toggle wdt work.\n"); + break; + case HW_ALGO_LEVEL: + tmp_val = !logic_wdt->active_val; + ret = rg_wdt_write(logic_wdt->logic_func_mode, logic_wdt->feed_dev_name, + logic_wdt->feed_reg, &tmp_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("logic level wdt write first failed.ret = %d\n", ret); + } + udelay(1); + ret = rg_wdt_write(logic_wdt->logic_func_mode, logic_wdt->feed_dev_name, + logic_wdt->feed_reg, &logic_wdt->active_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("logic level wdt write second failed.ret = %d\n", ret); + } + WDT_VERBOSE("logic level wdt work.\n"); + break; + } + } + return; +} + +static enum hrtimer_restart hrtimer_hwping(struct hrtimer *timer) +{ + rg_wdt_priv_t *priv = container_of(timer, rg_wdt_priv_t, hrtimer); + + wdt_hwping(priv); + hrtimer_forward(timer, timer->base->get_time(), priv->m_kt); + return HRTIMER_RESTART; +} + +static int thread_timer_cfg(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct device *dev; + uint32_t hw_margin; + uint32_t feed_time; + uint32_t accuracy; + uint8_t set_time_val; + int ret; + + dev = priv->dev; + + ret = 0; + if (dev->of_node) { + ret += of_property_read_u32(dev->of_node, "feed_time", &priv->feed_time); + if (ret != 0) { + dev_err(dev, "thread Failed to priv dts.\n"); + return -ENXIO; + } + } else { + priv->feed_time = rg_wdt_device->feed_time; + } + WDT_VERBOSE("thread priv->feed_time: %u.\n", priv->feed_time); + + hw_margin = priv->hw_margin; + feed_time = priv->feed_time; + accuracy = priv->timer_accuracy; + + if ((feed_time > (hw_margin / 2)) || (feed_time == 0)) { + dev_err(dev, "thread timer feed_time[%d] should be less than half hw_margin or zero.\n", feed_time); + return -EINVAL; + } + + set_time_val = hw_margin / accuracy; + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->timeout_cfg_reg, &set_time_val, ONE_BYTE); + if (ret < 0) { + dev_err(dev, "set wdt thread timer reg error.\n"); + return ret; + } + return 0; +} + +static int wdt_thread_timer(void *data) +{ + rg_wdt_priv_t *priv = data; + + while (!kthread_should_stop()) { + schedule_timeout_uninterruptible(msecs_to_jiffies(priv->feed_time)); + wdt_hwping(priv); + } + return 0; +} + +static int thread_timer_create(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct task_struct *p; + int ret; + + ret = thread_timer_cfg(priv, rg_wdt_device); + if (ret < 0) { + dev_err(priv->dev, "set wdt thread timer failed.\n"); + return ret; + } + + p = kthread_create(wdt_thread_timer, (void *)priv, "%s", "rg_wdt"); + if (!IS_ERR(p)) { + WDT_VERBOSE("timer thread create success.\n"); + priv->thread = p; + wake_up_process(p); + } else { + dev_err(priv->dev, "timer thread create failed.\n"); + return -ENXIO; + } + + ret = rg_wdt_enable_ctrl(priv, WDT_ON); + if (ret < 0) { + dev_err(priv->dev, "thread enable wdt failed.\n"); + return -ENXIO; + } + + return 0; +} + +static int hrtimer_cfg(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct device *dev; + struct hrtimer *hrtimer; + uint8_t set_time_val; + uint8_t hrtimer_s; + uint32_t hrtimer_ns; + int ret; + uint32_t hw_margin; + uint32_t feed_time; + uint32_t accuracy; + uint32_t max_timeout; + + dev = priv->dev; + + ret = 0; + if (dev->of_node) { + ret += of_property_read_u32(dev->of_node, "feed_time", &priv->feed_time); + if (ret != 0) { + dev_err(dev, "hrtimer Failed to priv dts.\n"); + return -ENXIO; + } + } else { + priv->feed_time = rg_wdt_device->feed_time; + } + WDT_VERBOSE("hrtimer priv->feed_time: %u.\n", priv->feed_time); + + hrtimer = &priv->hrtimer; + hw_margin = priv->hw_margin; + feed_time = priv->feed_time; + accuracy = priv->timer_accuracy; + max_timeout = accuracy * 255; + + if (hw_margin < accuracy || hw_margin > max_timeout) { + dev_err(dev, "hrtimer_hw_margin should be between %u and %u.\n", + accuracy, max_timeout); + return -EINVAL; + } + if ((feed_time > (hw_margin / 2)) || (feed_time == 0)) { + dev_err(dev, "feed_time[%d] should be less than half hw_margin or zeor.\n", feed_time); + return -EINVAL; + } + + hrtimer_s = feed_time / MS_TO_S; + hrtimer_ns = (feed_time % MS_TO_S) * MS_TO_NS; + set_time_val = hw_margin / accuracy; + + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->timeout_cfg_reg, &set_time_val, ONE_BYTE); + if (ret < 0) { + dev_err(dev, "set wdt time reg error.\n"); + return ret; + } + + priv->m_kt = ktime_set(hrtimer_s, hrtimer_ns); + hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer->function = hrtimer_hwping; + hrtimer_start(hrtimer, priv->m_kt, HRTIMER_MODE_REL); + + ret = rg_wdt_enable_ctrl(priv, WDT_ON); + if (ret < 0) { + dev_err(dev, "hrtimer enable wdt failed.\n"); + return -ENXIO; + } + + return 0; +} + +static int rg_wdt_ping(struct watchdog_device *wdd) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + + wdt_hwping(priv); + return 0; +} + +static int rg_wdt_start(struct watchdog_device *wdd) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + int ret; + + ret = rg_wdt_enable_ctrl(priv, WDT_ON); + if (ret < 0) { + WDT_ERROR("start wdt enable failed.\n"); + return -ENXIO; + } + set_bit(WDOG_HW_RUNNING, &wdd->status); + return 0; +} + +static int rg_wdt_stop(struct watchdog_device *wdd) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + int ret; + + ret = rg_wdt_enable_ctrl(priv, WDT_OFF); + if (ret < 0) { + WDT_ERROR("stop wdt enable failed.\n"); + return -ENXIO; + } + clear_bit(WDOG_HW_RUNNING, &wdd->status); + return 0; +} + +static int rg_wdt_set_timeout(struct watchdog_device *wdd, unsigned int t) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + uint32_t timeout_ms; + uint32_t accuracy; + uint8_t set_time_val; + int ret; + + accuracy = priv->timer_accuracy; + timeout_ms = t * 1000; + if (timeout_ms > accuracy * 255) { + WDT_ERROR("set wdt timeout too larger error.timeout_ms:%u\n", timeout_ms); + return -EINVAL; + } + + set_time_val = timeout_ms / accuracy; + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->timeout_cfg_reg, &set_time_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("set wdt timeout reg error, set_time_val:%u ret:%d\n", set_time_val, ret); + return ret; + } + wdd->timeout = t; + + return 0; +} + +static unsigned int rg_wdt_get_timeleft(struct watchdog_device *wdd) +{ + rg_wdt_priv_t *priv = watchdog_get_drvdata(wdd); + unsigned int time_left; + uint32_t accuracy; + uint8_t get_time_val; + int ret; + + accuracy = priv->timer_accuracy; + + ret = rg_wdt_read(priv->priv_func_mode, priv->config_dev_name, + priv->timeleft_cfg_reg, &get_time_val, ONE_BYTE); + if (ret < 0) { + WDT_ERROR("get wdt timeout reg error.ret:%d\n", ret); + return ret; + } + time_left = get_time_val * accuracy / MS_TO_S; + + WDT_VERBOSE("get wdt timeleft %d get_time_val %d accuracy=%d\n", + time_left, get_time_val, accuracy); + return time_left; +} + +static const struct watchdog_info rg_wdt_ident = { + .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, + .firmware_version = 0, + .identity = "CPLD Watchdog", +}; + +static const struct watchdog_ops rg_wdt_ops = { + .owner = THIS_MODULE, + .start = rg_wdt_start, + .stop = rg_wdt_stop, + .ping = rg_wdt_ping, + .set_timeout = rg_wdt_set_timeout, + .get_timeleft = rg_wdt_get_timeleft, +}; + +static int watchdog_device_cfg(rg_wdt_priv_t *priv) +{ + int ret; + uint8_t set_time_val; + + ret = rg_wdt_enable_ctrl(priv, WDT_OFF); + if (ret < 0) { + dev_err(priv->dev, "probe disable wdt failed.\n"); + return -ENXIO; + } + + set_time_val = priv->hw_margin / priv->timer_accuracy; + ret = rg_wdt_write(priv->priv_func_mode, priv->config_dev_name, + priv->timeout_cfg_reg, &set_time_val, ONE_BYTE); + if (ret < 0) { + dev_err(priv->dev, "set wdt time reg error.\n"); + return ret; + } + + watchdog_set_drvdata(&priv->wdd, priv); + + priv->wdd.info = &rg_wdt_ident; + priv->wdd.ops = &rg_wdt_ops; + priv->wdd.bootstatus = 0; + priv->wdd.timeout = priv->hw_margin / MS_TO_S; + priv->wdd.min_timeout = priv->timer_accuracy / MS_TO_S; + priv->wdd.max_timeout = priv->timer_accuracy * MAX_REG_VAL / MS_TO_S; + priv->wdd.parent = priv->dev; + + watchdog_stop_on_reboot(&priv->wdd); + + ret = devm_watchdog_register_device(priv->dev, &priv->wdd); + if (ret != 0) { + dev_err(priv->dev, "cannot register watchdog device (err=%d)\n", ret); + return -ENXIO; + } + + return 0; +} + +static int logic_wdt_init(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct device *dev; + logic_wdt_info_t *logic_wdt; + int ret; + + dev = priv->dev; + logic_wdt = &priv->logic_wdt; + + ret = 0; + if (dev->of_node) { + ret += of_property_read_string(dev->of_node, "feed_dev_name", &logic_wdt->feed_dev_name); + ret += of_property_read_u32(dev->of_node, "feed_reg", &logic_wdt->feed_reg); + ret += of_property_read_u8(dev->of_node, "active_val", &logic_wdt->active_val); + ret += of_property_read_u8(dev->of_node, "logic_func_mode", &logic_wdt->logic_func_mode); + if (ret != 0) { + dev_err(dev, "Failed to logic_wdt dts.\n"); + return -ENXIO; + } + } else { + logic_wdt->feed_dev_name = rg_wdt_device->wdt_config_mode.logic_wdt.feed_dev_name; + logic_wdt->feed_reg = rg_wdt_device->wdt_config_mode.logic_wdt.feed_reg; + logic_wdt->active_val = rg_wdt_device->wdt_config_mode.logic_wdt.active_val; + logic_wdt->logic_func_mode = rg_wdt_device->wdt_config_mode.logic_wdt.logic_func_mode; + } + + logic_wdt->state_val = logic_wdt->active_val; + + WDT_VERBOSE("feed_dev_name:%s, feed_reg:0x%x, active_val:%u, logic_func_mode:%u\n", + logic_wdt->feed_dev_name, logic_wdt->feed_reg, + logic_wdt->active_val, logic_wdt->logic_func_mode); + + return 0; +} + +static int gpio_wdt_init(rg_wdt_priv_t *priv, rg_wdt_device_t *rg_wdt_device) +{ + struct device *dev; + gpio_wdt_info_t *gpio_wdt; + enum of_gpio_flags flags; + uint32_t f = 0; + int ret; + + dev = priv->dev; + gpio_wdt = &priv->gpio_wdt; + + if (dev->of_node) { + gpio_wdt->gpio = of_get_gpio_flags(dev->of_node, 0, &flags); + } else { + gpio_wdt->gpio = rg_wdt_device->wdt_config_mode.gpio_wdt.gpio; + flags = rg_wdt_device->wdt_config_mode.gpio_wdt.flags; + } + if (!gpio_is_valid(gpio_wdt->gpio)) { + dev_err(dev, "gpio is invalid.\n"); + return gpio_wdt->gpio; + } + + gpio_wdt->active_low = flags & OF_GPIO_ACTIVE_LOW; + + if(priv->hw_algo == HW_ALGO_TOGGLE) { + f = GPIOF_IN; + } else { + f = gpio_wdt->active_low ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; + } + + ret = devm_gpio_request_one(dev, gpio_wdt->gpio, f, + dev_name(dev)); + if (ret) { + dev_err(dev, "devm_gpio_request_one failed.\n"); + return ret; + } + + gpio_wdt->state = gpio_wdt->active_low; + gpio_direction_output(gpio_wdt->gpio, gpio_wdt->state); + + WDT_VERBOSE("active_low:%d\n", gpio_wdt->active_low); + return 0; +} + +static ssize_t set_wdt_sysfs_value(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + rg_wdt_priv_t *priv = dev_get_drvdata(dev); + int ret, val; + + val = 0; + sscanf(buf, "%d", &val); + WDT_VERBOSE("set wdt, val:%d.\n", val); + + if (val < 0 || val > 255) { + WDT_ERROR("set wdt val %d failed.\n", val); + return -EINVAL; + } + + mutex_lock(&priv->update_lock); + + ret = rg_wdt_enable_ctrl(priv, val); + if (ret < 0) { + WDT_ERROR("set wdt sysfs value:%u failed.\n", val); + goto fail; + } + + WDT_VERBOSE("set wdt sysfs value:%u successed.\n", val); + mutex_unlock(&priv->update_lock); + return count; + +fail: + mutex_unlock(&priv->update_lock); + return ret; +} + +static ssize_t show_wdt_sysfs_value(struct device *dev, + struct device_attribute *da, char *buf) +{ + rg_wdt_priv_t *priv = dev_get_drvdata(dev); + uint8_t val, status; + int ret; + + mutex_lock(&priv->update_lock); + + ret = rg_wdt_read(priv->priv_func_mode, priv->config_dev_name, + priv->enable_reg, &val, ONE_BYTE); + if (ret < 0) { + dev_err(priv->dev, "read wdt enable reg val error.\n"); + goto fail; + } + + val &= priv->enable_mask; + if (val == priv->enable_val) { + status = WDT_ON; + } else if(val == priv->disable_val) { + status = WDT_OFF; + } else { + WDT_ERROR("enable reg read val not match set val, read val:%u, mask:%u, enable_val:%u, disable_val:%u", + val, priv->enable_mask, priv->enable_val, priv->disable_val); + ret = -EIO; + goto fail; + } + + WDT_VERBOSE("read_val:%u, mask:%u, enable_val:%u, disable_val:%u, status:%u", + val, priv->enable_mask, priv->enable_val, priv->disable_val, status); + + mutex_unlock(&priv->update_lock); + return sprintf(buf, "%u\n", status); + +fail: + mutex_unlock(&priv->update_lock); + return ret; +} + +static SENSOR_DEVICE_ATTR(wdt_status, S_IRUGO | S_IWUSR, show_wdt_sysfs_value, set_wdt_sysfs_value, 0); + +static struct attribute *wdt_sysfs_attrs[] = { + &sensor_dev_attr_wdt_status.dev_attr.attr, + NULL +}; + +static const struct attribute_group wdt_sysfs_group = { + .attrs = wdt_sysfs_attrs, +}; + +struct wdt_attr_match_group { + uint8_t index; + const struct attribute_group *attr_group_ptr; +}; + +static struct wdt_attr_match_group g_wdt_attr_match[] = { + {0, &wdt_sysfs_group}, +}; + +static const struct attribute_group *wdt_get_attr_group(uint32_t index) +{ + int i; + struct wdt_attr_match_group *group; + + for (i = 0; i < ARRAY_SIZE(g_wdt_attr_match); i++) { + group = &g_wdt_attr_match[i]; + if (index == group->index) { + WDT_VERBOSE("get wdt attr, index:%u.\n", index); + return group->attr_group_ptr; + } + } + + return NULL; +} + +static int rg_wdt_probe(struct platform_device *pdev) +{ + rg_wdt_priv_t *priv; + int ret; + const char *algo; + rg_wdt_device_t *rg_wdt_device; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) { + dev_err(&pdev->dev, "devm_kzalloc failed.\n"); + return -ENOMEM; + } + + platform_set_drvdata(pdev, priv); + + if (pdev->dev.of_node) { + ret = 0; + ret += of_property_read_string(pdev->dev.of_node, "config_dev_name", &priv->config_dev_name); + ret += of_property_read_string(pdev->dev.of_node, "hw_algo", &algo); + ret += of_property_read_u8(pdev->dev.of_node, "config_mode", &priv->config_mode); + ret += of_property_read_u8(pdev->dev.of_node, "priv_func_mode", &priv->priv_func_mode); + ret += of_property_read_u8(pdev->dev.of_node, "enable_val", &priv->enable_val); + ret += of_property_read_u8(pdev->dev.of_node, "disable_val", &priv->disable_val); + ret += of_property_read_u8(pdev->dev.of_node, "enable_mask", &priv->enable_mask); + ret += of_property_read_u32(pdev->dev.of_node, "enable_reg", &priv->enable_reg); + ret += of_property_read_u32(pdev->dev.of_node, "timeout_cfg_reg", &priv->timeout_cfg_reg); + ret += of_property_read_u32(pdev->dev.of_node,"hw_margin_ms", &priv->hw_margin); + ret += of_property_read_u8(pdev->dev.of_node,"feed_wdt_type", &priv->feed_wdt_type); + ret += of_property_read_u32(pdev->dev.of_node,"timer_accuracy", &priv->timer_accuracy); + if (ret != 0) { + dev_err(&pdev->dev, "Failed to priv dts.\n"); + return -ENXIO; + } + + priv->sysfs_index = SYSFS_NO_CFG; + of_property_read_u8(pdev->dev.of_node,"sysfs_index", &priv->sysfs_index); + + priv->timeleft_cfg_reg = priv->timeout_cfg_reg; + of_property_read_u32(pdev->dev.of_node,"timeleft_cfg_reg", &priv->timeleft_cfg_reg); + } else { + if (pdev->dev.platform_data == NULL) { + dev_err(&pdev->dev, "Failed to get platform data config.\n"); + return -ENXIO; + } + rg_wdt_device = pdev->dev.platform_data; + priv->config_dev_name = rg_wdt_device->config_dev_name; + algo = rg_wdt_device->hw_algo; + priv->config_mode = rg_wdt_device->config_mode; + priv->priv_func_mode = rg_wdt_device->priv_func_mode; + priv->enable_val = rg_wdt_device->enable_val; + priv->disable_val = rg_wdt_device->disable_val; + priv->enable_mask = rg_wdt_device->enable_mask; + priv->enable_reg = rg_wdt_device->enable_reg; + priv->timeout_cfg_reg = rg_wdt_device->timeout_cfg_reg; + priv->hw_margin = rg_wdt_device->hw_margin; + priv->timer_accuracy = rg_wdt_device->timer_accuracy; + priv->feed_wdt_type = rg_wdt_device->feed_wdt_type; + priv->sysfs_index = rg_wdt_device->sysfs_index; + priv->timeleft_cfg_reg = rg_wdt_device->timeleft_cfg_reg; + } + + if (!strcmp(algo, "toggle")) { + priv->hw_algo = HW_ALGO_TOGGLE; + } else if (!strcmp(algo, "level")) { + priv->hw_algo = HW_ALGO_LEVEL; + } else { + dev_err(&pdev->dev, "hw_algo config error.must be toggle or level.\n"); + return -EINVAL; + } + + WDT_VERBOSE("config_dev_name:%s, config_mode:%u, priv_func_mode:%u, enable_reg:0x%x, timeout_cfg_reg:0x%x\n", + priv->config_dev_name, priv->config_mode, priv->priv_func_mode, priv->enable_reg, priv->timeout_cfg_reg); + WDT_VERBOSE("timeout_cfg_reg:0x%x, enable_val:%u, disable_val:%u, enable_mask:%u, hw_margin:%u, feed_wdt_type:%u\n", + priv->timeleft_cfg_reg, priv->enable_val, priv->disable_val, priv->enable_mask, priv->hw_margin, priv->feed_wdt_type); + + priv->dev = &pdev->dev; + if (priv->config_mode == GPIO_FEED_WDT_MODE) { + ret = gpio_wdt_init(priv, rg_wdt_device); + if (ret < 0) { + dev_err(&pdev->dev, "init gpio mode wdt failed.\n"); + return -ENXIO; + } + } else if (priv->config_mode == LOGIC_FEED_WDT_MODE) { + ret = logic_wdt_init(priv, rg_wdt_device); + if (ret < 0) { + dev_err(&pdev->dev, "init func mode wdt failed.\n"); + return -ENXIO; + } + } else { + dev_err(&pdev->dev, "unsupport %u config_mode, dts configure error.\n", + priv->config_mode); + return -ENXIO; + } + + switch (priv->feed_wdt_type) { + case WATCHDOG_DEVICE_TYPE: + ret = watchdog_device_cfg(priv); + break; + case HRTIMER_TYPE: + ret = hrtimer_cfg(priv, rg_wdt_device); + break; + case THREAD_TYPE: + ret = thread_timer_create(priv, rg_wdt_device); + break; + default: + dev_err(&pdev->dev, "timer type %u unsupport.\n", priv->feed_wdt_type); + return -EINVAL; + } + if (ret < 0) { + dev_err(&pdev->dev, "init timer feed_wdt_type %u failed.\n", priv->feed_wdt_type); + return -ENXIO; + } + + dev_info(&pdev->dev, "register %s mode, config_mode %u, func_mode %u, %u ms overtime wdt success\n", + algo, priv->config_mode, priv->priv_func_mode, priv->hw_margin); + + if (priv->sysfs_index != SYSFS_NO_CFG) { + + priv->sysfs_group = wdt_get_attr_group(priv->sysfs_index); + if (priv->sysfs_group) { + ret = sysfs_create_group(&pdev->dev.kobj, priv->sysfs_group); + if (ret != 0) { + dev_err(&pdev->dev, "sysfs_create_group failed. ret:%d.\n", ret); + return -ENOMEM; + } + dev_info(&pdev->dev, "sysfs create group success\n"); + } else { + dev_err(&pdev->dev, "failed to find %u index wdt, return NULL.\n", priv->sysfs_index); + return -ENOMEM; + } + + mutex_init(&priv->update_lock); + + dev_info(&pdev->dev, "register %u index wdt sysfs success." ,priv->sysfs_index); + } + + return 0; +} + +static void unregister_action(struct platform_device *pdev) +{ + rg_wdt_priv_t *priv = platform_get_drvdata(pdev); + gpio_wdt_info_t *gpio_wdt; + logic_wdt_info_t *logic_wdt; + int ret; + + ret = rg_wdt_enable_ctrl(priv, WDT_OFF); + if (ret < 0) { + dev_err(&pdev->dev, "remove disable wdt failed.\n"); + } + + if (priv->sysfs_index != SYSFS_NO_CFG) { + sysfs_remove_group(&pdev->dev.kobj, priv->sysfs_group); + } + + if (priv->feed_wdt_type == HRTIMER_TYPE) { + hrtimer_cancel(&priv->hrtimer); + } else if (priv->feed_wdt_type == THREAD_TYPE) { + kthread_stop(priv->thread); + priv->thread = NULL; + } else { + WDT_VERBOSE("wdd type, do nothing.\n"); + } + + if (priv->config_mode == GPIO_FEED_WDT_MODE) { + gpio_wdt = &priv->gpio_wdt; + gpio_set_value_cansleep(gpio_wdt->gpio, !gpio_wdt->active_low); + + if (priv->hw_algo == HW_ALGO_TOGGLE) { + gpio_direction_input(gpio_wdt->gpio); + } + } else { + logic_wdt = &priv->logic_wdt; + logic_wdt->state_val = !logic_wdt->state_val; + ret = rg_wdt_write(logic_wdt->logic_func_mode, logic_wdt->feed_dev_name, + logic_wdt->feed_reg, &logic_wdt->state_val, ONE_BYTE); + if (ret < 0) { + dev_err(&pdev->dev, "set wdt control reg error.\n"); + } + } + + return; +} + +static int rg_wdt_remove(struct platform_device *pdev) +{ + WDT_VERBOSE("enter remove wdt.\n"); + unregister_action(pdev); + dev_info(&pdev->dev, "remove wdt finish.\n"); + + return 0; +} + +static void rg_wdt_shutdown(struct platform_device *pdev) +{ + WDT_VERBOSE("enter shutdown wdt.\n"); + unregister_action(pdev); + dev_info(&pdev->dev, "shutdown wdt finish.\n"); + + return; +} + +static const struct of_device_id rg_wdt_dt_ids[] = { + { .compatible = "ruijie,rg_wdt", }, + { } +}; +MODULE_DEVICE_TABLE(of, rg_wdt_dt_ids); + +static struct platform_driver rg_wdt_driver = { + .driver = { + .name = "rg_wdt", + .of_match_table = rg_wdt_dt_ids, + }, + .probe = rg_wdt_probe, + .remove = rg_wdt_remove, + .shutdown = rg_wdt_shutdown, +}; + +#ifdef CONFIG_GPIO_WATCHDOG_ARCH_INITCALL +static int __init rg_wdt_init(void) +{ + return platform_driver_register(&rg_wdt_driver); +} +arch_initcall(rg_wdt_init); +#else +module_platform_driver(rg_wdt_driver); +#endif + +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("watchdog driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.h new file mode 100644 index 000000000000..9c00a27c2838 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_wdt.h @@ -0,0 +1,46 @@ +#ifndef __RG_WDT_H__ +#define __RG_WDT_H__ + +#include + +#define SYSFS_NO_CFG (0xff) + +typedef struct gpio_wdt_info_s { + int gpio; + enum of_gpio_flags flags; + bool active_low; + bool state; +}gpio_wdt_info_t; + +typedef struct logic_wdt_info_s { + const char *feed_dev_name; + uint8_t logic_func_mode; + uint32_t feed_reg; + uint8_t active_val; + uint8_t state_val; +}logic_wdt_info_t; + +typedef struct rg_wdt_device_s { + int device_flag; + const char *config_dev_name; + uint8_t config_mode; + const char *hw_algo; + uint8_t enable_val; + uint8_t disable_val; + uint8_t enable_mask; + uint8_t priv_func_mode; + uint8_t feed_wdt_type; + uint32_t enable_reg; + uint32_t timeout_cfg_reg; + uint32_t timeleft_cfg_reg; + uint32_t hw_margin; + uint32_t feed_time; + uint32_t timer_accuracy; + union { + gpio_wdt_info_t gpio_wdt; + logic_wdt_info_t logic_wdt; + } wdt_config_mode; + uint8_t sysfs_index; +} rg_wdt_device_t; + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_xdpe132g5c.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_xdpe132g5c.c new file mode 100644 index 000000000000..4ae5faf4c544 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/rg_xdpe132g5c.c @@ -0,0 +1,574 @@ +/* + * xdpe132g5c_i2c_drv.c + * + * This module create sysfs to set AVS and create hwmon to get out power + * through xdpe132g5c I2C address. + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-09-17 Initial version + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RG_I2C_RETRY_SLEEP_TIME (10000) /* 10ms */ +#define RG_I2C_RETRY_TIME (10) +#define RG_XDPE_I2C_PAGE_ADDR (0xff) +#define RG_XDPE_I2C_VOUT_MODE (0x40) +#define RG_XDPE_I2C_VOUT_COMMAND (0x42) +#define RG_XDPE_I2C_VOUT_PAGE (0x06) +#define RG_XDPE_VOUT_MAX_THRESHOLD ((0xFFFF * 1000L * 1000L) / (256)) +#define RG_XDPE_VOUT_MIN_THRESHOLD (0) + +static int g_rg_xdpe_debug = 0; +static int g_rg_xdpe_error = 0; + +module_param(g_rg_xdpe_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_xdpe_error, int, S_IRUGO | S_IWUSR); + +#define RG_XDPE_VERBOSE(fmt, args...) do { \ + if (g_rg_xdpe_debug) { \ + printk(KERN_INFO "[RG_XDPE][VER][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_XDPE_ERROR(fmt, args...) do { \ + if (g_rg_xdpe_error) { \ + printk(KERN_ERR "[RG_XDPE][ERR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct xdpe_data { + struct i2c_client *client; + struct device *hwmon_dev; + struct mutex update_lock; + long vout_max; + long vout_min; +}; + +typedef struct xdpe_vout_data_s { + u8 vout_mode; + int vout_precision; +} xdpe_vout_data_t; + +static xdpe_vout_data_t g_xdpe_vout_group[] = { + {.vout_mode = 0x18, .vout_precision = 256}, + {.vout_mode = 0x17, .vout_precision = 512}, + {.vout_mode = 0x16, .vout_precision = 1024}, + {.vout_mode = 0x15, .vout_precision = 2048}, + {.vout_mode = 0x14, .vout_precision = 4096}, +}; + +static s32 rg_i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command) +{ + int i; + s32 ret; + + for (i = 0; i < RG_I2C_RETRY_TIME; i++) { + ret = i2c_smbus_read_byte_data(client, command); + if (ret >= 0) { + return ret; + } + usleep_range(RG_I2C_RETRY_SLEEP_TIME, RG_I2C_RETRY_SLEEP_TIME + 1); + } + return ret; +} + +static s32 rg_i2c_smbus_write_byte_data(const struct i2c_client *client, u8 command, u8 value) +{ + int i; + s32 ret; + + for (i = 0; i < RG_I2C_RETRY_TIME; i++) { + ret = i2c_smbus_write_byte_data(client, command, value); + if (ret >= 0) { + return ret; + } + usleep_range(RG_I2C_RETRY_SLEEP_TIME, RG_I2C_RETRY_SLEEP_TIME + 1); + } + return ret; +} + +static s32 rg_i2c_smbus_read_word_data(const struct i2c_client *client, u8 command) +{ + int i; + s32 ret; + + for (i = 0; i < RG_I2C_RETRY_TIME; i++) { + ret = i2c_smbus_read_word_data(client, command); + if (ret >= 0) { + return ret; + } + usleep_range(RG_I2C_RETRY_SLEEP_TIME, RG_I2C_RETRY_SLEEP_TIME + 1); + } + return ret; +} + +static s32 rg_i2c_smbus_write_word_data(const struct i2c_client *client, u8 command, + u16 value) +{ + int i; + s32 ret; + + for (i = 0; i < RG_I2C_RETRY_TIME; i++) { + ret = i2c_smbus_write_word_data(client, command, value); + if (ret >= 0) { + return ret; + } + usleep_range(RG_I2C_RETRY_SLEEP_TIME, RG_I2C_RETRY_SLEEP_TIME + 1); + } + return ret; +} + +static long calc_power_linear11_data(int data) +{ + s16 exponent; + s32 mantissa; + long val; + + exponent = ((s16)data) >> 11; + mantissa = ((s16)((data & 0x7ff) << 5)) >> 5; + val = mantissa; + val = val * 1000L * 1000L; + + if (exponent >= 0) { + val <<= exponent; + } else { + val >>= -exponent; + } + return val; +} + +static int read_xdpe_power_value(const struct i2c_client *client, u8 page, u8 reg, long *value) +{ + int ret, data; + + ret = rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, page); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: set xdpe page%u failed, ret: %d\n", client->adapter->nr, + client->addr, page, ret); + return ret; + } + data = rg_i2c_smbus_read_word_data(client, reg); + if (data < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe page%u reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, page, reg, data); + return data; + } + *value = calc_power_linear11_data(data); + RG_XDPE_VERBOSE("%d-%04x: page%u reg: 0x%x rd_data: 0x%x, decode linear11 value: %ld\n", + client->adapter->nr, client->addr, page, reg, data, *value); + return 0; +} + +static ssize_t xdpe_power_value_show(struct device *dev, struct device_attribute *da, + char *buf) +{ + int ret, ori_page; + u16 sensor_h, sensor_l; + u8 page, reg; + struct sensor_device_attribute *attr; + struct i2c_client *client; + struct xdpe_data *data; + long value1, value2; + + data = dev_get_drvdata(dev); + client = data->client; + attr = to_sensor_dev_attr(da); + sensor_h = ((attr->index) >> 16) & 0xffff; + sensor_l = (attr->index) & 0xffff; + + mutex_lock(&data->update_lock); + + ori_page = rg_i2c_smbus_read_byte_data(client, RG_XDPE_I2C_PAGE_ADDR); + if (ori_page < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe origin page failed, ret: %d\n", client->adapter->nr, + client->addr, ori_page); + mutex_unlock(&data->update_lock); + return ori_page; + } + value1 = 0; + value2 = 0; + + if (sensor_h) { + page = (sensor_h >> 8) & 0xff; + reg = sensor_h & 0xff; + ret = read_xdpe_power_value(client, page, reg, &value1); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe sensor high sensor page%u reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, page, reg, ret); + goto error; + } + RG_XDPE_VERBOSE("%d-%04x: read xdpe sensor high sensor page%u reg: 0x%x success, value: %ld\n", + client->adapter->nr, client->addr, page, reg, value1); + } + + page = (sensor_l >> 8) & 0xff; + reg = sensor_l & 0xff; + ret = read_xdpe_power_value(client, page, reg, &value2); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe sensor low sensor page%u reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, page, reg, ret); + goto error; + } + RG_XDPE_VERBOSE("%d-%04x: read xdpe sensor low sensor page%u reg: 0x%x success, value: %ld\n", + client->adapter->nr, client->addr, page, reg, value2); + + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + return snprintf(buf, PAGE_SIZE, "%ld\n", value1 + value2); +error: + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + return ret; +} + +static int xdpe_get_vout_precision(const struct i2c_client *client, int *vout_precision) +{ + int i, vout_mode, a_size; + + vout_mode = rg_i2c_smbus_read_byte_data(client, RG_XDPE_I2C_VOUT_MODE); + if (vout_mode < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe vout mode reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, RG_XDPE_I2C_VOUT_MODE, vout_mode); + return vout_mode; + } + + a_size = ARRAY_SIZE(g_xdpe_vout_group); + for (i = 0; i < a_size; i++) { + if (g_xdpe_vout_group[i].vout_mode == vout_mode) { + *vout_precision = g_xdpe_vout_group[i].vout_precision; + RG_XDPE_VERBOSE("%d-%04x: match, vout mode: 0x%x, precision: %d\n", + client->adapter->nr, client->addr, vout_mode, *vout_precision); + break; + } + } + if (i == a_size) { + RG_XDPE_ERROR("%d-%04x: invalid vout mode: 0x%x\n",client->adapter->nr, client->addr, + vout_mode); + return -EINVAL; + } + return 0; +} + +static ssize_t xdpe_avs_vout_show(struct device *dev, struct device_attribute *da, char *buf) +{ + int ret, ori_page, vout_cmd, vout_precision; + struct i2c_client *client; + struct xdpe_data *data; + long vout; + + client = to_i2c_client(dev); + data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + ori_page = rg_i2c_smbus_read_byte_data(client, RG_XDPE_I2C_PAGE_ADDR); + if (ori_page < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe origin page failed, ret: %d\n", client->adapter->nr, + client->addr, ori_page); + mutex_unlock(&data->update_lock); + return ori_page; + } + + ret = rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, RG_XDPE_I2C_VOUT_PAGE); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: set xdpe avs vout page%u failed, ret: %d\n", client->adapter->nr, + client->addr, RG_XDPE_I2C_VOUT_PAGE, ret); + goto error; + } + + ret = xdpe_get_vout_precision(client, &vout_precision); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: get xdpe avs vout precision failed, ret: %d\n", + client->adapter->nr, client->addr, ret); + goto error; + } + + vout_cmd = rg_i2c_smbus_read_word_data(client, RG_XDPE_I2C_VOUT_COMMAND); + if (vout_cmd < 0) { + ret = vout_cmd; + RG_XDPE_ERROR("%d-%04x: read xdpe vout command reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, RG_XDPE_I2C_VOUT_COMMAND, ret); + goto error; + } + + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + + vout = vout_cmd * 1000L * 1000L / vout_precision; + RG_XDPE_VERBOSE("%d-%04x: vout: %ld, vout_cmd: 0x%x, precision: %d\n", client->adapter->nr, + client->addr, vout, vout_cmd, vout_precision); + return snprintf(buf, PAGE_SIZE, "%ld\n", vout); +error: + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + return ret; +} + +static ssize_t xdpe_avs_vout_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int ret, ori_page, vout_cmd, vout_cmd_set, vout_precision; + struct i2c_client *client; + struct xdpe_data *data; + long vout, vout_max, vout_min; + + client = to_i2c_client(dev); + ret = kstrtol(buf, 10, &vout); + if (ret) { + RG_XDPE_ERROR("%d-%04x: invalid value: %s \n", client->adapter->nr, client->addr, buf); + return -EINVAL; + } + + data = i2c_get_clientdata(client); + vout_max = data->vout_max; + vout_min = data->vout_min; + if ((vout > vout_max) || (vout < vout_min)) { + RG_XDPE_ERROR("%d-%04x: vout value: %ld, out of range [%ld, %ld] \n", client->adapter->nr, + client->addr, vout, vout_min, vout_max); + return -EINVAL; + } + + mutex_lock(&data->update_lock); + + ori_page = rg_i2c_smbus_read_byte_data(client, RG_XDPE_I2C_PAGE_ADDR); + if (ori_page < 0) { + RG_XDPE_ERROR("%d-%04x: read xdpe origin page failed, ret: %d\n", client->adapter->nr, + client->addr, ori_page); + mutex_unlock(&data->update_lock); + return ori_page; + } + + ret = rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, RG_XDPE_I2C_VOUT_PAGE); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: set xdpe avs vout page%u failed, ret: %d\n", client->adapter->nr, + client->addr, RG_XDPE_I2C_VOUT_PAGE, ret); + goto error; + } + + ret = xdpe_get_vout_precision(client, &vout_precision); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: get xdpe avs vout precision failed, ret: %d\n", + client->adapter->nr, client->addr, ret); + goto error; + } + + vout_cmd_set = (vout * vout_precision) / (1000L * 1000L); + if (vout_cmd_set > 0xffff) { + RG_XDPE_ERROR("%d-%04x: invalid value, vout %ld, vout_precision: %d, vout_cmd_set: 0x%x\n", + client->adapter->nr, client->addr, vout, vout_precision, vout_cmd_set); + ret = -EINVAL; + goto error; + } + ret = rg_i2c_smbus_write_word_data(client, RG_XDPE_I2C_VOUT_COMMAND, vout_cmd_set); + if (ret < 0) { + RG_XDPE_ERROR("%d-%04x: set xdpe vout cmd reg: 0x%x, value: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, RG_XDPE_I2C_VOUT_COMMAND, vout_cmd_set, ret); + goto error; + } + + vout_cmd = rg_i2c_smbus_read_word_data(client, RG_XDPE_I2C_VOUT_COMMAND); + if (vout_cmd < 0) { + ret = vout_cmd; + RG_XDPE_ERROR("%d-%04x: read xdpe vout command reg: 0x%x failed, ret: %d\n", + client->adapter->nr, client->addr, RG_XDPE_I2C_VOUT_COMMAND, ret); + goto error; + } + if (vout_cmd != vout_cmd_set) { + ret = -EIO; + RG_XDPE_ERROR("%d-%04x: vout cmd value check error, vout cmd read: 0x%x, vout cmd set: 0x%x\n", + client->adapter->nr, client->addr, vout_cmd, vout_cmd_set); + goto error; + + } + + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + RG_XDPE_VERBOSE("%d-%04x: set vout cmd success, vout %ld, vout_precision: %d, vout_cmd_set: 0x%x\n", + client->adapter->nr, client->addr, vout, vout_precision, vout_cmd_set); + return count; +error: + rg_i2c_smbus_write_byte_data(client, RG_XDPE_I2C_PAGE_ADDR, ori_page); + mutex_unlock(&data->update_lock); + return ret; +} + +static ssize_t xdpe_avs_vout_max_show(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client; + struct xdpe_data *data; + long vout_max; + + client = to_i2c_client(dev); + data = i2c_get_clientdata(client); + vout_max = data->vout_max; + return snprintf(buf, PAGE_SIZE, "%ld\n", vout_max); +} + +static ssize_t xdpe_avs_vout_max_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int ret; + struct i2c_client *client; + struct xdpe_data *data; + long vout_max; + + client = to_i2c_client(dev); + ret = kstrtol(buf, 10, &vout_max); + if (ret) { + RG_XDPE_ERROR("%d-%04x: invalid value: %s \n", client->adapter->nr, client->addr, buf); + return -EINVAL; + } + RG_XDPE_VERBOSE("%d-%04x: vout max threshold: %ld", client->adapter->nr, client->addr, + vout_max); + data = i2c_get_clientdata(client); + data->vout_max = vout_max; + return count; +} + +static ssize_t xdpe_avs_vout_min_show(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client; + struct xdpe_data *data; + long vout_min; + + client = to_i2c_client(dev); + data = i2c_get_clientdata(client); + vout_min = data->vout_min; + return snprintf(buf, PAGE_SIZE, "%ld\n", vout_min); +} + +static ssize_t xdpe_avs_vout_min_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int ret; + struct i2c_client *client; + struct xdpe_data *data; + long vout_min; + + client = to_i2c_client(dev); + ret = kstrtol(buf, 10, &vout_min); + if (ret) { + RG_XDPE_ERROR("%d-%04x: invalid value: %s \n", client->adapter->nr, client->addr, buf); + return -EINVAL; + } + RG_XDPE_VERBOSE("%d-%04x: vout min threshold: %ld", client->adapter->nr, client->addr, + vout_min); + data = i2c_get_clientdata(client); + data->vout_min = vout_min; + return count; +} + +/* xdpe hwmon */ +static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO ,xdpe_power_value_show, NULL, 0x072c); +static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO ,xdpe_power_value_show, NULL, 0x0b2c); +static SENSOR_DEVICE_ATTR(power3_input, S_IRUGO ,xdpe_power_value_show, NULL, 0x072c0b2c); + +static struct attribute *xdpe_hwmon_attrs[] = { + &sensor_dev_attr_power1_input.dev_attr.attr, + &sensor_dev_attr_power2_input.dev_attr.attr, + &sensor_dev_attr_power3_input.dev_attr.attr, + NULL +}; +ATTRIBUTE_GROUPS(xdpe_hwmon); + +/* xdpe sysfs */ +static SENSOR_DEVICE_ATTR(avs_vout, S_IRUGO | S_IWUSR, xdpe_avs_vout_show, xdpe_avs_vout_store, 0); +static SENSOR_DEVICE_ATTR(avs_vout_max, S_IRUGO | S_IWUSR, xdpe_avs_vout_max_show, xdpe_avs_vout_max_store, 0); +static SENSOR_DEVICE_ATTR(avs_vout_min, S_IRUGO | S_IWUSR, xdpe_avs_vout_min_show, xdpe_avs_vout_min_store, 0); + +static struct attribute *xdpe132g5c_sysfs_attrs[] = { + &sensor_dev_attr_avs_vout.dev_attr.attr, + &sensor_dev_attr_avs_vout_max.dev_attr.attr, + &sensor_dev_attr_avs_vout_min.dev_attr.attr, + NULL, +}; + +static const struct attribute_group xdpe132g5c_sysfs_attrs_group = { + .attrs = xdpe132g5c_sysfs_attrs, +}; + +static int xdpe132g5c_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct xdpe_data *data; + int ret; + + RG_XDPE_VERBOSE("bus: %d, addr: 0x%02x do probe.\n", client->adapter->nr, client->addr); + data = devm_kzalloc(&client->dev, sizeof(struct xdpe_data), GFP_KERNEL); + if (!data) { + dev_err(&client->dev, "devm_kzalloc failed.\n"); + return -ENOMEM; + } + + data->client = client; + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + + ret = sysfs_create_group(&client->dev.kobj, &xdpe132g5c_sysfs_attrs_group); + if (ret != 0) { + dev_err(&client->dev, "Create xdpe132g5c sysfs failed, ret: %d\n", ret); + return ret; + } + data->hwmon_dev = hwmon_device_register_with_groups(&client->dev, client->name, data, + xdpe_hwmon_groups); + if (IS_ERR(data->hwmon_dev)) { + ret = PTR_ERR(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &xdpe132g5c_sysfs_attrs_group); + dev_err(&client->dev, "Failed to register xdpe hwmon device, ret: %d\n", ret); + return ret; + } + data->vout_max = RG_XDPE_VOUT_MAX_THRESHOLD; + data->vout_min = RG_XDPE_VOUT_MIN_THRESHOLD; + dev_info(&client->dev, "xdpe132g5c probe success\n"); + return 0; +} + +static int xdpe132g5c_remove(struct i2c_client *client) +{ + struct xdpe_data *data; + + RG_XDPE_VERBOSE("bus: %d, addr: 0x%02x do remove\n", client->adapter->nr, client->addr); + data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &xdpe132g5c_sysfs_attrs_group); + return 0; +} + +static const struct i2c_device_id xdpe132g5c_id[] = { + {"rg_xdpe132g5c", 0}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, xdpe132g5c_id); + +static const struct of_device_id __maybe_unused xdpe132g5c_of_match[] = { + {.compatible = "infineon,rg_xdpe132g5c"}, + {} +}; +MODULE_DEVICE_TABLE(of, xdpe132g5c_of_match); + +static struct i2c_driver rg_xdpe132g5c_driver = { + .driver = { + .name = "rg_xdpe132g5c", + .of_match_table = of_match_ptr(xdpe132g5c_of_match), + }, + .probe = xdpe132g5c_probe, + .remove = xdpe132g5c_remove, + .id_table = xdpe132g5c_id, +}; + +module_i2c_driver(rg_xdpe132g5c_driver); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd "); +MODULE_DESCRIPTION("I2C driver for Infineon XDPE132 family"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie.h new file mode 100644 index 000000000000..bd2fd8bfa663 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie.h @@ -0,0 +1,71 @@ +#ifndef __RUIJIE_H__ +#define __RUIJIE_H__ + +#include +#include +#include + +typedef enum { + DBG_START, + DBG_VERBOSE, + DBG_KEY, + DBG_WARN, + DBG_ERROR, + DBG_END, +} dbg_level_t; + + typedef struct dfd_i2c_dev_s { + int bus; + int addr; + } dfd_i2c_dev_t; + +typedef struct dfd_dev_head_info_s { + uint8_t ver; + uint8_t flag; + uint8_t hw_ver; + uint8_t type; + int16_t tlv_len; +} dfd_dev_head_info_t; + +typedef struct dfd_dev_tlv_info_s { + uint8_t type; + uint8_t len; + uint8_t data[0]; +} dfd_dev_tlv_info_t; + +typedef enum dfd_dev_info_type_e { + DFD_DEV_INFO_TYPE_MAC = 1, + DFD_DEV_INFO_TYPE_NAME = 2, + DFD_DEV_INFO_TYPE_SN = 3, + DFD_DEV_INFO_TYPE_PWR_CONS = 4, + DFD_DEV_INFO_TYPE_HW_INFO = 5, + DFD_DEV_INFO_TYPE_DEV_TYPE = 6, +} dfd_dev_tlv_type_t; + +extern int debuglevel; +extern s32 platform_i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command); +extern s32 platform_i2c_smbus_read_i2c_block_data(const struct i2c_client *client, + u8 command, u8 length, u8 *values); +extern s32 platform_i2c_smbus_read_word_data(const struct i2c_client *client, u8 command); + +#define DBG_DEBUG(fmt, arg...) do { \ + if ( debuglevel > DBG_START && debuglevel < DBG_ERROR) { \ + printk(KERN_INFO "[DEBUG]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } else if ( debuglevel >= DBG_ERROR ) { \ + printk(KERN_ERR "[DEBUG]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } else { } \ +} while (0) + +#define DBG_INFO(fmt, arg...) do { \ + if ( debuglevel > DBG_KEY) { \ + printk(KERN_INFO "[INFO]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } \ + } while (0) + +#define DBG_ERROR(fmt, arg...) do { \ + if ( debuglevel > DBG_START) { \ + printk(KERN_ERR "[ERROR]:<%s, %d>:"fmt, __FUNCTION__, __LINE__, ##arg); \ + } \ + } while (0) + +#endif diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie_common_module.c b/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie_common_module.c new file mode 100644 index 000000000000..3c2046febd70 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/ruijie_common_module.c @@ -0,0 +1,210 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,152) +#include +#else +#include +#endif +#include +#include +#include +#include +#include "ruijie.h" +#include "dfd_tlveeprom.h" + +#define PLATFORM_I2C_RETRY_TIMES 3 + +#define DFD_TLVEEPROM_I2C_BUS (0) +#define DFD_TLVEEPROM_I2C_ADDR (0x56) +#define DFD_E2PROM_MAX_LEN (256) +#define DFD_CARDTYPE_EXT_TLVLEN (4) + +#define PLATFORM_CARDTYPE_RETRY_CNT (10) +#define PLATFORM_CARDTYPE_RETRY_TIMES (1000) + +int debuglevel = 0; +module_param(debuglevel, int, S_IRUGO | S_IWUSR); + +static int dfd_my_type = 0; +module_param(dfd_my_type, int, S_IRUGO | S_IWUSR); + +int g_common_debug_error = 0; +module_param(g_common_debug_error, int, S_IRUGO | S_IWUSR); + +int g_common_debug_verbose = 0; +module_param(g_common_debug_verbose, int, S_IRUGO | S_IWUSR); + +uint32_t dfd_my_type_i2c_bus = 0; +module_param(dfd_my_type_i2c_bus, int, S_IRUGO | S_IWUSR); + +uint32_t dfd_my_type_i2c_addr = 0; +module_param(dfd_my_type_i2c_addr, int, S_IRUGO | S_IWUSR); + +#define RUJIE_COMMON_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_common_debug_verbose) { \ + printk(KERN_ERR "[RUIJIE_COMMON][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RUJIE_COMMON_DEBUG_ERROR(fmt, args...) do { \ + if (g_common_debug_error) { \ + printk(KERN_ERR "[RUIJIE_COMMON][ERROR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static int32_t dfd_i2c_read(char *dev, uint32_t addr, uint32_t offset_addr, unsigned char * +buf, int32_t size) +{ + struct file *fp; + struct i2c_client client; + int i ,j; + int rv; + s32 val_t; + + val_t = -1; + rv = 0; + fp = filp_open(dev, O_RDWR, S_IRUSR | S_IWUSR); + if (IS_ERR(fp)) { + DBG_ERROR("i2c open fail.\n"); + RUJIE_COMMON_DEBUG_ERROR("i2c open fail.\n"); + return -1; + } + memcpy(&client, fp->private_data, sizeof(struct i2c_client)); + client.addr = addr; + for (j = 0 ;j < size ;j++){ + for (i = 0; i < PLATFORM_I2C_RETRY_TIMES; i++) { + if ((val_t = i2c_smbus_read_byte_data(&client, (offset_addr + j)))< 0) { + DBG_DEBUG("read try(%d)time offset_addr:%x \n", i, offset_addr); + continue; + } else { + * (buf + j) = val_t; + break; + } + } + if (val_t < 0) { + rv = -1; + break; + } + } + filp_close(fp, NULL); + return rv; +} + +static int dfd_tlvinfo_get_cardtype(void) +{ + char i2c_path[16] = {0}; + int ret; + int cardtype; + u_int8_t eeprom[DFD_E2PROM_MAX_LEN]; + dfd_i2c_dev_t i2c_dev; + uint8_t buf[DFD_CARDTYPE_EXT_TLVLEN]; + uint8_t len; + dfd_tlv_type_t tlv_type; + + if (dfd_my_type_i2c_bus != 0) { + i2c_dev.bus = dfd_my_type_i2c_bus; + } else { + i2c_dev.bus = DFD_TLVEEPROM_I2C_BUS; + } + + if (dfd_my_type_i2c_addr != 0) { + i2c_dev.addr = dfd_my_type_i2c_addr; + } else { + i2c_dev.addr = DFD_TLVEEPROM_I2C_ADDR; + } + snprintf(i2c_path, sizeof(i2c_path), "/dev/i2c-%d", i2c_dev.bus); + RUJIE_COMMON_DEBUG_VERBOSE("Read device eeprom info:(dev:%s, addr:%02x).\n", i2c_path, i2c_dev.addr); + + ret = dfd_i2c_read(i2c_path, i2c_dev.addr, 0, eeprom, DFD_E2PROM_MAX_LEN); + if (ret != 0) { + DBG_ERROR("Read eeprom info error(dev: %s, addr: %02x).\n", i2c_path, i2c_dev.addr); + RUJIE_COMMON_DEBUG_ERROR("Read eeprom info error(dev: %s, addr: %02x).\n", i2c_path, i2c_dev.addr); + return ret; + } + + tlv_type.main_type = TLV_CODE_VENDOR_EXT; + tlv_type.ext_type = DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE; + len = sizeof(buf); + memset(buf, 0, len); + ret = dfd_tlvinfo_get_e2prom_info(eeprom, DFD_E2PROM_MAX_LEN, &tlv_type, buf, &len); + if (ret) { + DBG_ERROR("dfd_tlvinfo_get_e2prom_info failed ret %d.\n", ret); + return -1; + } + for (ret = 0; ret < 4; ret++) { + DBG_DEBUG("buf 0x%02x.\n", buf[ret]); + } + + cardtype = ntohl(*((uint32_t *)buf)); + DBG_DEBUG("cardtype 0x%x.\n", cardtype); + return cardtype; +} + +static int __dfd_get_my_card_type(void) +{ + return dfd_tlvinfo_get_cardtype(); +} + +int dfd_get_my_card_type(void) +{ + int type; + int cnt; + + if (dfd_my_type != 0) { + DBG_DEBUG("my_type = 0x%x\r\n", dfd_my_type); + return dfd_my_type; + } + + cnt = PLATFORM_CARDTYPE_RETRY_CNT; + while (cnt--) { + type = __dfd_get_my_card_type(); + if (type < 0) { + RUJIE_COMMON_DEBUG_ERROR("__dfd_get_my_card_type fail cnt %d, ret %d.\n", cnt, type); + msleep(PLATFORM_CARDTYPE_RETRY_TIMES); + continue; + } + RUJIE_COMMON_DEBUG_VERBOSE("success to get type 0x%x.\n", type); + break; + } + + dfd_my_type = type; + return dfd_my_type; +} +EXPORT_SYMBOL(dfd_get_my_card_type); + +static int __init ruijie_common_init(void) +{ + int ret; + + RUJIE_COMMON_DEBUG_VERBOSE("Enter.\n"); + ret = dfd_get_my_card_type(); + if (ret <= 0) { + RUJIE_COMMON_DEBUG_ERROR("dfd_get_my_card_type failed, ret %d.\n", ret); + printk(KERN_ERR "Warning: Device type get failed, please check the TLV-EEPROM!\n"); + return -1; + } + + RUJIE_COMMON_DEBUG_VERBOSE("Leave success type 0x%x.\n", ret); + return 0; +} + +static void __exit ruijie_common_exit(void) +{ + RUJIE_COMMON_DEBUG_VERBOSE("Exit.\n"); +} + +module_init(ruijie_common_init); +module_exit(ruijie_common_exit); + +MODULE_DESCRIPTION("ruijie Platform Support"); +MODULE_AUTHOR("sonic_rd "); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/modules/spi-bitbang-txrx.h b/platform/broadcom/sonic-platform-modules-tencent/common/modules/spi-bitbang-txrx.h new file mode 100644 index 000000000000..47bb9b898dfd --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/modules/spi-bitbang-txrx.h @@ -0,0 +1,107 @@ +/* + * Mix this utility code with some glue code to get one of several types of + * simple SPI master driver. Two do polled word-at-a-time I/O: + * + * - GPIO/parport bitbangers. Provide chipselect() and txrx_word[](), + * expanding the per-word routines from the inline templates below. + * + * - Drivers for controllers resembling bare shift registers. Provide + * chipselect() and txrx_word[](), with custom setup()/cleanup() methods + * that use your controller's clock and chipselect registers. + * + * Some hardware works well with requests at spi_transfer scope: + * + * - Drivers leveraging smarter hardware, with fifos or DMA; or for half + * duplex (MicroWire) controllers. Provide chipselect() and txrx_bufs(), + * and custom setup()/cleanup() methods. + */ + +/* + * The code that knows what GPIO pins do what should have declared four + * functions, ideally as inlines, before including this header: + * + * void setsck(struct spi_device *, int is_on); + * void setmosi(struct spi_device *, int is_on); + * int getmiso(struct spi_device *); + * void spidelay(unsigned); + * + * setsck()'s is_on parameter is a zero/nonzero boolean. + * + * setmosi()'s is_on parameter is a zero/nonzero boolean. + * + * getmiso() is required to return 0 or 1 only. Any other value is invalid + * and will result in improper operation. + * + * A non-inlined routine would call bitbang_txrx_*() routines. The + * main loop could easily compile down to a handful of instructions, + * especially if the delay is a NOP (to run at peak speed). + * + * Since this is software, the timings may not be exactly what your board's + * chips need ... there may be several reasons you'd need to tweak timings + * in these routines, not just to make it faster or slower to match a + * particular CPU clock rate. + */ + +static inline u32 +bitbang_txrx_be_cpha0(struct spi_device *spi, + unsigned nsecs, unsigned cpol, unsigned flags, + u32 word, u8 bits) +{ + /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ + + u32 oldbit = (!(word & (1<<(bits-1)))) << 31; + /* clock starts at inactive polarity */ + for (word <<= (32 - bits); likely(bits); bits--) { + + /* setup MSB (to slave) on trailing edge */ + if ((flags & SPI_MASTER_NO_TX) == 0) { + if ((word & (1 << 31)) != oldbit) { + setmosi(spi, word & (1 << 31)); + oldbit = word & (1 << 31); + } + } + spidelay(nsecs); /* T(setup) */ + + setsck(spi, !cpol); + spidelay(nsecs); + + /* sample MSB (from slave) on leading edge */ + word <<= 1; + if ((flags & SPI_MASTER_NO_RX) == 0) + word |= getmiso(spi); + setsck(spi, cpol); + } + return word; +} + +static inline u32 +bitbang_txrx_be_cpha1(struct spi_device *spi, + unsigned nsecs, unsigned cpol, unsigned flags, + u32 word, u8 bits) +{ + /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ + + u32 oldbit = (!(word & (1<<(bits-1)))) << 31; + /* clock starts at inactive polarity */ + for (word <<= (32 - bits); likely(bits); bits--) { + + /* setup MSB (to slave) on leading edge */ + setsck(spi, !cpol); + if ((flags & SPI_MASTER_NO_TX) == 0) { + if ((word & (1 << 31)) != oldbit) { + setmosi(spi, word & (1 << 31)); + oldbit = word & (1 << 31); + } + } + spidelay(nsecs); /* T(setup) */ + + setsck(spi, cpol); + spidelay(nsecs); + + /* sample MSB (from slave) on trailing edge */ + word <<= 1; + if ((flags & SPI_MASTER_NO_RX) == 0) + word |= getmiso(spi); + } + return word; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/dev_monitor.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/dev_monitor.py new file mode 100755 index 000000000000..7fbfe144b2c4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/dev_monitor.py @@ -0,0 +1,345 @@ +#!/usr/bin/env python3 +import click +import os +import time +from ruijieconfig import DEV_MONITOR_PARAM +from ruijieutil import waitForDocker +from platform_util import io_rd, rji2cget, rji2cset, rjpciwr +import syslog +import traceback + + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class AliasedGroup(click.Group): + def get_command(self, ctx, cmd_name): + rv = click.Group.get_command(self, ctx, cmd_name) + if rv is not None: + return rv + matches = [x for x in self.list_commands(ctx) + if x.startswith(cmd_name)] + if not matches: + return None + elif len(matches) == 1: + return click.Group.get_command(self, ctx, matches[0]) + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) + return None + + +DEVMONITOR_DEBUG_FILE = "/etc/.devmonitor_debug_flag" + +debuglevel = 0 + + +def debug_init(): + global debuglevel + if os.path.exists(DEVMONITOR_DEBUG_FILE): + debuglevel = 1 + else: + debuglevel = 0 + + +def devwarninglog(s): + #s = s.decode('utf-8').encode('gb2312') + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_WARNING, s) + + +def devcriticallog(s): + #s = s.decode('utf-8').encode('gb2312') + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_CRIT, s) + + +def deverror(s): + #s = s.decode('utf-8').encode('gb2312') + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def devinfo(s): + #s = s.decode('utf-8').encode('gb2312') + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_INFO, s) + + +def devdebuglog(s): + #s = s.decode('utf-8').encode('gb2312') + if debuglevel == 1: + syslog.openlog("DEVMONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +class DevMonitor(): + + def getpresentstatus(self, param): + try: + ret = {} + ret["status"] = '' + totalerr = 0 + gettype = param.get('gettype') + presentbit = param.get('presentbit') + okval = param.get('okval') + if gettype == "io": + io_addr = param.get('io_addr') + val = io_rd(io_addr) + if val is not None: + retval = val + else: + totalerr -= 1 + else: + bus = param.get('bus') + loc = param.get('loc') + offset = param.get('offset') + ind, val = rji2cget(bus, loc, offset) + if ind == True: + retval = val + else: + totalerr -= 1 + if totalerr < 0: + ret["status"] = "NOT OK" + return ret + val_t = (int(retval, 16) & (1 << presentbit)) >> presentbit + if val_t != okval: + ret["status"] = "ABSENT" + else: + ret["status"] = "PRESENT" + except Exception as e: + ret["status"] = "NOT OK" + deverror("getpresentstatus error") + deverror(str(e)) + return ret + + def removeDev(self, bus, loc): + cmd = "echo 0x%02x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (loc, bus) + devpath = "/sys/bus/i2c/devices/%d-%04x" % (bus, loc) + if os.path.exists(devpath): + os.system(cmd) + + def addDev(self, name, bus, loc): + if name == "lm75": + time.sleep(0.1) + cmd = "echo %s 0x%02x > /sys/bus/i2c/devices/i2c-%d/new_device" % (name, loc, bus) + devpath = "/sys/bus/i2c/devices/%d-%04x" % (bus, loc) + if os.path.exists(devpath) == False: + os.system(cmd) + + def checkattr(self, bus, loc, attr): + try: + attrpath = "/sys/bus/i2c/devices/%d-%04x/%s" % (bus, loc, attr) + if os.path.exists(attrpath): + return True + except Exception as e: + deverror("checkattr error") + deverror(str(e)) + return False + + def monitor(self, ret): + totalerr = 0 + for item in ret: + try: + name = item.get('name') + itemattr = '%sattr' % name + val_t = getattr(DevMonitor, itemattr, None) + if val_t == 'OK': + continue + present = item.get('present', None) + devices = item.get('device') + err_t = 0 + for item_dev in devices: + item_devattr = '%s' % (item_dev['id']) + val_t = getattr(DevMonitor, item_devattr, None) + if val_t == 'OK': + continue + devname = item_dev.get('name') + bus = item_dev.get('bus') + loc = item_dev.get('loc') + attr = item_dev.get('attr') + if self.checkattr(bus, loc, attr) == False: + err_t -= 1 + setattr(DevMonitor, item_devattr, 'NOT OK') + if present is not None: + presentstatus = self.getpresentstatus(present) + devdebuglog("%s present status:%s" % (name, presentstatus.get('status'))) + if presentstatus.get('status') == 'PRESENT': + self.removeDev(bus, loc) + time.sleep(0.1) + self.addDev(devname, bus, loc) + else: + self.removeDev(bus, loc) + time.sleep(0.1) + self.addDev(devname, bus, loc) + else: + setattr(DevMonitor, item_devattr, 'OK') + val_t = getattr(DevMonitor, item_devattr, None) + devdebuglog("%s status %s" % (item_devattr, val_t)) + if err_t == 0: + setattr(DevMonitor, itemattr, 'OK') + else: + totalerr -= 1 + setattr(DevMonitor, itemattr, 'NOT OK') + val_t = getattr(DevMonitor, itemattr, None) + devdebuglog("%s status %s" % (itemattr, val_t)) + except Exception as e: + totalerr -= 1 + deverror("monitor error") + deverror(str(e)) + return totalerr + + def psusmonitor(self): + psus_conf = DEV_MONITOR_PARAM.get('psus') + if psus_conf is None: + return 0 + psusattr = 'psusattr' + val_t = getattr(DevMonitor, psusattr, None) + if val_t == 'OK': + return 0 + ret = self.monitor(psus_conf) + if ret == 0: + setattr(DevMonitor, psusattr, 'OK') + else: + setattr(DevMonitor, psusattr, 'NOT OK') + val_t = getattr(DevMonitor, psusattr, None) + devdebuglog("psusattr:value:%s" % (val_t)) + return ret + + def fansmonitor(self): + fans_conf = DEV_MONITOR_PARAM.get('fans') + if fans_conf is None: + return 0 + fansattr = 'fansattr' + val_t = getattr(DevMonitor, fansattr, None) + if val_t == 'OK': + return 0 + ret = self.monitor(fans_conf) + if ret == 0: + setattr(DevMonitor, fansattr, 'OK') + else: + setattr(DevMonitor, fansattr, 'NOT OK') + val_t = getattr(DevMonitor, fansattr, None) + devdebuglog("fansattr:value:%s" % (val_t)) + return ret + + def slotsmonitor(self): + slots_conf = DEV_MONITOR_PARAM.get('slots') + if slots_conf is None: + return 0 + slotsattr = 'slotsattr' + val_t = getattr(DevMonitor, slotsattr, None) + if val_t == 'OK': + return 0 + ret = self.monitor(slots_conf) + if ret == 0: + setattr(DevMonitor, slotsattr, 'OK') + else: + setattr(DevMonitor, slotsattr, 'NOT OK') + val_t = getattr(DevMonitor, slotsattr, None) + devdebuglog("slotsattr:value:%s" % (val_t)) + return ret + + def sdkmonitor(self): + sdk_conf = DEV_MONITOR_PARAM.get('sdk') + ret = 0 + if sdk_conf is None: + return ret + sdkattr = 'sdkattr' + val_t = getattr(DevMonitor, sdkattr, None) + if val_t == 'OK': + return ret + if waitForDocker(timeout=0) == True: + setattr(DevMonitor, sdkattr, 'OK') + acts = sdk_conf.get("act", []) + for item in acts: + if item.get('gettype') == 'i2c': + bus = item.get('bus') + loc = item.get('loc') + offset = item.get('offset') + value = item.get('value') + rji2cset(bus, loc, offset, value) + elif item.get('gettype') == 'pci': + pcibus = item.get("pcibus") + slot = item.get("slot") + fn = item.get("fn") + bar = item.get("bar") + offset = item.get("offset") + data = item.get("data") + rjpciwr(pcibus, slot, fn, bar, offset, data) + + else: + ret = -1 + setattr(DevMonitor, sdkattr, 'NOT OK') + val_t = getattr(DevMonitor, sdkattr, None) + devdebuglog("sdkattr:value:%s" % (val_t)) + return ret + + def othersmonitor(self): + others_conf = DEV_MONITOR_PARAM.get('others') + if others_conf is None: + return 0 + othersattr = 'othersattr' + val_t = getattr(DevMonitor, othersattr, None) + if val_t == 'OK': + return 0 + ret = self.monitor(others_conf) + if ret == 0: + setattr(DevMonitor, othersattr, 'OK') + else: + setattr(DevMonitor, othersattr, 'NOT OK') + val_t = getattr(DevMonitor, othersattr, None) + devdebuglog("othersattr:value:%s" % (val_t)) + return ret + + +def doDevMonitor(devMonitor): + ret_t = 0 + ret_t += devMonitor.psusmonitor() + ret_t += devMonitor.fansmonitor() + ret_t += devMonitor.slotsmonitor() + # SDK + ret_t += devMonitor.sdkmonitor() + ret_t += devMonitor.othersmonitor() + return ret_t + + +def run(interval, devMonitor): + # devMonitor.devattrinit() + while True: + try: + debug_init() + ret = doDevMonitor(devMonitor) + except Exception as e: + traceback.print_exc() + deverror(str(e)) + ret = -1 + if ret == 0: + time.sleep(5) + devinfo("dev_monitor finished!") + exit(0) + time.sleep(interval) + + +@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) +def main(): + '''device operator''' + pass + + +@main.command() +def start(): + '''start device monitor''' + devinfo("dev_monitor start") + devMonitor = DevMonitor() + interval = DEV_MONITOR_PARAM.get('polling_time', 10) + run(interval, devMonitor) + + +@main.command() +def stop(): + '''stop device monitor ''' + devinfo("stop") + + +# device_i2c operation +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_fanctrl.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_fanctrl.py new file mode 100755 index 000000000000..cfd3da7602e9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_fanctrl.py @@ -0,0 +1,1012 @@ +#!/usr/bin/env python3 +import os +import subprocess +import time +import syslog +import traceback +from plat_hal.interface import interface +from plat_hal.baseutil import baseutil +from algorithm.pid import pid +from algorithm.openloop import openloop +from algorithm.hysteresis import hysteresis + + +SWITCH_TEMP = "SWITCH_TEMP" +INLET_TEMP = "INLET_TEMP" +BOARD_TEMP = "BOARD_TEMP" +OUTLET_TEMP = "OUTLET_TEMP" +CPU_TEMP = "CPU_TEMP" + +FANCTROL_DEBUG_FILE = "/etc/.fancontrol_debug_flag" +OTP_REBOOT_JUDGE_FILE = "/etc/.otp_reboot_flag" #coordination with REBOOT_CAUSE_PARA + +FANCTROLERROR = 1 +FANCTROLDEBUG = 2 +FANAIRFLOWDEBUG = 4 + +debuglevel = 0 + +F2B_AIR_FLOW = "F2B" +B2F_AIR_FLOW = "B2F" +ONIE_E2_NAME = "ONIE_E2" + + +def fancontrol_debug(s): + if FANCTROLDEBUG & debuglevel: + syslog.openlog("FANCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def fancontrol_error(s): + if FANCTROLERROR & debuglevel: + syslog.openlog("FANCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def fanairflow_debug(s): + if FANAIRFLOWDEBUG & debuglevel: + syslog.openlog("AIR_FLOW_MONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def exec_os_cmd(cmd): + status, output = subprocess.getstatusoutput(cmd) + if status: + print(output) + return status, output + + +def debug_init(): + global debuglevel + try: + with open(FANCTROL_DEBUG_FILE, "r") as fd: + value = fd.read() + debuglevel = int(value) + except Exception as e: + debuglevel = 0 + + +error_temp = -9999 # get temp error +invalid_temp = -10000 # get temp invalid +PRE_FAN_NOK_UNKNOWN = "UNKNOWN" + + +class DevFan(object): + + def __init__(self, name, interface): + self.__name = name + self.origin_name = None + self.display_name = None + self.air_flow = None + self.air_flow_inconsistent = False + self.int_case = interface + + @property + def name(self): + return self.__name + + def get_fan_rotor_number(self): + return self.int_case.get_fan_rotor_number(self.name) + + def get_fan_presence(self): + return self.int_case.get_fan_presence(self.name) + + def get_fan_rotor_status(self, rotor_name): + return self.int_case.get_fan_rotor_status(self.name, rotor_name) + + def get_fan_fru_info(self): + return self.int_case.get_fan_fru_info(self.name) + + @property + def na_ret(self): + return self.int_case.na_ret + + def update_fru_info(self): + try: + dic = self.get_fan_fru_info() + self.origin_name = dic["PN"] + self.air_flow = dic["AirFlow"] + self.display_name = dic["DisplayName"] + except Exception as e: + fanairflow_debug("update %s fru info error, msg: %s" % (self.name, str(e))) + self.origin_name = self.na_ret + self.air_flow = self.na_ret + self.display_name = self.na_ret + + +class fancontrol(object): + __int_case = None + + __pwm = 0x80 + + def __init__(self): + self.int_case = interface() + self.__config = baseutil.get_monitor_config() + self.__pid_config = self.__config["pid"] + self.__hyst_config = self.__config.get("hyst", {}) + self.__temps_threshold_config = self.__config["temps_threshold"] + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['temp'] = 0 + temp_threshold['fail_num'] = 0 + temp_threshold['warning_num'] = 0 # temp warning times + temp_threshold['critical_num'] = 0 # temp critical times + temp_threshold['emergency_num'] = 0 # temp emergency times + temp_threshold.setdefault('ignore_threshold', 0) # default temp threshold on + temp_threshold.setdefault('invalid', invalid_temp) + temp_threshold.setdefault('error', error_temp) + + self.__fan_rotor_error_num = {} + self.__fan_present_status = {} # {"FAN1":0, "FAN2":1...} 1:present, 0:absent + self.__fan_rotate_status = {} # {"FAN1":0, "FAN2":1...} 1:OK, 0:NOT OK + self.__fan_repair_flag = {} # {"FAN1":0, "FAN2":1...} 1:repair, 0:give up + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + self.__fan_present_status[fan_name] = 1 # present + self.__fan_rotate_status[fan_name] = 1 # OK + self.__fan_repair_flag[fan_name] = 1 # repair + rotor_num = self.get_rotor_number(fan_name) + tmp_fan = {} + for j in range(rotor_num): + rotor_name = "Rotor" + str(j + 1) + tmp_fan[rotor_name] = 0 # not error + self.__fan_rotor_error_num[fan_name] = tmp_fan + + self.__fancontrol_para = self.__config["fancontrol_para"] + self.__interval = self.__fancontrol_para.get("interval", 5) + self.__fan_status_interval = self.__fancontrol_para.get("fan_status_interval", 0) + self.__max_pwm = self.__fancontrol_para.get("max_pwm", 0xff) + self.__min_pwm = self.__fancontrol_para.get("min_pwm", 0x80) + self.__abnormal_pwm = self.__fancontrol_para.get("abnormal_pwm", 0xbb) + self.__warning_pwm = self.__fancontrol_para.get("warning_pwm", 0xff) + self.__temp_invalid_pid_pwm = self.__fancontrol_para.get("temp_invalid_pid_pwm", 0x80) + self.__temp_error_pid_pwm = self.__fancontrol_para.get("temp_error_pid_pwm", 0x80) + self.__temp_fail_num = self.__fancontrol_para.get("temp_fail_num", 3) + self.__check_temp_fail = self.__fancontrol_para.get("check_temp_fail", []) + self.__temp_warning_num = self.__fancontrol_para.get("temp_warning_num", 3) + self.__temp_critical_num = self.__fancontrol_para.get("temp_critical_num", 3) + self.__temp_emergency_num = self.__fancontrol_para.get("temp_emergency_num", 3) + self.__temp_warning_countdown = self.__fancontrol_para.get("temp_warning_countdown", 60) + self.__temp_critical_countdown = self.__fancontrol_para.get("temp_critical_countdown", 60) + self.__temp_emergency_countdown = self.__fancontrol_para.get("temp_emergency_countdown", 60) + self.__rotor_error_count = self.__fancontrol_para.get("rotor_error_count", 6) + self.__inlet_mac_diff = self.__fancontrol_para.get("inlet_mac_diff", 50) + self.__check_crit_reboot_flag = self.__fancontrol_para.get("check_crit_reboot_flag", 1) + self.__check_emerg_reboot_flag = self.__fancontrol_para.get("check_emerg_reboot_flag", 1) + self.__check_crit_reboot_num = self.__fancontrol_para.get("check_crit_reboot_num", 3) + self.__check_crit_sleep_time = self.__fancontrol_para.get("check_crit_sleep_time", 20) + self.__check_emerg_reboot_num = self.__fancontrol_para.get("check_emerg_reboot_num", 3) + self.__check_emerg_sleep_time = self.__fancontrol_para.get("check_emerg_sleep_time", 20) + self.__check_temp_emergency = self.__fancontrol_para.get("check_temp_emergency", 0) + self.__check_temp_critical = self.__fancontrol_para.get("check_temp_critical", 1) + self.__check_temp_warning = self.__fancontrol_para.get("check_temp_warning", 1) + self.__check_temp_emergency_reboot = self.__fancontrol_para.get("check_temp_emergency_reboot", []) + self.__psu_absent_fullspeed_num = self.__fancontrol_para.get("psu_absent_fullspeed_num", 1) + self.__fan_absent_fullspeed_num = self.__fancontrol_para.get("fan_absent_fullspeed_num", 1) + self.__rotor_error_fullspeed_num = self.__fancontrol_para.get("rotor_error_fullspeed_num", 1) + self.__psu_fan_control = self.__fancontrol_para.get("psu_fan_control", 1) # default control psu fan + self.__fan_plug_in_pwm = self.__fancontrol_para.get("fan_plug_in_pwm", 0x80) + self.__fan_plug_in_default_countdown = self.__fancontrol_para.get("fan_plug_in_default_countdown", 0) + self.__deal_fan_error_policy = self.__fancontrol_para.get("deal_fan_error", 0) + self.__deal_fan_error_conf = self.__fancontrol_para.get("deal_fan_error_conf", {}) + self.__deal_fan_error_default_countdown = self.__deal_fan_error_conf.get("countdown", 0) + + self.__warning_countdown = 0 # temp warning flag for normal fancontrol + self.__critical_countdown = 0 # temp critical flag for normal fancontrol + self.__emergency_countdown = 0 # temp emergency flag for normal fancontrol + self.__fan_plug_in_countdown = 0 # fan plug in flag for normal fancontrol + self.__deal_fan_error_countdown = 0 + self.__fan_absent_num = 0 + self.__fan_nok_num = 0 + self.__pre_fan_nok = PRE_FAN_NOK_UNKNOWN + self.openloop = openloop() + self.pid = pid() + self.hyst = hysteresis() + self.__pwm = self.__min_pwm + + self.__board_air_flow = "" + self.__fan_air_flow_monitor = self.__fancontrol_para.get("fan_air_flow_monitor", 0) + self.__air_flow_correct_fan_pwm = self.__fancontrol_para.get("air_flow_correct_fan_pwm", 0xff) + self.__air_flow_error_fan_pwm = self.__fancontrol_para.get("air_flow_error_fan_pwm", 0) + self.__air_flow_error_psu_pwm = self.__fancontrol_para.get("air_flow_error_psu_pwm", 0xff) + self.air_flow_inconsistent_flag = False + self.fan_obj_list = [] + + @property + def na_ret(self): + return self.int_case.na_ret + + def get_onie_e2_obj(self, name): + return self.int_case.get_onie_e2_obj(name) + + @property + def board_air_flow(self): + if self.__board_air_flow != F2B_AIR_FLOW and self.__board_air_flow != B2F_AIR_FLOW: + onie_e2_obj = self.get_onie_e2_obj(ONIE_E2_NAME) + if onie_e2_obj is not None: + fanairflow_debug("onie_e2 servicetag: %s" % onie_e2_obj.servicetag) + if isinstance(onie_e2_obj.servicetag, str) and onie_e2_obj.servicetag.startswith("F2B"): + self.__board_air_flow = F2B_AIR_FLOW + elif isinstance(onie_e2_obj.servicetag, str) and onie_e2_obj.servicetag.startswith("B2F"): + self.__board_air_flow = B2F_AIR_FLOW + else: + self.__board_air_flow = onie_e2_obj.servicetag + fanairflow_debug("board_air_flow: %s" % self.__board_air_flow) + return self.__board_air_flow + + @property + def fan_air_flow_monitor(self): + return self.__fan_air_flow_monitor + + @property + def air_flow_correct_fan_pwm(self): + return self.__air_flow_correct_fan_pwm + + @property + def air_flow_error_fan_pwm(self): + return self.__air_flow_error_fan_pwm + + @property + def air_flow_error_psu_pwm(self): + return self.__air_flow_error_psu_pwm + + def get_para(self, type): + para = self.__pid_config.get(type) + return para + + def update_over_temp_threshold_num(self): + for temp_threshold in self.__temps_threshold_config.values(): + if temp_threshold['ignore_threshold']: + continue + emergency_threshold = temp_threshold.get('emergency', None) + critical_threshold = temp_threshold.get('critical', None) + warning_threshold = temp_threshold.get('warning', None) + fancontrol_debug("%s warning = %s, critical = %s, emergency = %s" % + (temp_threshold['name'], warning_threshold, critical_threshold, emergency_threshold)) + + if emergency_threshold is not None and temp_threshold['temp'] >= emergency_threshold: + temp_threshold['emergency_num'] += 1 + else: + temp_threshold['emergency_num'] = 0 + + if critical_threshold is not None and temp_threshold['temp'] >= critical_threshold: + temp_threshold['critical_num'] += 1 + else: + temp_threshold['critical_num'] = 0 + + if warning_threshold is not None and temp_threshold['temp'] >= warning_threshold: + temp_threshold['warning_num'] += 1 + else: + temp_threshold['warning_num'] = 0 + + fancontrol_debug("%s warning_num = %d, critical_num = %d, emergency_num = %d" % + (temp_threshold['name'], temp_threshold['warning_num'], temp_threshold['critical_num'], temp_threshold.get("emergency_num"))) + return + + def get_monitor_temp(self): + sensorlist = self.int_case.get_temp_info() + + for temp_threshold in self.__temps_threshold_config.values(): + sensor = sensorlist.get(temp_threshold['name']) + if sensor["Value"] is None or int(sensor["Value"]) == self.int_case.error_ret: + temp_threshold['fail_num'] += 1 + fancontrol_error("get %s failed, fail_num = %d" % (temp_threshold['name'], temp_threshold['fail_num'])) + else: + temp_threshold['fail_num'] = 0 + temp_threshold.setdefault('fix', 0) + temp_threshold['temp'] = sensor["Value"] + temp_threshold['fix'] + fancontrol_debug("%s = %d" % (temp_threshold['name'], temp_threshold['temp'])) + self.update_over_temp_threshold_num() + + def is_temp_warning(self): + warning_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + if temp_threshold['ignore_threshold']: + continue + if temp_threshold['warning_num'] >= self.__temp_warning_num: + warning_flag = True + fancontrol_debug("%s is over warning" % temp_threshold['name']) + fancontrol_debug("%s = %d, warning = %s" % + (temp_threshold['name'], temp_threshold['temp'], temp_threshold.get('warning'))) + return warning_flag + + def checkTempWarning(self): + try: + if self.is_temp_warning(): + self.__warning_countdown = self.__temp_warning_countdown + fancontrol_debug("temp is over warning") + return True + else: + if self.__warning_countdown > 0: + self.__warning_countdown -= 1 + return False + except Exception as e: + fancontrol_error("%%policy: checkTempWarning failed") + fancontrol_error(str(e)) + return False + + def checkTempWarningCountdown(self): + if self.__warning_countdown > 0: + return True + return False + + def is_temp_critical(self): + critical_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['critical_flag'] = False + if temp_threshold['ignore_threshold']: + continue + if temp_threshold['critical_num'] >= self.__temp_critical_num: + critical_flag = True + temp_threshold['critical_flag'] = True + fancontrol_debug("%s is over critical" % temp_threshold['name']) + fancontrol_debug("%s = %d, critical = %s" % + (temp_threshold['name'], temp_threshold['temp'], temp_threshold.get('critical'))) + return critical_flag + + def checkTempCritical(self): + try: + if self.is_temp_critical(): + self.__critical_countdown = self.__temp_critical_countdown + fancontrol_debug("temp is over critical") + return True + else: + if self.__critical_countdown > 0: + self.__critical_countdown -= 1 + return False + except Exception as e: + fancontrol_error("%%policy: checkTempCrit failed") + fancontrol_error(str(e)) + return False + + def is_temp_emergency(self): + emergency_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['emergency_flag'] = False + if temp_threshold['ignore_threshold']: + continue + if temp_threshold['emergency_num'] >= self.__temp_emergency_num: + emergency_flag = True + temp_threshold['emergency_flag'] = True + fancontrol_debug("%s is over emergency" % temp_threshold['name']) + fancontrol_debug("%s = %d, emergency = %s" % + (temp_threshold['name'], temp_threshold['temp'], temp_threshold.get('emergency'))) + return emergency_flag + + + def checkTempEmergency(self): + try: + if self.is_temp_emergency(): + self.__emergency_countdown = self.__temp_emergency_countdown + fancontrol_debug("temp is over emergency") + return True + else: + if self.__emergency_countdown > 0: + self.__emergency_countdown -= 1 + return False + except Exception as e: + fancontrol_error("%%policy: checkTempEmergency failed") + fancontrol_error(str(e)) + return False + + def checkTempCriticalCountdown(self): + if self.__critical_countdown > 0: + return True + return False + + def checkTempEmergencyCountdown(self): + if self.__emergency_countdown > 0: + return True + return False + + def checkTempRebootCrit(self): + try: + if self.is_temp_critical(): + temp_dict = dict(self.__temps_threshold_config) + tmp = temp_dict.get(SWITCH_TEMP) + if tmp['critical_flag'] == True: + fancontrol_debug("switch temp is over reboot critical") + return True + del temp_dict[SWITCH_TEMP] + for temp_items in temp_dict.values(): + if temp_items['ignore_threshold']: + continue + if temp_items['critical_flag'] == False: + return False + + fancontrol_debug("other temp is over reboot critical") + return True + except Exception as e: + fancontrol_error("%%policy: checkTempRebootCrit failed") + fancontrol_error(str(e)) + return False + + def checkCritReboot(self): + try: + reboot_flag = False + if self.checkTempRebootCrit() == True: + self.set_all_fan_speed_pwm(self.__max_pwm) + for i in range(self.__check_crit_reboot_num): + time.sleep(self.__check_crit_sleep_time) + self.get_monitor_temp() + if self.checkTempRebootCrit() == True: + fancontrol_debug("The temperature of device is over reboot critical value.") + reboot_flag = True + continue + else: + fancontrol_debug("The temperature of device is not over reboot critical value.") + reboot_flag = False + break + if reboot_flag is True: + reboot_log = "The temperature of device is over critical value." + reboot_log_cmd = "echo '%s' > /dev/ttyS0" % reboot_log + fancontrol_error(reboot_log) + exec_os_cmd(reboot_log_cmd) + reboot_log = "The system is going to reboot now." + reboot_log_cmd = "echo '%s' > /dev/ttyS0" % reboot_log + fancontrol_error(reboot_log) + exec_os_cmd(reboot_log_cmd) + for temp_threshold in self.__temps_threshold_config.values(): + fancontrol_error("%s = %d" % (temp_threshold['name'], temp_threshold['temp'])) + create_judge_file = "touch %s" % OTP_REBOOT_JUDGE_FILE + exec_os_cmd(create_judge_file) + exec_os_cmd("sync") + time.sleep(3) + os.system("/sbin/reboot") + except Exception as e: + fancontrol_error("%%policy: checkCritReboot failed") + fancontrol_error(str(e)) + + def checkTempRebootEmerg(self): + try: + if self.is_temp_emergency(): + temp_emerg_reboot_flag = False + for temp_list in self.__check_temp_emergency_reboot: + for temp in temp_list: + tmp = self.__temps_threshold_config.get(temp) + if tmp['emergency_flag'] is False: + fancontrol_debug("temp_list %s, temp: %s not emergency" % (temp_list, temp)) + temp_emerg_reboot_flag = False + break + temp_emerg_reboot_flag = True + if temp_emerg_reboot_flag is True: + fancontrol_debug("temp_list %s, all temp is over emergency reboot" % temp_list) + return True + except Exception as e: + fancontrol_error("%%policy: checkTempRebootEmerg failed") + fancontrol_error(str(e)) + return False + + def checkEmergReboot(self): + try: + reboot_flag = False + if self.checkTempRebootEmerg() is True: + self.set_all_fan_speed_pwm(self.__max_pwm) + for i in range(self.__check_emerg_reboot_num): + time.sleep(self.__check_emerg_sleep_time) + self.get_monitor_temp() + if self.checkTempRebootEmerg() is True: + fancontrol_debug("The temperature of device is over reboot emergency value, i = %d" % (i+1)) + reboot_flag = True + continue + else: + fancontrol_debug("The temperature of device is not over reboot emergency value.") + reboot_flag = False + break + if reboot_flag is True: + reboot_log = "The temperature of device is over emergency value." + reboot_log_cmd = "echo '%s' > /dev/ttyS0" % reboot_log + fancontrol_error(reboot_log) + exec_os_cmd(reboot_log_cmd) + reboot_log = "The system is going to reboot now." + reboot_log_cmd = "echo '%s' > /dev/ttyS0" % reboot_log + fancontrol_error(reboot_log) + exec_os_cmd(reboot_log_cmd) + for temp_threshold in self.__temps_threshold_config.values(): + fancontrol_error("%s = %d" % (temp_threshold['name'], temp_threshold['temp'])) + create_judge_file = "touch %s" % OTP_REBOOT_JUDGE_FILE + exec_os_cmd(create_judge_file) + exec_os_cmd("sync") + time.sleep(3) + os.system("/sbin/reboot") + except Exception as e: + fancontrol_error("%%policy: checkEmergReboot failed") + fancontrol_error(str(e)) + + def get_fan_total_number(self): + return self.int_case.get_fan_total_number() + + def get_rotor_number(self, fan_name): + return self.int_case.get_fan_rotor_number(fan_name) + + def get_fan_presence(self, fan_name): + return self.int_case.get_fan_presence(fan_name) + + def get_fan_rotor_status(self, fan_name, rotor_name): + return self.int_case.get_fan_rotor_status(fan_name, rotor_name) + + def get_psu_total_number(self): + return self.int_case.get_psu_total_number() + + def get_psu_presence(self, psu_name): + return self.int_case.get_psu_presence(psu_name) + + def get_psu_input_output_status(self, psu_name): + return self.int_case.get_psu_input_output_status(psu_name) + + def checkFanPresence(self): + absent_num = 0 + + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + rotor_num = self.get_rotor_number(fan_name) + tmp_fan = self.__fan_rotor_error_num.get(fan_name) + status = self.get_fan_presence(fan_name) + if status == False: + absent_num = absent_num + 1 + self.__fan_present_status[fan_name] = 0 + fancontrol_debug("%s absent" % fan_name) + else: + if self.__fan_present_status[fan_name] == 0: # absent -> present + self.__pre_fan_nok = PRE_FAN_NOK_UNKNOWN + self.__fan_plug_in_countdown = self.__fan_plug_in_default_countdown + self.__fan_repair_flag[fan_name] = 1 + for j in range(rotor_num): + rotor_name = "Rotor" + str(j + 1) + tmp_fan[rotor_name] = 0 + self.__fan_present_status[fan_name] = 1 + fancontrol_debug("%s presence" % fan_name) + return absent_num + + def checkFanRotorStatus(self): + err_num = 0 + self.__fan_nok_num = 0 + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + rotor_num = self.get_rotor_number(fan_name) + tmp_fan = self.__fan_rotor_error_num.get(fan_name) + fan_rotor_err_cnt = 0 + for j in range(rotor_num): + rotor_name = "Rotor" + str(j + 1) + status = self.get_fan_rotor_status(fan_name, rotor_name) + if status == True: + tmp_fan[rotor_name] = 0 + fancontrol_debug("%s %s ok" % (fan_name, rotor_name)) + else: + tmp_fan[rotor_name] += 1 + if tmp_fan[rotor_name] >= self.__rotor_error_count: + err_num = err_num + 1 + fan_rotor_err_cnt += 1 + fancontrol_debug("%s %s error" % (fan_name, rotor_name)) + fancontrol_debug("%s %s error %d times" % (fan_name, rotor_name, tmp_fan[rotor_name])) + if fan_rotor_err_cnt == 0: + self.__fan_rotate_status[fan_name] = 1 # FAN is ok + else: + self.__fan_rotate_status[fan_name] = 0 # FAN is not ok + self.__fan_nok_num += 1 + fancontrol_debug("fan not ok number:%d." % self.__fan_nok_num) + return err_num + + def checkPsuPresence(self): + absent_num = 0 + psu_num = self.get_psu_total_number() + for i in range(psu_num): + psu_name = "PSU" + str(i + 1) + status = self.get_psu_presence(psu_name) + if status == False: + absent_num = absent_num + 1 + fancontrol_debug("%s absent" % psu_name) + else: + fancontrol_debug("%s presence" % psu_name) + return absent_num + + def checkPsuStatus(self): + err_num = 0 + psu_num = self.get_psu_total_number() + for i in range(psu_num): + psu_name = "PSU" + str(i + 1) + status = self.get_psu_input_output_status(psu_name) + if status == False: + err_num = err_num + 1 + fancontrol_debug("%s error" % psu_name) + else: + fancontrol_debug("%s ok" % psu_name) + return err_num + + def checkDevError(self): + pwm = self.__min_pwm + switchtemp = self.__temps_threshold_config.get(SWITCH_TEMP)['temp'] + inlettemp = self.__temps_threshold_config.get(INLET_TEMP)['temp'] + temp_diff = abs(switchtemp - inlettemp) + fancontrol_debug("|switchtemp - inlettemp| = %d" % temp_diff) + if temp_diff >= self.__inlet_mac_diff: + fancontrol_debug("temp_diff is over than inlet_mac_diff(%d)" % self.__inlet_mac_diff) + if self.__pwm > self.__abnormal_pwm: + pwm = self.__max_pwm + else: + pwm = self.__abnormal_pwm + return pwm + + def checktempfail(self): + pwm = self.__min_pwm + for temp in self.__check_temp_fail: + temp_name = temp.get("temp_name") + temp_fail_num = self.__temps_threshold_config.get(temp_name)['fail_num'] + if temp_fail_num >= self.__temp_fail_num: + pwm = self.__abnormal_pwm + fancontrol_debug("%s temp_fail_num = %d" % (temp_name, temp_fail_num)) + fancontrol_debug("self.__temp_fail_num = %d" % self.__temp_fail_num) + return pwm + + def abnormal_check(self): + pwm_list = [] + pwm_min = self.__min_pwm + pwm_list.append(pwm_min) + + if self.__check_temp_emergency == 1: + status = self.checkTempEmergency() + if status is True: + over_emerg_pwm = self.__max_pwm + pwm_list.append(over_emerg_pwm) + fancontrol_debug("over_emerg_pwm = 0x%x" % over_emerg_pwm) + # do reset check + if self.__check_emerg_reboot_flag == 1: + self.checkEmergReboot() + else: + if self.checkTempEmergencyCountdown() == True: # temp lower than emergency in 5 min + over_emerg_countdown_pwm = self.__max_pwm + pwm_list.append(over_emerg_countdown_pwm) + fancontrol_debug("TempEmergencyCountdown: %d, over_emerg_countdown_pwm = 0x%x" % + (self.__emergency_countdown, over_emerg_countdown_pwm)) + + if self.__check_temp_critical == 1: + status = self.checkTempCritical() + if status == True: + over_crit_pwm = self.__max_pwm + pwm_list.append(over_crit_pwm) + fancontrol_debug("over_crit_pwm = 0x%x" % over_crit_pwm) + # do reset check + if self.__check_crit_reboot_flag == 1: + self.checkCritReboot() + else: + if self.checkTempCriticalCountdown() == True: # temp lower than critical in 5 min + over_crit_countdown_pwm = self.__max_pwm + pwm_list.append(over_crit_countdown_pwm) + fancontrol_debug("TempCriticalCountdown: %d, over_crit_countdown_pwm = 0x%x" % + (self.__critical_countdown, over_crit_countdown_pwm)) + + if self.__check_temp_warning == 1: + status = self.checkTempWarning() + if status == True: + over_warn_pwm = self.__warning_pwm + pwm_list.append(over_warn_pwm) + fancontrol_debug("over_warn_pwm = 0x%x" % over_warn_pwm) + else: + if self.checkTempWarningCountdown() == True: # temp lower than warning in 5 min + over_warn_countdown_pwm = self.__warning_pwm + pwm_list.append(over_warn_countdown_pwm) + fancontrol_debug("TempWarningCountdown: %d, over_warn_countdown_pwm = 0x%x" % + (self.__warning_countdown, over_warn_countdown_pwm)) + + self.__fan_absent_num = self.checkFanPresence() + if self.__fan_absent_num >= self.__fan_absent_fullspeed_num: + fan_absent_pwm = self.__max_pwm + pwm_list.append(fan_absent_pwm) + fancontrol_debug("fan_absent_pwm = 0x%x" % fan_absent_pwm) + + rotor_err_num = self.checkFanRotorStatus() + if rotor_err_num >= self.__rotor_error_fullspeed_num: + rotor_err_pwm = self.__max_pwm + pwm_list.append(rotor_err_pwm) + fancontrol_debug("rotor_err_pwm = 0x%x" % rotor_err_pwm) + + psu_absent_num = self.checkPsuPresence() + if psu_absent_num >= self.__psu_absent_fullspeed_num: + psu_absent_pwm = self.__max_pwm + pwm_list.append(psu_absent_pwm) + fancontrol_debug("psu_absent_pwm = 0x%x" % psu_absent_pwm) + + dev_err_pwm = self.checkDevError() + pwm_list.append(dev_err_pwm) + fancontrol_debug("dev_err_pwm = 0x%x" % dev_err_pwm) + + temp_fail_pwm = self.checktempfail() + pwm_list.append(temp_fail_pwm) + fancontrol_debug("temp_fail_pwm = 0x%x" % temp_fail_pwm) + + pwm = max(pwm_list) + return pwm + + def get_error_fan(self): + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + if self.__fan_rotate_status[fan_name] == 0: + return fan_name + return None + + def fan_error_update_pwm(self, fan_pwm_dict): + try: + fancontrol_debug("enter deal fan error policy") + ori_fan_pwm_dict = fan_pwm_dict.copy() + + err_fan_name = self.get_error_fan() + if err_fan_name is None: + fancontrol_debug("fan name is None, do nothing.") + return ori_fan_pwm_dict + + if self.__fan_repair_flag[err_fan_name] == 0: + fancontrol_debug("%s already repaired, do nothing." % err_fan_name) + return ori_fan_pwm_dict + + if self.__pre_fan_nok != err_fan_name: + fancontrol_debug( + "not ok fan change from %s to %s, update countdown." % + (self.__pre_fan_nok, err_fan_name)) + self.__deal_fan_error_countdown = self.__deal_fan_error_default_countdown + if self.__pre_fan_nok != PRE_FAN_NOK_UNKNOWN: + fancontrol_debug( + "%s repaire success, %s NOT OK, try to repaire." % + (self.__pre_fan_nok, err_fan_name)) + self.__fan_repair_flag[self.__pre_fan_nok] = 0 + self.__pre_fan_nok = err_fan_name + + if self.__deal_fan_error_countdown > 0: + self.__deal_fan_error_countdown -= 1 + fancontrol_debug("%s repaire, countdown %d." % (err_fan_name, self.__deal_fan_error_countdown)) + + if self.__deal_fan_error_countdown == 0: + self.__fan_repair_flag[err_fan_name] = 0 + fancontrol_debug("%s set repaire fail flag, use origin pwm." % err_fan_name) + return ori_fan_pwm_dict + + fan_err_pwm_conf_list = self.__deal_fan_error_conf[err_fan_name] + for item in fan_err_pwm_conf_list: + fan_pwm_dict[item["name"]] = item["pwm"] + fancontrol_debug("fan pwm update, fan pwm dict:%s" % fan_pwm_dict) + + return fan_pwm_dict + except Exception as e: + fancontrol_error("%%policy: deal_fan_error raise Exception:%s" % str(e)) + self.__pre_fan_nok = PRE_FAN_NOK_UNKNOWN + return ori_fan_pwm_dict + + def get_fan_pwm_dict(self, default_pwm): + fan_pwm_dict = {} + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + fan_pwm_dict[fan_name] = default_pwm + if self.__deal_fan_error_policy: + if self.__fan_absent_num == 0 and self.__fan_nok_num == 1: + fan_pwm_dict = self.fan_error_update_pwm(fan_pwm_dict) + else: + if self.__pre_fan_nok != PRE_FAN_NOK_UNKNOWN and self.__fan_rotate_status[self.__pre_fan_nok] == 1: + fancontrol_debug("%s repaire success." % (self.__pre_fan_nok)) + self.__fan_repair_flag[self.__pre_fan_nok] = 0 + self.__pre_fan_nok = PRE_FAN_NOK_UNKNOWN + return fan_pwm_dict + + def check_board_air_flow(self): + board_air_flow = self.board_air_flow + if board_air_flow != F2B_AIR_FLOW and board_air_flow != B2F_AIR_FLOW: + fanairflow_debug("get board air flow error, value [%s]" % board_air_flow) + return False + fanairflow_debug("board air flow check ok: %s" % board_air_flow) + return True + + def check_fan_air_flow(self): + if self.fan_air_flow_monitor: + fanairflow_debug("open air flow monitor, check fan air flow") + ret = self.check_board_air_flow() + if ret is False: + fanairflow_debug("get board air flow error, set air_flow_inconsistent_flag False") + self.air_flow_inconsistent_flag = False + return + air_flow_inconsistent_flag_tmp = False + for fan_obj in self.fan_obj_list: + fan_obj.update_fru_info() + fanairflow_debug("%s origin name: [%s], display name: [%s] air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow)) + if fan_obj.air_flow == self.na_ret: + fanairflow_debug("%s get air flow failed, set air_flow_inconsistent flag False" % fan_obj.name) + fan_obj.air_flow_inconsistent = False + continue + if fan_obj.air_flow != self.board_air_flow: + fanairflow_debug("%s air flow error, origin name: [%s], display name: [%s], fan air flow [%s], board air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow)) + air_flow_inconsistent_flag_tmp = True + fan_obj.air_flow_inconsistent = True + else: + fanairflow_debug("%s air flow check ok, origin name: [%s], display name: [%s], fan air flow: [%s], board air flow: [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow)) + fan_obj.air_flow_inconsistent = False + self.air_flow_inconsistent_flag = air_flow_inconsistent_flag_tmp + else: + fanairflow_debug("air flow monitor not open, set air_flow_inconsistent_flag False") + self.air_flow_inconsistent_flag = False + return + + def do_fancontrol(self): + pwm_list = [] + pwm_min = self.__min_pwm + pwm_list.append(pwm_min) + + # first check fan air flow + self.check_fan_air_flow() + fanairflow_debug("check_fan_air_flow, air_flow_inconsistent_flag: %s" % self.air_flow_inconsistent_flag) + # get_monitor_temp + self.get_monitor_temp() + fancontrol_debug("last_pwm = 0x%x" % self.__pwm) + # openloop + inlettemp = self.__temps_threshold_config.get(INLET_TEMP)['temp'] + linear_value = self.openloop.linear_cacl(inlettemp) + if linear_value is None: + linear_value = self.__min_pwm + pwm_list.append(linear_value) + fancontrol_debug("linear_value = 0x%x" % linear_value) + + curve_value = self.openloop.curve_cacl(inlettemp) + if curve_value is None: + curve_value = self.__min_pwm + pwm_list.append(curve_value) + fancontrol_debug("curve_value = 0x%x" % curve_value) + + # hyst + for hyst_index in self.__hyst_config.values(): + temp_name = hyst_index['name'] + tmp_temp = int(self.__temps_threshold_config.get(temp_name)['temp']) # make sure temp is int + hyst_value = self.hyst.cacl(temp_name, tmp_temp) + if hyst_value is None: + hyst_value = self.__min_pwm + pwm_list.append(hyst_value) + fancontrol_debug("%s hyst_value = 0x%x" % (temp_name, hyst_value)) + + # pid + for pid_index in self.__pid_config.values(): + temp_name = pid_index['name'] + tmp_temp = self.__temps_threshold_config.get(temp_name)['temp'] + if tmp_temp is not None: + tmp_temp = int(tmp_temp) # make sure temp is int + invalid_temp = self.__temps_threshold_config.get(temp_name)['invalid'] + error_temp = self.__temps_threshold_config.get(temp_name)['error'] + if tmp_temp == invalid_temp: # temp is invalid + temp = None + self.pid.cacl(self.__pwm, temp_name, temp) # temp invalid, PID need to record None + pid_value = self.__temp_invalid_pid_pwm + fancontrol_debug("%s is invalid, pid_value = 0x%x" % (temp_name, pid_value)) + fancontrol_debug("temp = %d, invalid_temp = %d" % (tmp_temp, invalid_temp)) + elif tmp_temp == error_temp: # temp is error + temp = None + self.pid.cacl(self.__pwm, temp_name, temp) # temp error, PID need to record None + pid_value = self.__temp_error_pid_pwm + fancontrol_debug("%s is error, pid_value = 0x%x" % (temp_name, pid_value)) + fancontrol_debug("temp = %d, error_temp = %d" % (tmp_temp, error_temp)) + else: + pid_value = self.pid.cacl(self.__pwm, temp_name, tmp_temp) + else: # temp get failed + pid_value = self.pid.cacl(self.__pwm, temp_name, tmp_temp) + if pid_value is None: + pid_value = self.__min_pwm + pwm_list.append(pid_value) + fancontrol_debug("%s pid_value = 0x%x" % (temp_name, pid_value)) + + # abnormal + abnormal_value = self.abnormal_check() + pwm_list.append(abnormal_value) + fancontrol_debug("abnormal_value = 0x%x" % abnormal_value) + + if self.__fan_plug_in_countdown > 0 and self.__fan_absent_num == 0: + fancontrol_debug("fan plug in countdown %d, set plug in pwm: 0x%x" % + (self.__fan_plug_in_countdown, self.__fan_plug_in_pwm)) + self.__pwm = self.__fan_plug_in_pwm + self.__fan_plug_in_countdown -= 1 + else: + self.__pwm = max(pwm_list) + fancontrol_debug("__pwm = 0x%x\n" % self.__pwm) + if self.air_flow_inconsistent_flag is True: + fanairflow_debug("air flow inconsistent, set all fan speed pwm") + self.set_all_fan_speed_pwm(self.__pwm) + else: + fanairflow_debug("air flow consistent, deal fan error policy") + fan_pwm_dict = self.get_fan_pwm_dict(self.__pwm) + self.set_fan_pwm_independent(fan_pwm_dict, self.__pwm) + + def run(self): + start_time = time.time() + while True: + try: + debug_init() + if self.__fan_status_interval > 0 and self.__fan_status_interval < self.__interval: + delta_time = time.time() - start_time + if delta_time >= self.__interval or delta_time < 0: + self.do_fancontrol() + start_time = time.time() + else: + self.checkFanPresence() + time.sleep(self.__fan_status_interval) + else: + self.do_fancontrol() + time.sleep(self.__interval) + except Exception as e: + traceback.print_exc() + fancontrol_error(str(e)) + + def set_all_fan_speed_pwm(self, pwm): + fan_pwm_dict = {} + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + fan_pwm_dict[fan_name] = pwm + self.set_fan_pwm_independent(fan_pwm_dict, pwm) + + def set_fan_pwm_independent(self, fan_pwm_dict, psu_fan_pwm): + if self.air_flow_inconsistent_flag is True: + psu_fan_pwm = self.air_flow_error_psu_pwm + fancontrol_debug("air flow inconsistent, set psu fan pwm: 0x%x" % psu_fan_pwm) + for fan_obj in self.fan_obj_list: + if fan_obj.air_flow_inconsistent is True: + fan_pwm_dict[fan_obj.name] = self.air_flow_error_fan_pwm + fanairflow_debug("%s air flow error, origin name: [%s], display name: [%s], fan air flow: [%s], board air flow: [%s], set fan pwm: 0x%x" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow, self.air_flow_error_fan_pwm)) + else: + fan_pwm_dict[fan_obj.name] = self.air_flow_correct_fan_pwm + fanairflow_debug("%s air flow correct, origin name: [%s], display name: [%s], fan air flow: [%s], board air flow: [%s], set fan pwm: 0x%x" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow, self.air_flow_correct_fan_pwm)) + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + self.fan_set_speed_pwm_by_name(fan_name, fan_pwm_dict[fan_name]) + if self.__psu_fan_control == 1: + self.set_psu_fan_speed_pwm(psu_fan_pwm) + + def get_fans(self): + return self.int_case.get_fans() + + def get_speed(self, fan_name, rotor_index): + return self.int_case.get_fan_speed(fan_name, rotor_index) + + def get_speed_pwm(self, fan_name, rotor_index): + return self.int_case.get_fan_speed_pwm(fan_name, rotor_index) + + def fan_get_speed_pwm(self): + fans = self.get_fans() + for fan in fans: + rotor_len = self.get_rotor_number(fan.name) + for i in range(rotor_len): + fancontrol_debug("%s rotor%d: %d" % (fan.name, i + 1, self.get_speed_pwm(fan.name, i + 1))) + + def fan_set_speed_pwm_by_name(self, fan_name, pwm): + duty = round(pwm * 100 / 255) + rotor_len = self.get_rotor_number(fan_name) + for i in range(rotor_len): + val = self.int_case.set_fan_speed_pwm(fan_name, i + 1, duty) + if val != 0: + fancontrol_error("%s rotor%d: %d" % (fan_name, i + 1, val)) + + def set_psu_fan_speed_pwm(self, pwm): + duty = round(pwm * 100 / 255) + psu_num = self.get_psu_total_number() + for i in range(psu_num): + psu_name = "PSU" + str(i + 1) + status = self.int_case.set_psu_fan_speed_pwm(psu_name, int(duty)) + if status != True: + fancontrol_error("set %s speed fail" % psu_name) + + def fan_obj_init(self): + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + fan_obj = DevFan(fan_name, self.int_case) + self.fan_obj_list.append(fan_obj) + fanairflow_debug("fan object initialize success") + + +if __name__ == '__main__': + debug_init() + fancontrol_debug("enter main") + fan_control = fancontrol() + fan_control.fan_obj_init() + fan_control.run() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_ledctrl.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_ledctrl.py new file mode 100755 index 000000000000..223b4e2ba437 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/hal_ledctrl.py @@ -0,0 +1,792 @@ +#!/usr/bin/env python3 +import time +import syslog +import traceback +from plat_hal.interface import interface +from plat_hal.baseutil import baseutil +try: + import abc +except ImportError as e: + raise ImportError (str(e) + " - required module not found") + +SWITCH_TEMP = "SWITCH_TEMP" +F2B_AIR_FLOW = "F2B" +B2F_AIR_FLOW = "B2F" +ONIE_E2_NAME = "ONIE_E2" + +# status +STATUS_PRESENT = "PRESENT" +STATUS_ABSENT = "ABSENT" +STATUS_OK = "OK" +STATUS_NOT_OK = "NOT OK" +STATUS_FAILED = "FAILED" +STATUS_UNKNOWN = "UNKNOWN" + +LEDCTROL_DEBUG_FILE = "/etc/.ledcontrol_debug_flag" + +LEDCTROLERROR = 1 +LEDCTROLDEBUG = 2 + +debuglevel = 0 +# led status defined +COLOR_GREEN = 1 +COLOR_YELLOW = 2 +COLOR_RED = 3 +LED_STATUS_DICT = {COLOR_GREEN: "green", COLOR_YELLOW: "yellow", COLOR_RED: "red"} + + +def ledcontrol_debug(s): + if LEDCTROLDEBUG & debuglevel: + syslog.openlog("LEDCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def ledcontrol_error(s): + if LEDCTROLERROR & debuglevel: + syslog.openlog("LEDCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def air_flow_warn(s): + syslog.openlog("AIR_FLOW_MONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_WARNING, s) + + +def air_flow_error(s): + syslog.openlog("AIR_FLOW_MONITOR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def debug_init(): + global debuglevel + try: + with open(LEDCTROL_DEBUG_FILE, "r") as fd: + value = fd.read() + debuglevel = int(value) + except Exception as e: + debuglevel = 0 + + +class DevBase(object): + __metaclass__ = abc.ABCMeta + + def __init__(self, name, air_flow_monitor): + self.__name = name + self.__air_flow_monitor = air_flow_monitor + self.present = STATUS_UNKNOWN + self.status = STATUS_UNKNOWN + self.status_summary = STATUS_UNKNOWN + self.origin_name = STATUS_UNKNOWN + self.display_name = STATUS_UNKNOWN + self.air_flow = STATUS_UNKNOWN + self.led_status = COLOR_GREEN + + @property + def name(self): + return self.__name + + @property + def air_flow_monitor(self): + return self.__air_flow_monitor + + @abc.abstractmethod + def get_present(self): + """ + Gets the present status of PSU/FAN + + Returns: + A string, e.g. 'PRESENT, ABSENT, FAILED' + """ + raise NotImplementedError + + @abc.abstractmethod + def get_status(self): + """ + Gets the status of PSU/FAN + + Returns: + A string, e.g. 'OK, NOT OK, FAILED' + """ + raise NotImplementedError + + @abc.abstractmethod + def update_dev_info(self): + """ + update status and fru info of PSU/FAN + + include present, status, status_summary, part_model_name, product_name, air_flow + """ + raise NotImplementedError + + @abc.abstractmethod + def set_module_led(self, color): + """ + set PSU/FAN module LED status + + Args: + color: A string representing the color with which to set the + PSU/FAN module LED status + + Returns: + bool: True if status LED state is set successfully, False if not + """ + raise NotImplementedError + + +class DevPsu(DevBase): + + def __init__(self, name, air_flow_monitor, interface): + super(DevPsu, self).__init__(name, air_flow_monitor) + self.int_case = interface + + def get_psu_presence(self): + return self.int_case.get_psu_presence(self.name) + + def get_psu_input_output_status(self): + return self.int_case.get_psu_input_output_status(self.name) + + def get_psu_fru_info(self): + return self.int_case.get_psu_fru_info(self.name) + + @property + def na_ret(self): + return self.int_case.na_ret + + def get_present(self): + try: + status = self.get_psu_presence() + if status is True: + return STATUS_PRESENT + if status is False: + return STATUS_ABSENT + except Exception as e: + ledcontrol_error("get %s present status error, msg: %s" % (self.name, str(e))) + return STATUS_FAILED + + def get_status(self): + try: + status = self.get_psu_input_output_status() + if status is True: + return STATUS_OK + if status is False: + return STATUS_NOT_OK + except Exception as e: + ledcontrol_error("get %s status error, msg: %s" % (self.name, str(e))) + return STATUS_FAILED + + def update_dev_info(self): + try: + # update status + self.present = self.get_present() + if self.present != STATUS_PRESENT: + self.status = STATUS_UNKNOWN + self.status_summary = self.present + else: + self.status = self.get_status() + self.status_summary = self.status + # update fru info if need air flow monitor + if self.air_flow_monitor: + dic = self.get_psu_fru_info() + self.origin_name = dic["PN"] + self.air_flow = dic["AirFlow"] + self.display_name = dic["DisplayName"] + except Exception as e: + ledcontrol_error("update %s info error, msg: %s" % (self.name, str(e))) + self.present = STATUS_FAILED + self.status = STATUS_FAILED + self.status_summary = STATUS_FAILED + self.origin_name = self.na_ret + self.air_flow = self.na_ret + self.display_name = self.na_ret + + def set_module_led(self, color): + """ + set PSU module LED is not support, always return True + """ + return True + + +class DevFan(DevBase): + + def __init__(self, name, air_flow_monitor, interface): + super(DevFan, self).__init__(name, air_flow_monitor) + self.int_case = interface + + def get_fan_rotor_number(self): + return self.int_case.get_fan_rotor_number(self.name) + + def get_fan_presence(self): + return self.int_case.get_fan_presence(self.name) + + def get_fan_rotor_status(self, rotor_name): + return self.int_case.get_fan_rotor_status(self.name, rotor_name) + + def get_fan_fru_info(self): + return self.int_case.get_fan_fru_info(self.name) + + @property + def na_ret(self): + return self.int_case.na_ret + + def get_present(self): + try: + status = self.get_fan_presence() + if status is True: + return STATUS_PRESENT + if status is False: + return STATUS_ABSENT + except Exception as e: + ledcontrol_error("get %s present status error, msg: %s" % (self.name, str(e))) + return STATUS_FAILED + + def get_status(self): + try: + rotor_num = self.get_fan_rotor_number() + err_motor_num = 0 + for j in range(rotor_num): + rotor_name = "Rotor" + str(j + 1) + roll_status = self.get_fan_rotor_status(rotor_name) + if roll_status is not True: + err_motor_num += 1 + ledcontrol_debug("%s %s error, status %s" % (self.name, rotor_name, roll_status)) + else: + ledcontrol_debug("%s %s ok" % (self.name, rotor_name)) + if err_motor_num > 0: + return STATUS_NOT_OK + return STATUS_OK + except Exception as e: + ledcontrol_error("get %s status error, msg: %s" % (self.name, str(e))) + return STATUS_FAILED + + def update_dev_info(self): + try: + # update status + self.present = self.get_present() + if self.present != STATUS_PRESENT: + self.status = STATUS_UNKNOWN + self.status_summary = self.present + else: + self.status = self.get_status() + self.status_summary = self.status + # update fru info if need air flow monitor + if self.air_flow_monitor: + dic = self.get_fan_fru_info() + self.origin_name = dic["PN"] + self.air_flow = dic["AirFlow"] + self.display_name = dic["DisplayName"] + except Exception as e: + ledcontrol_error("update %s fru info error, msg: %s" % (self.name, str(e))) + self.present = STATUS_FAILED + self.status = STATUS_FAILED + self.status_summary = STATUS_FAILED + self.origin_name = self.na_ret + self.air_flow = self.na_ret + self.display_name = self.na_ret + + def set_module_led(self, color): + ret = self.int_case.set_fan_led(self.name, color) + if ret == 0: + return True + return False + + +class ledcontrol(object): + + def __init__(self): + self.fan_obj_list = [] + self.psu_obj_list = [] + self.board_psu_led_status = COLOR_GREEN + self.board_fan_led_status = COLOR_GREEN + self.__board_air_flow = "" + self.int_case = interface() + self.__config = baseutil.get_monitor_config() + self.__temps_threshold_config = self.__config["temps_threshold"] + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['temp'] = 0 + temp_threshold['fail_num'] = 0 + self.__ledcontrol_para = self.__config["ledcontrol_para"] + self.__interval = self.__ledcontrol_para.get("interval", 5) + self.__checkpsu = self.__ledcontrol_para.get("checkpsu", 0) + self.__checkfan = self.__ledcontrol_para.get("checkfan", 0) + self.__psu_yellow_num = self.__ledcontrol_para.get("psu_yellow_num") + self.__fan_yellow_num = self.__ledcontrol_para.get("fan_yellow_num") + self.__board_sys_led = self.__ledcontrol_para.get("board_sys_led", []) + self.__board_psu_led = self.__ledcontrol_para.get("board_psu_led", []) + self.__board_fan_led = self.__ledcontrol_para.get("board_fan_led", []) + self.__psu_air_flow_monitor = self.__ledcontrol_para.get("psu_air_flow_monitor", 0) + self.__fan_air_flow_monitor = self.__ledcontrol_para.get("fan_air_flow_monitor", 0) + self.__fan_mix_list = self.__ledcontrol_para.get("fan_mix_list", []) + + @property + def na_ret(self): + return self.int_case.na_ret + + @property + def checkpsu(self): + return self.__checkpsu + + @property + def checkfan(self): + return self.__checkfan + + @property + def psu_yellow_num(self): + return self.__psu_yellow_num + + @property + def fan_yellow_num(self): + return self.__fan_yellow_num + + @property + def psu_air_flow_monitor(self): + return self.__psu_air_flow_monitor + + @property + def fan_air_flow_monitor(self): + return self.__fan_air_flow_monitor + + @property + def board_sys_led(self): + return self.__board_sys_led + + @property + def board_psu_led(self): + return self.__board_psu_led + + @property + def board_fan_led(self): + return self.__board_fan_led + + @property + def fan_mix_list(self): + return self.__fan_mix_list + + @property + def interval(self): + return self.__interval + + def get_fan_total_number(self): + return self.int_case.get_fan_total_number() + + def get_psu_total_number(self): + return self.int_case.get_psu_total_number() + + def get_onie_e2_obj(self, name): + return self.int_case.get_onie_e2_obj(name) + + def set_led_color(self, led_name, color): + try: + ret = self.int_case.set_led_color(led_name, color) + except Exception as e: + ledcontrol_error("set %s led %s error, msg: %s" % (led_name, color, str(e))) + ret = False + return ret + + def set_sys_led(self, color): + for led in self.board_sys_led: + led_name = led.get("led_name") + ret = self.set_led_color(led_name, color) + if ret is True: + ledcontrol_debug("set %s success, color:%s," % (led_name, color)) + else: + ledcontrol_debug("set %s failed, color:%s," % (led_name, color)) + + def set_psu_led(self, color): + for led in self.board_psu_led: + led_name = led.get("led_name") + ret = self.set_led_color(led_name, color) + if ret is True: + ledcontrol_debug("set %s success, color:%s," % (led_name, color)) + else: + ledcontrol_debug("set %s failed, color:%s," % (led_name, color)) + + def set_fan_led(self, color): + for led in self.board_fan_led: + led_name = led.get("led_name") + ret = self.set_led_color(led_name, color) + if ret is True: + ledcontrol_debug("set %s success, color:%s," % (led_name, color)) + else: + ledcontrol_debug("set %s failed, color:%s," % (led_name, color)) + + def set_fan_module_led(self): + for fan_obj in self.fan_obj_list: + color = LED_STATUS_DICT.get(fan_obj.led_status) + ret = fan_obj.set_module_led(color) + if ret is True: + ledcontrol_debug("set %s module led success, color: %s," % (fan_obj.name, color)) + else: + ledcontrol_debug("set %s module led failed, color: %s," % (fan_obj.name, color)) + + @property + def board_air_flow(self): + if self.__board_air_flow != F2B_AIR_FLOW and self.__board_air_flow != B2F_AIR_FLOW: + onie_e2_obj = self.get_onie_e2_obj(ONIE_E2_NAME) + if onie_e2_obj is not None: + ledcontrol_debug("onie_e2 servicetag: %s" % onie_e2_obj.servicetag) + if isinstance(onie_e2_obj.servicetag, str) and onie_e2_obj.servicetag.startswith("F2B"): + self.__board_air_flow = F2B_AIR_FLOW + elif isinstance(onie_e2_obj.servicetag, str) and onie_e2_obj.servicetag.startswith("B2F"): + self.__board_air_flow = B2F_AIR_FLOW + else: + self.__board_air_flow = onie_e2_obj.servicetag + ledcontrol_debug("board_air_flow: %s" % self.__board_air_flow) + return self.__board_air_flow + + def update_psu_info(self): + for psu_obj in self.psu_obj_list: + psu_obj.update_dev_info() + ledcontrol_debug("%s present: [%s], status: [%s] status_summary [%s]" % + (psu_obj.name, psu_obj.present, psu_obj.status, psu_obj.status_summary)) + if psu_obj.air_flow_monitor: + ledcontrol_debug("%s origin name: [%s], display name: [%s] air flow [%s]" % + (psu_obj.name, psu_obj.origin_name, psu_obj.display_name, psu_obj.air_flow)) + + def update_fan_info(self): + for fan_obj in self.fan_obj_list: + fan_obj.update_dev_info() + ledcontrol_debug("%s present: [%s], status: [%s] status_summary [%s]" % + (fan_obj.name, fan_obj.present, fan_obj.status, fan_obj.status_summary)) + if fan_obj.air_flow_monitor: + ledcontrol_debug("%s origin name: [%s], display name: [%s] air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow)) + + def get_monitor_temp(self): + sensorlist = self.int_case.get_temp_info() + + for temp_threshold in self.__temps_threshold_config.values(): + sensor = sensorlist.get(temp_threshold['name']) + if sensor["Value"] is None: + temp_threshold['fail_num'] += 1 + ledcontrol_error("get %s failed, fail_num = %d" % (temp_threshold['name'], temp_threshold['fail_num'])) + else: + temp_threshold['fail_num'] = 0 + temp_threshold.setdefault('fix', 0) + temp_threshold['temp'] = sensor["Value"] + temp_threshold['fix'] + ledcontrol_debug("%s = %d" % (temp_threshold['name'], temp_threshold['temp'])) + ledcontrol_debug("warning = %d, critical = %d" % (temp_threshold['warning'], temp_threshold['critical'])) + + def is_temp_warning(self): + warning_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + if temp_threshold['temp'] >= temp_threshold['warning']: + warning_flag = True + ledcontrol_debug("%s is over warning" % temp_threshold['name']) + ledcontrol_debug( + "%s = %d, warning = %d" % + (temp_threshold['name'], + temp_threshold['temp'], + temp_threshold['warning'])) + return warning_flag + + def checkTempWarning(self): + try: + if self.is_temp_warning(): + ledcontrol_debug("temp is over warning") + return True + except Exception as e: + ledcontrol_error("%%policy: checkTempWarning failed") + ledcontrol_error(str(e)) + return False + + def is_temp_critical(self): + critical_flag = False + for temp_threshold in self.__temps_threshold_config.values(): + temp_threshold['critical_flag'] = False + if temp_threshold['temp'] >= temp_threshold['critical']: + critical_flag = True + temp_threshold['critical_flag'] = True + ledcontrol_debug("%s is over critical" % temp_threshold['name']) + ledcontrol_debug( + "%s = %d, critical = %d" % + (temp_threshold['name'], + temp_threshold['temp'], + temp_threshold['critical'])) + return critical_flag + + def checkTempCrit(self): + try: + if self.is_temp_critical(): + temp_dict = dict(self.__temps_threshold_config) + tmp = temp_dict.get(SWITCH_TEMP) + if tmp['critical_flag'] == True: + ledcontrol_debug("temp is over critical") + return True + + del temp_dict[SWITCH_TEMP] + for temp_items in temp_dict.values(): + if temp_items['critical_flag'] == False: + return False + + ledcontrol_debug("temp is over critical") + return True + except Exception as e: + ledcontrol_error("%%policy: checkTempCrit failed") + ledcontrol_error(str(e)) + return False + + def check_board_air_flow(self): + board_air_flow = self.board_air_flow + if board_air_flow != F2B_AIR_FLOW and board_air_flow != B2F_AIR_FLOW: + air_flow_error("%%AIR_FLOW_MONITOR-3-ERROR: get board air flow error, value [%s]" % board_air_flow) + return False + ledcontrol_debug("board air flow check ok: %s" % board_air_flow) + return True + + def get_monitor_fan_status(self): + fanerrnum = 0 + for fan_obj in self.fan_obj_list: + status = fan_obj.status_summary + ledcontrol_debug("%s status: %s" % (fan_obj.name, status)) + if status != STATUS_OK: + fan_obj.led_status = COLOR_RED + fanerrnum += 1 + else: + fan_obj.led_status = COLOR_GREEN + ledcontrol_debug("fan error number: %d" % fanerrnum) + + if fanerrnum == 0: + fan_led_status = COLOR_GREEN + elif fanerrnum <= self.fan_yellow_num: + fan_led_status = COLOR_YELLOW + else: + fan_led_status = COLOR_RED + ledcontrol_debug("monitor fan status, set fan led: %s" % LED_STATUS_DICT.get(fan_led_status)) + return fan_led_status + + def get_monitor_psu_status(self): + psuerrnum = 0 + for psu_obj in self.psu_obj_list: + status = psu_obj.status_summary + ledcontrol_debug("%s status: %s" % (psu_obj.name, status)) + if status != STATUS_OK: + psu_obj.led_status = COLOR_RED + psuerrnum += 1 + else: + psu_obj.led_status = COLOR_GREEN + ledcontrol_debug("psu error number: %d" % psuerrnum) + + if psuerrnum == 0: + psu_led_status = COLOR_GREEN + elif psuerrnum <= self.psu_yellow_num: + psu_led_status = COLOR_YELLOW + else: + psu_led_status = COLOR_RED + ledcontrol_debug("monitor psu status, set psu led: %s" % LED_STATUS_DICT.get(psu_led_status)) + return psu_led_status + + def get_monitor_fan_air_flow(self): + if self.fan_air_flow_monitor == 0: + ledcontrol_debug("fan air flow monitor not open, default green") + return COLOR_GREEN + + ret = self.check_board_air_flow() + if ret is False: + ledcontrol_debug("check board air flow error, skip fan air flow monitor.") + return COLOR_GREEN + + fan_led_status_list = [] + fan_air_flow_ok_obj_list = [] + fan_air_flow_ok_set = set() + fan_module_led_list = [] + for fan_obj in self.fan_obj_list: + if fan_obj.present != STATUS_PRESENT: + fan_module_led_list.append(COLOR_GREEN) + continue + if fan_obj.air_flow == self.na_ret: + air_flow_warn("%%AIR_FLOW_MONITOR-4-WARN: %s get air flow failed, origin name: [%s], display name: [%s], air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow)) + led_status = COLOR_YELLOW + elif fan_obj.air_flow != self.board_air_flow: + air_flow_error("%%AIR_FLOW_MONITOR-3-ERROR: %s air flow error, origin name: [%s], display name: [%s], fan air flow [%s], board air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow)) + led_status = COLOR_RED + else: + fan_air_flow_ok_obj_list.append(fan_obj) + fan_air_flow_ok_set.add(fan_obj.origin_name) + ledcontrol_debug("%s air flow check ok, origin name: [%s], display name: [%s], fan air flow: [%s], board air flow: [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow, self.board_air_flow)) + led_status = COLOR_GREEN + fan_module_led_list.append(led_status) + if led_status > fan_obj.led_status: + fan_obj.led_status = led_status + + fan_led_status = max(fan_module_led_list) + fan_led_status_list.append(fan_led_status) + if len(fan_air_flow_ok_set) > 1 and fan_air_flow_ok_set not in self.fan_mix_list: + for fan_obj in fan_air_flow_ok_obj_list: + air_flow_warn("%%AIR_FLOW_MONITOR-4-WARN: %s mixing, origin name: [%s], display name: [%s], air flow [%s]" % + (fan_obj.name, fan_obj.origin_name, fan_obj.display_name, fan_obj.air_flow)) + fan_led_status = COLOR_YELLOW + fan_led_status_list.append(fan_led_status) + + fan_led_status = max(fan_led_status_list) + ledcontrol_debug("monitor fan air flow, set fan led: %s" % LED_STATUS_DICT.get(fan_led_status)) + return fan_led_status + + def get_monitor_psu_air_flow(self): + if self.psu_air_flow_monitor == 0: + ledcontrol_debug("psu air flow monitor not open, default green") + return COLOR_GREEN + + ret = self.check_board_air_flow() + if ret is False: + ledcontrol_debug("check board air flow error, skip psu air flow monitor.") + return COLOR_GREEN + + psu_module_led_list = [] + for psu_obj in self.psu_obj_list: + if psu_obj.present != STATUS_PRESENT: + psu_module_led_list.append(COLOR_GREEN) + continue + if psu_obj.air_flow == self.na_ret: + air_flow_warn("%%AIR_FLOW_MONITOR-4-WARN: %s get air flow failed, origin name: [%s], display name: [%s], air flow [%s]" % + (psu_obj.name, psu_obj.origin_name, psu_obj.display_name, psu_obj.air_flow)) + led_status = COLOR_YELLOW + elif psu_obj.air_flow != self.board_air_flow: + air_flow_error("%%AIR_FLOW_MONITOR-3-ERROR: %s air flow error, origin name: [%s], display name: [%s], psu air flow [%s], board air flow [%s]" % + (psu_obj.name, psu_obj.origin_name, psu_obj.display_name, psu_obj.air_flow, self.board_air_flow)) + led_status = COLOR_RED + else: + ledcontrol_debug("%s psu air flow check ok, origin name: [%s], display name: [%s], psu air flow: [%s], board air flow: [%s]" % + (psu_obj.name, psu_obj.origin_name, psu_obj.display_name, psu_obj.air_flow, self.board_air_flow)) + led_status = COLOR_GREEN + psu_module_led_list.append(led_status) + if led_status > psu_obj.led_status: + psu_obj.led_status = led_status + + psu_led_status = max(psu_module_led_list) + ledcontrol_debug("monitor psu air flow, set psu led: %s" % LED_STATUS_DICT.get(psu_led_status)) + return psu_led_status + + def get_temp_sys_led_status(self): + if self.checkTempCrit() is True: + sys_led_status = COLOR_RED + elif self.checkTempWarning() is True: + sys_led_status = COLOR_YELLOW + else: + sys_led_status = COLOR_GREEN + ledcontrol_debug("monitor temperature, set sys led: %s" % LED_STATUS_DICT.get(sys_led_status)) + return sys_led_status + + def get_sys_led_follow_fan_status(self): + + if self.checkfan: + sys_led_status = self.board_fan_led_status + ledcontrol_debug("sys led follow fan led, set sys led: %s" % LED_STATUS_DICT.get(sys_led_status)) + else: + sys_led_status = COLOR_GREEN + ledcontrol_debug("sys led don't follow fan led, set default green") + return sys_led_status + + def get_sys_led_follow_psu_status(self): + if self.checkpsu: + sys_led_status = self.board_psu_led_status + ledcontrol_debug("sys led follow psu led, set sys led: %s" % LED_STATUS_DICT.get(sys_led_status)) + else: + sys_led_status = COLOR_GREEN + ledcontrol_debug("sys led don't follow psu led, set default green") + return sys_led_status + + def dealSysLedStatus(self): + sys_led_status_list = [] + # get_monitor_temp + self.get_monitor_temp() + + # monitor temp get sys led status + sys_led_status = self.get_temp_sys_led_status() + sys_led_status_list.append(sys_led_status) + + # check sys led follow fan led status + sys_led_status = self.get_sys_led_follow_fan_status() + sys_led_status_list.append(sys_led_status) + + # check sys led follow psu led status + sys_led_status = self.get_sys_led_follow_psu_status() + sys_led_status_list.append(sys_led_status) + + sys_led_status = max(sys_led_status_list) + sys_led_color = LED_STATUS_DICT.get(sys_led_status) + + # set sys led + self.set_sys_led(sys_led_color) + + def dealFanLedStatus(self): + fan_led_status_list = [] + # update fan info + self.update_fan_info() + + # monitor fan status first + fan_led_status = self.get_monitor_fan_status() + fan_led_status_list.append(fan_led_status) + + # monitor fan air flow + fan_led_status = self.get_monitor_fan_air_flow() + fan_led_status_list.append(fan_led_status) + + self.board_fan_led_status = max(fan_led_status_list) + fan_led_color = LED_STATUS_DICT.get(self.board_fan_led_status) + + # set fan led + self.set_fan_led(fan_led_color) + # set fan module led + self.set_fan_module_led() + + def dealPsuLedStatus(self): + psu_led_status_list = [] + # update psu info + self.update_psu_info() + + # monitor psu status first + psu_led_status = self.get_monitor_psu_status() + psu_led_status_list.append(psu_led_status) + + # monitor psu air flow + psu_led_status = self.get_monitor_psu_air_flow() + psu_led_status_list.append(psu_led_status) + + self.board_psu_led_status = max(psu_led_status_list) + psu_led_color = LED_STATUS_DICT.get(self.board_psu_led_status) + + # set psu led + self.set_psu_led(psu_led_color) + + def do_ledcontrol(self): + self.dealPsuLedStatus() + self.dealFanLedStatus() + self.dealSysLedStatus() + + def fan_obj_init(self): + fan_num = self.get_fan_total_number() + for i in range(fan_num): + fan_name = "FAN" + str(i + 1) + fan_obj = DevFan(fan_name, self.fan_air_flow_monitor, self.int_case) + self.fan_obj_list.append(fan_obj) + ledcontrol_debug("fan object initialize success") + + def psu_obj_init(self): + psu_num = self.get_psu_total_number() + for i in range(psu_num): + psu_name = "PSU" + str(i + 1) + psu_obj = DevPsu(psu_name, self.psu_air_flow_monitor, self.int_case) + self.psu_obj_list.append(psu_obj) + ledcontrol_debug("psu object initialize success") + + def run(self): + while True: + try: + debug_init() + self.do_ledcontrol() + time.sleep(self.interval) + except Exception as e: + traceback.print_exc() + ledcontrol_error(str(e)) + + +if __name__ == '__main__': + debug_init() + ledcontrol_debug("enter main") + led_control = ledcontrol() + led_control.fan_obj_init() + led_control.psu_obj_init() + led_control.run() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_intf.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_intf.py new file mode 100755 index 000000000000..cb8101fb181e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_intf.py @@ -0,0 +1,252 @@ +#!/usr/bin/env python3 +import os +import syslog +import importlib.machinery +from platform_util import getplatform_name, dev_file_read, dev_file_write, write_sysfs, read_sysfs + +__all__ = [ + "platform_reg_read", + "platform_reg_write", + "platform_set_optoe_type", + "platform_get_optoe_type", + "platform_sfp_read", + "platform_sfp_write", +] + +CPLD = 0 +FPGA = 1 +CPLD_PATH = "/dev/cpld%d" +FPGA_PATH = "/dev/fpga%d" + + +OPTOE_PATH = "/sys/bus/i2c/devices/%d-0050/" +OPTOE_DEV_CLASS = "dev_class" +OPTOE_EEPROM = "eeprom" + + +PLATFORM_INTF_DEBUG_FILE = "/etc/.platform_intf_debug_flag" + + +CONFIG_FILE_LIST = ["/usr/local/bin/", "/usr/local/lib/python3/dist-packages/config/", "/usr/local/lib/python3.7/dist-packages/config/", "/usr/local/lib/python3.9/dist-packages/config/"] + + +def platform_intf_debug(s): + if os.path.exists(PLATFORM_INTF_DEBUG_FILE): + syslog.openlog("PLATFORM_INTF_DEBUG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def platform_intf_error(s): + if os.path.exists(PLATFORM_INTF_DEBUG_FILE): + syslog.openlog("PLATFORM_INTF_ERROR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +class IntfPlatform: + CONFIG_NAME = 'PLATFORM_INTF_OPTOE' + __port_optoe_dict = {} + def __init__(self): + real_path = None + platform = (getplatform_name()).replace("-", "_") + for configfile_path in CONFIG_FILE_LIST: + configfile = (configfile_path + platform + "_port_config.py") + if os.path.exists(configfile): + real_path = configfile + break + if real_path is None: + raise Exception("get port config error") + config = importlib.machinery.SourceFileLoader(self.CONFIG_NAME, real_path).load_module() + self.__port_optoe_dict = config.PLATFORM_INTF_OPTOE + + def get_dev_path(self, dev_type, dev_id): + if dev_type == CPLD: + path = CPLD_PATH % dev_id + elif dev_type == FPGA: + path = FPGA_PATH % dev_id + else: + msg = "dev_type error!" + return False, msg + platform_intf_debug("path:%s" % path) + return True, path + + def get_port_path(self, port): + port_num = self.__port_optoe_dict.get("port_num", 0) + optoe_start_bus = self.__port_optoe_dict.get("optoe_start_bus", 0) + if port_num <= 0 or optoe_start_bus <= 0: + msg = "PLATFORM_INTF_OPTOE config error!" + return False, msg + if port <= 0 or port > port_num: + msg = "port out of range !" + return False, msg + path = OPTOE_PATH % (port + optoe_start_bus - 1) + platform_intf_debug("path:%s" % path) + return True, path + + def reg_read(self, dev_type, dev_id, offset, size): + ret, path = self.get_dev_path(dev_type, dev_id) + if ret == False: + return False, path + ret, info = dev_file_read(path, offset, size) + return ret, info + + def reg_write(self, dev_type, dev_id, offset, val_list): + ret, path = self.get_dev_path(dev_type, dev_id) + if ret == False: + return False, path + ret, info = dev_file_write(path, offset, val_list) + return ret, info + + def set_optoe_type(self, port, optoe_type): + ret, path = self.get_port_path(port) + if ret == False: + return False, path + optoe_type_path = path + OPTOE_DEV_CLASS + ret, info = write_sysfs(optoe_type_path, "%d" % optoe_type) + if ret == False: + return False, info + return True, None + + def get_optoe_type(self, port): + ret, path = self.get_port_path(port) + if ret == False: + return False, path + optoe_type_path = path + OPTOE_DEV_CLASS + ret, info = read_sysfs(optoe_type_path) + if ret == False: + return False, info + return True, int(info) + + def sfp_read(self, port_id, offset, size): + ret, path = self.get_port_path(port_id) + if ret == False: + return False, path + optoe_eeprom_path = path + OPTOE_EEPROM + ret, info = dev_file_read(optoe_eeprom_path, offset, size) + return ret, info + + def sfp_write(self, port_id, offset, val_list): + ret, path = self.get_port_path(port_id) + if ret == False: + return False, path + optoe_eeprom_path = path + OPTOE_EEPROM + ret, info = dev_file_write(optoe_eeprom_path, offset, val_list) + return ret, info + + +platform = IntfPlatform() + + +def platform_reg_read(dev_type, dev_id, offset, size): + ret = False + info = None + + '''1. params check + ''' + if (isinstance(dev_type, int) is False or isinstance(dev_id, int) is False or + isinstance(offset, int) is False or isinstance(size, int) is False): + info = "params type check fail in platform_reg_read" + return ret, info + if dev_id < 0 or offset < 0 or size <= 0: + info = "params value check fail in platform_reg_read" + return ret, info + if dev_type != CPLD and dev_type != FPGA: + info = "dev_type match erro, fail in platform_reg_read" + return ret, info + + '''2. call the solve func + ''' + return platform.reg_read(dev_type, dev_id, offset, size) + + +def platform_reg_write(dev_type, dev_id, offset, val_list): + ret = False + info = None + + '''1. params check + ''' + if (isinstance(dev_type, int) is False or isinstance(dev_id, int) is False or + isinstance(offset, int) is False or isinstance(val_list, list) is False): + info = "params type check fail in platform_reg_write" + return ret, info + if dev_id < 0 or offset < 0 or len(val_list) <= 0: + info = "params value check fail in platform_reg_write" + return ret, info + if dev_type != CPLD and dev_type != FPGA: + info = "dev_type match erro, fail in platform_reg_write" + return ret, info + + '''2. call the solve func + ''' + return platform.reg_write(dev_type, dev_id, offset, val_list) + + +def platform_set_optoe_type(port, optoe_type): + ret = False + info = None + + '''1. params check + ''' + if isinstance(port, int) is False or isinstance(optoe_type, int) is False: + info = "params type check fail in platform_set_optoe_type" + return ret, info + if port < 0 or optoe_type < 1 or optoe_type > 3: + info = "params value check fail in platform_set_optoe_type" + return ret, info + + '''2. call the solve func + ''' + return platform.set_optoe_type(port, optoe_type) + + +def platform_get_optoe_type(port): + ret = False + info = None + + '''1. params check + ''' + if isinstance(port, int) is False: + info = "params type check fail in platform_get_optoe_type" + return ret, info + if port < 0: + info = "params value check fail in platform_get_optoe_type" + return ret, info + + '''2. call the solve func + ''' + return platform.get_optoe_type(port) + + +def platform_sfp_read(port_id, offset, size): + ret = False + info = None + + '''1. params check + ''' + if isinstance(port_id, int) is False or isinstance(offset, int) is False or isinstance(size, int) is False: + info = "params type check fail in platform_sfp_read" + return ret, info + if port_id < 0 or offset < 0 or size <= 0: + info = "params value check fail in platform_sfp_read" + return ret, info + + '''2. call the solve func + ''' + return platform.sfp_read(port_id, offset, size) + + +def platform_sfp_write(port_id, offset, val_list): + ret = False + info = None + + '''1. params check + ''' + if isinstance(port_id, int) is False or isinstance(offset, int) is False or isinstance(val_list, list) is False: + info = "params type check fail in platform_sfp_write" + return ret, info + if port_id < 0 or offset < 0 or len(val_list) <= 0: + info = "params value check fail in platform_sfp_write" + return ret, info + + '''2. call the solve func + ''' + return platform.sfp_write(port_id, offset, val_list) \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_manufacturer.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_manufacturer.py new file mode 100755 index 000000000000..fe6084fd05a7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_manufacturer.py @@ -0,0 +1,609 @@ +#!/usr/bin/env python3 + +import re +from sys import exit, stderr +from ruijieconfig import MANUINFO_CONF +from monitor import status +import mmap +import fcntl +import subprocess +import signal +import os +import time +from platform_util import byteTostr + + +INDENT = 4 + + +def printerr(vchar): + stderr.write(vchar + '\n') + + +g_extra_cache = dict() +g_meminfo_cache = dict() +g_exphy_cache = dict() + + +def exec_os_cmd(cmd, timeout=10): + try: + start_time = time.time() + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT, + close_fds=True, preexec_fn=os.setsid) + while True: + if proc.poll() is not None: + break + if timeout <= 0: + continue + if (time.time() - start_time) > timeout: + try: + os.killpg(os.getpgid(proc.pid), signal.SIGTERM) + except Exception as e: + return -1, "run command %s %d sec timeout, msg: %s" % (cmd, timeout, str(e)) + return -1, "run command %s %d sec timeout" % (cmd, timeout) + time.sleep(0.01) + return proc.returncode, byteTostr(proc.stdout.read()).strip() + except Exception as e: + return -1, str(e) + + +def exphyfwsplit(): + # improve performance + global g_exphy_cache + if g_exphy_cache: + return + cmd = "bcmcmd -t 1 \"phy control xe,ce fw_get\" |grep fw_version" + status, output = exec_os_cmd(cmd) + if status or len(output) == 0: + raise Exception("run cmd: {} error, status: {}, msg: {}".format(cmd, status, output)) + exphyfwstr = output.strip() + portlist = exphyfwstr.split("\n") + for port in portlist: + phy_addr_str = get_regular_val(port, r"phy_addr\s*=\s*\w+", 0) + if phy_addr_str.startswith("ERR"): + continue + phy_addr_key = phy_addr_str.replace(" ", "") + if phy_addr_key in g_exphy_cache: + continue + + g_exphy_cache[phy_addr_key] = {} + + fw_version_str = get_regular_val(port, r"fw_version\s*=\s*\w+", 0) + if fw_version_str.startswith("ERR"): + del g_exphy_cache[phy_addr_key] + continue + + fw_version = fw_version_str.split("=")[1].strip() + g_exphy_cache[phy_addr_key]["fw_version"] = fw_version + + if "success" in port: + status = "OK" + else: + status = "Unexpected" + g_exphy_cache[phy_addr_key]["status"] = status + return + + +def get_exphy_fw(phyid): + exphyfwsplit() + if phyid not in g_exphy_cache: + return "ERR %s not found." % phyid + fw_version = g_exphy_cache.get(phyid).get("fw_version") + status = g_exphy_cache.get(phyid).get("status") + msg = "%s %s" % (fw_version, status) + return msg + + +def lshwmemorysplit(): + # improve performance + global g_meminfo_cache + if g_meminfo_cache: + return + cmd = "lshw -c memory" + status, output = exec_os_cmd(cmd) + if status or len(output) == 0: + raise Exception("run cmd: {} error, status: {}, msg: {}".format(cmd, status, output)) + memstr = output.strip() + memlist = memstr.split("*-") + for item in memlist: + if item.strip().startswith("memory") and "System Memory" not in item: + continue + line_index = 0 + for line in item.splitlines(): + line_index += 1 + if line_index == 1: + memdict_key = line + g_meminfo_cache[memdict_key] = {} + else: + if ":" not in line: + continue + key = line.split(":", 1)[0].strip() + value = line.split(":", 1)[1].strip() + g_meminfo_cache[memdict_key][key] = value + if "empty" in item: + break + return + + +def run_extra_func(funcname): + # improve performance + if funcname in g_extra_cache: + return g_extra_cache.get(funcname) + func = getattr(status, funcname) + ret = [] + func(ret) + if ret: + g_extra_cache[funcname] = ret + return ret + + +def get_extra_value(funcname, itemid, key): + for item in run_extra_func(funcname): + if item.get("id") == itemid: + return item.get(key, "NA") + return "NA" + + +def get_memory_value(params): + global g_meminfo_cache + root_key = params.get("root_key") + sub_key = params.get("sub_key") + lshwmemorysplit() + return g_meminfo_cache.get(root_key, {}).get(sub_key, "NA") + + +def get_memory_bank_value(params): + global g_meminfo_cache + lshwmemorysplit() + bank = params.get("bankid") + if g_meminfo_cache.get(bank, {}): + return True + return False + + +def io_wr(reg_addr, reg_data): + try: + regdata = 0 + regaddr = 0 + if isinstance(reg_addr, int): + regaddr = reg_addr + else: + regaddr = int(reg_addr, 16) + if isinstance(reg_data, int): + regdata = reg_data + else: + regdata = int(reg_data, 16) + devfile = "/dev/port" + fd = os.open(devfile, os.O_RDWR | os.O_CREAT) + os.lseek(fd, regaddr, os.SEEK_SET) + os.write(fd, regdata.to_bytes(1, 'little')) + return True + except ValueError as e: + print(e) + return False + except Exception as e: + print(e) + return False + finally: + os.close(fd) + + +def checksignaldriver(name): + modisexistcmd = "lsmod | grep -w %s | wc -l" % name + status, output = exec_os_cmd(modisexistcmd) + if status: + return False + if output.isdigit() and int(output) > 0: + return True + else: + return False + + +def adddriver(name): + cmd = "modprobe %s" % name + if checksignaldriver(name) != True: + ret, log = exec_os_cmd(cmd) + if ret != 0 or len(log) > 0: + return False + return True + return True + + +def removedriver(name): + cmd = "rmmod %s" % name + if checksignaldriver(name): + exec_os_cmd(cmd) + + +def add_5387_driver(): + errmsg = "" + spi_gpio = "rg_spi_gpio" + ret = adddriver(spi_gpio) + if ret is False: + errmsg = "modprobe rg_spi_gpio driver failed." + return False, errmsg + spi_5387_device = "rg_spi_93xx46 spi_bus_num=0" + ret = adddriver(spi_5387_device) + if ret is False: + errmsg = "modprobe rg_spi_93xx46 driver failed." + return ret, errmsg + return True, "" + + +def remove_5387_driver(): + spi_5387_device = "rg_spi_93xx46" + removedriver(spi_5387_device) + spi_gpio = "rg_spi_gpio" + removedriver(spi_gpio) + + +def deal_itmes(item_list): + for item in item_list: + dealtype = item.get("dealtype") + if dealtype == "shell": + cmd = item.get("cmd") + timeout = item.get("timeout", 10) + exec_os_cmd(cmd, timeout) + elif dealtype == "io_wr": + io_addr = item.get("io_addr") + wr_value = item.get("value") + io_wr(io_addr, wr_value) + else: + pass + + +def get_bcm5387_version(params): + version = "" + try: + status, msg = add_5387_driver() + if status is False: + raise Exception(msg) + + before_deal_list = params.get("before", []) + deal_itmes(before_deal_list) + + ret, version = exec_os_cmd(params["get_version"]) + if ret != 0: + version = "ERR " + version + + after_deal_list = params.get("after", []) + deal_itmes(after_deal_list) + + except Exception as e: + version = "ERR %s" % (str(e)) + finally: + finally_deal_list = params.get("finally", []) + deal_itmes(finally_deal_list) + remove_5387_driver() + return version + + +def get_func_value(funcname, params): + ret = eval(funcname)(params) + return ret + + +def read_pci_reg(pcibus, slot, fn, bar, offset): + '''read pci register''' + if offset % 4 != 0: + return "ERR offset: %d not 4 bytes align" + filename = "/sys/bus/pci/devices/0000:%02x:%02x.%x/resource%d" % (int(pcibus), int(slot), int(fn), int(bar)) + size = os.path.getsize(filename) + with open(filename, "r+") as file: + data = mmap.mmap(file.fileno(), size) + result = data[offset: offset + 4] + s = result[::-1] + val = 0 + for i in range(0, len(s)): + val = val << 8 | s[i] + data.close() + return "0x%08x" % val + + +def devfileread(path, offset, len, bit_width): + ret = "" + val_str = '' + val_list = [] + fd = -1 + if not os.path.exists(path): + return ("%s not found !" % path) + if len % bit_width != 0: + return "only support read by bit_width" + if len < bit_width: + return "len needs to greater than or equal to bit_width" + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, len) + for item in ret: + val_list.append(item) + + for i in range(0, len, bit_width): + val_str += " 0x" + for j in range(0, bit_width): + val_str += "%02x" % val_list[i + bit_width - j - 1] + except Exception as e: + return str(e) + finally: + if fd > 0: + os.close(fd) + return val_str + + +def read_reg(loc, offset, size): + with open(loc, 'rb') as file: + file.seek(offset) + return ' '.join(["%02x" % item for item in file.read(size)]) + + +def std_match(stdout, pattern): + if pattern is None: + return stdout.strip() + for line in stdout.splitlines(): + if re.match(pattern, line): + return line.strip() + raise EOFError("pattern: {} does not match anything in stdout {}".format( + pattern, stdout)) + + +def i2c_rd(bus, loc, offset): + ''' + read i2c with i2cget command + ''' + cmd = "i2cget -f -y {} {} {}".format(bus, loc, offset) + # TODO: add retry + retrytime = 6 + for i in range(retrytime): + ret, stdout = subprocess.getstatusoutput(cmd) + if ret == 0: + return stdout + time.sleep(0.1) + raise RuntimeError("run cmd: {} error, status {}".format(cmd, ret)) + + +def i2c_rd_bytes(bus, loc, offset, size): + blist = [] + for i in range(size): + ret = i2c_rd(bus, loc, offset + i) + blist.append(ret) + + return blist + + +def get_pair_val(source, separator): + try: + value = source.split(separator, 1)[1] + except (ValueError, IndexError) as e: + # printerr(e.message) + return ("ERR separator: {} does not match in source: {}".format(separator, source)) + return value.strip() + + +def get_regular_val(source, pattern, group): + try: + value = re.findall(pattern, source)[group] + except Exception as e: + # printerr(str(e)) + return ("ERR pattern: {} does not match in source: {} with group: {}".format(pattern, source, group)) + return value.strip() + + +def find_match(file2read, pattern): + with open(file2read, 'r') as file: + for line in file: + if not re.match(pattern, line): + continue + return line.strip() + return "ERR pattern %s not match in %s" % (pattern, file2read) + + +def readaline(file2read): + with open(file2read, 'r') as file: + return file.readline() + + +def sort_key(e): + return e.arrt_index + + +class CallbackSet: + def cpld_format(self, blist): + if isinstance(blist, str): + blist = blist.split() + elif not isinstance(blist, list) or len(blist) != 4: + raise ValueError("cpld format: wrong parameter: {}".format(blist)) + + return "{}{}{}{}".format(*blist).replace("0x", "") + + +class VersionHunter: + call = CallbackSet() + + def __init__(self, entires): + self.head = None + self.next = None + self.key = None + self.cmd = None + self.file = None + self.reg = None + self.i2c = None + self.extra = None + self.pattern = None + self.separator = None + self.parent = None + self.ignore = False + self.children = [] + self.level = 0 + self.callback = None + self.delspace = None + self.arrt_index = None + self.config = None + self.precheck = None + self.func = None + self.regular = None + self.group = 0 + self.pci = None + self.devfile = None + self.decode = None + self.timeout = 10 + self.__dict__.update(entires) + + def check_para(self): + if self.pattern is None: + return False + if self.cmd is None or self.file is None: + return False + return True + + def get_version(self): + ret = "NA" + try: + if self.cmd is not None: + status, output = exec_os_cmd(self.cmd, self.timeout) + if status or len(output) == 0: + raise RuntimeError("run cmd: {} error, status: {}, msg: {}".format(self.cmd, status, output)) + ret = std_match(output, self.pattern) + elif self.file is not None: + ret = self.read_file() + elif self.reg is not None: + ret = read_reg(self.reg.get("loc"), self.reg.get("offset"), + self.reg.get("size")) + elif self.extra: + ret = get_extra_value(self.extra.get("funcname"), + self.extra.get("id"), + self.extra.get("key")) + elif self.i2c: + ret = i2c_rd_bytes(self.i2c.get("bus"), self.i2c.get("loc"), + self.i2c.get("offset"), + self.i2c.get("size")) + elif self.config: + ret = self.config + elif self.func: + ret = get_func_value(self.func.get("funcname"), + self.func.get("params")) + elif self.pci: + ret = read_pci_reg(self.pci.get("bus"), self.pci.get("slot"), + self.pci.get("fn"), self.pci.get("bar"), self.pci.get("offset")) + elif self.devfile: + ret = devfileread(self.devfile.get("loc"), self.devfile.get("offset"), + self.devfile.get("len"), self.devfile.get("bit_width")) + + except Exception as e: + # printerr(e.message) + return "ERR %s" % str(e) + return self.exe_callback(ret) + + def exe_callback(self, data): + try: + if self.callback: + method = getattr(self.call, self.callback) + return method(data) + except Exception as e: + # printerr("run callback method: {} error, data: {}".format(self.callback, data)) + # printerr(e.message) + return "ERR run callback method: {} error, data: {}".format(self.callback, data) + return data + + def read_file(self): + if self.pattern is not None: + return find_match(self.file, self.pattern) + else: + return readaline(self.file) + + def hunt(self): + if self.ignore: + return + indent = self.level * INDENT * " " + + if self.precheck: + try: + ret = eval(self.precheck.get("funcname"))(self.precheck.get("params")) + if ret is not True: + return + except Exception as e: + err_msg = "ERR %s" % str(e) + format_str = "{}{:<{}}{}".format(indent, self.key + ':', + (30 - len(indent)), err_msg) + print(format_str) + return + # has children + if self.children: + self.children.sort(key=sort_key) + format_str = "{}{}:".format(indent, self.key) + print(format_str) + for child in self.children: + if not isinstance(child, VersionHunter): + continue + child.level = self.level + 1 + child.hunt() + else: + version = self.get_version() or "" + if not version.startswith("ERR"): + version = version.replace("\x00", "").strip() + if self.separator is not None: + version = get_pair_val(version, self.separator) + if self.delspace is not None: + version = version.replace(" ", "") + if self.regular is not None: + version = get_regular_val(version, self.regular, self.group) + if self.decode is not None: + tmp_version = self.decode.get(version) + if tmp_version is None: + version = "ERR decode %s failed" % version + else: + version = tmp_version + format_str = "{}{:<{}}{}".format(indent, self.key + ':', + (30 - len(indent)), version) + print(format_str) + + if self.next: + print("") + self.next.hunt() + + +pidfile = 0 + + +def ApplicationInstance(): + global pidfile + pidfile = open(os.path.realpath(__file__), "r") + try: + fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB) + return True + except Exception as e: + return False + + +if __name__ == "__main__": + start_time = time.time() + while True: + ret = ApplicationInstance() + if ret == True: + break + if time.time() - start_time > 10: + printerr("manufacturer is running.") + exit(1) + time.sleep(0.5) + + objmap = dict() + + try: + target = {} + target.update(MANUINFO_CONF) + for objname, value in target.items(): + objmap[objname] = VersionHunter(value) + except Exception as e: + printerr(e.message) + exit(-1) + + head = None + for objname, obj in objmap.items(): + if head is None and obj.head: + head = obj + if obj.parent: + objmap.get(obj.parent).children.append(obj) + if obj.next: + obj.next = objmap.get(obj.next) + + head.hunt() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_sensors.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_sensors.py new file mode 100755 index 000000000000..c42db7e874bd --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_sensors.py @@ -0,0 +1,262 @@ +#!/usr/bin/python3 + +# On S6100, the Platform Management Controller runs the +# thermal algorithm. It provides a mailbox for the Host +# to query relevant thermals. The dell_mailbox module +# provides the sysfs support for the following objects: +# * onboard temperature sensors +# * FAN trays +# * PSU +# +import os +import sys +import importlib.machinery + + +def get_machine_info(): + if not os.path.isfile('/host/machine.conf'): + return None + machine_vars = {} + with open('/host/machine.conf') as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars + + +def get_platform_info(machine_info): + if machine_info is not None: + if 'onie_platform' in machine_info: + return machine_info['onie_platform'] + elif 'aboot_platform' in machine_info: + return machine_info['aboot_platform'] + return None + + +PLATFORM_ROOT_PATH = '/usr/share/sonic/device' +PLATFORM_SPECIFIC_MODULE_NAME = 'monitor' +PLATFORM_SPECIFIC_CLASS_NAME = 'status' +platform_status_class = None +platform = None + + +def get_platform_name(): + global platform + platform = get_platform_info(get_machine_info()) + return platform + + +val = get_platform_name() +sys.path.append("/".join([PLATFORM_ROOT_PATH, platform])) + +# Loads platform specific sfputil module from source + + +def load_platform_monitor(): + global platform_status_class + platform = get_platform_info(get_machine_info()) + platform_path = "/".join([PLATFORM_ROOT_PATH, platform]) + try: + module_file = "/".join([platform_path, PLATFORM_SPECIFIC_MODULE_NAME + ".py"]) + module = importlib.machinery.SourceFileLoader(PLATFORM_SPECIFIC_MODULE_NAME, module_file).load_module() + except IOError as e: + return -1 + try: + platform_status_class = getattr(module, PLATFORM_SPECIFIC_CLASS_NAME) + except AttributeError as e: + return -2 + return 0 + + +def printerr(str): + print("\033[0;31m%s\033[0m" % str) + + +def print_console(str): + print(str) + + +val_t = load_platform_monitor() +if val_t != 0: + raise Exception("load monitor.py error") + + +def print_platform(): + platform_info = get_platform_name() + print_console(platform_info) + print_console('Adapter: Ruijie Platform Management Controller') + print_console("") + + +def print_cputemp_sensors(): + val_ret = get_call_value_by_function("getcputemp") + print_info_str = "" + toptile = "Onboard coretemp Sensors:" + formatstr = " {name:<20} : {temp} C (high = {max} C , crit = {crit} C )" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + print_info_str += formatstr.format(**item) + '\n' + print_console(print_info_str) + + +def print_boardtemp(): + val_ret = get_call_value_by_function("getTemp") + print_info_str = "" + toptile = "Onboard Temperature Sensors:" + errformat = " {id:<20} : {errmsg}" + formatstr = " {id:<20} : {temp1_input} C (high = {temp1_max} C, hyst = {temp1_max_hyst} C)" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + realformat = formatstr if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + '\n' + print_console(print_info_str) + + +def print_mactemp_sensors(): + val_ret = get_call_value_by_function("getmactemp") + print_info_str = "" + toptile = "Onboard MAC Temperature Sensors:" + errformat = " {id:<20} : {errmsg}" + formatstr = " {id:<20} : {temp_input} C" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + realformat = formatstr if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + '\n' + print_console(print_info_str) + + +def print_macpower_sensors(): + val_ret = get_call_value_by_function("getmacpower") + print_info_str = "" + toptile = "Onboard MAC Power Sensors:" + errformat = " {id:<20} : {errmsg}" + formatstr = " {id:<20} : {power_input} W" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + realformat = formatstr if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + '\n' + print_console(print_info_str) + + +def print_fan_sensor(): + val_ret = get_call_value_by_function("checkFan") + print_info_str = "" + toptile = "Onboard fan Sensors:" + errformat = " {id} : {errmsg}\n" # " {id:<20} : {errmsg}" + fan_signle_rotor_format = " {id} : \n" \ + " fan_type :{fan_type}\n" \ + " sn :{sn}\n" \ + " hw_version:{hw_version}\n" \ + " Speed :{Speed} RPM\n" \ + " status :{errmsg} \n" + fan_double_rotor_format = " {id} : \n" \ + " fan_type :{fan_type}\n" \ + " sn :{sn}\n" \ + " hw_version:{hw_version}\n" \ + " Speed :\n" \ + " speed_front :{rotor1_speed:<5} RPM\n" \ + " speed_rear :{rotor2_speed:<5} RPM\n" \ + " status :{errmsg} \n" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + if item.get('Speed', None) is None: + realformat = fan_double_rotor_format if item.get('errcode', 0) == 0 else errformat + else: + realformat = fan_signle_rotor_format if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + print_console(print_info_str) + + +def print_psu_sensor(): + val_ret = get_call_value_by_function("getPsu") + print_info_str = "" + toptile = "Onboard Power Supply Unit Sensors:" + errformat = " {id} : {errmsg}\n" # " {id:<20} : {errmsg}" + psuformat = " {id} : \n" \ + " type :{type1}\n" \ + " sn :{sn}\n" \ + " in_current :{in_current} A\n" \ + " in_voltage :{in_voltage} V\n" \ + " out_current:{out_current} A\n" \ + " out_voltage:{out_voltage} V\n" \ + " temp :{temp} C \n" \ + " fan_speed :{fan_speed} RPM\n" \ + " in_power :{in_power} W\n" \ + " out_power :{out_power} W\n" + + if len(val_ret) != 0: + print_info_str += toptile + '\r\n' + for item in val_ret: + realformat = psuformat if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + print_console(print_info_str) + + +def print_slot_sensor(): + val_ret = get_call_value_by_function("checkSlot") + print_info_str = "" + toptile = "Onboard slot Sensors:" + errformat = " {id} : {errmsg}\n" # " {id:<20} : {errmsg}" + psuformat = " {id} : \n" \ + " slot_type :{slot_type}\n" \ + " sn :{sn}\n" \ + " hw_version :{hw_version} \n" \ + " status :{errmsg}\n" + + if len(val_ret) != 0: + print_info_str += toptile + '\r\n' + for item in val_ret: + realformat = psuformat if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + print_console(print_info_str) + + +def print_boarddcdc(): + val_ret = get_call_value_by_function("getDcdc") + print_info_str = "" + toptile = "Onboard DCDC Sensors:" + errformat = " {id:<26} : {errmsg}" + formatstr = " {id:<26} : {dcdc_input:<6} V (Min = {dcdc_min:<6} V, Max = {dcdc_max:<6} V)" + + if len(val_ret) != 0: + print_info_str += toptile + '\n' + for item in val_ret: + realformat = formatstr if item.get('errcode', 0) == 0 else errformat + print_info_str += realformat.format(**item) + '\n' + print_console(print_info_str) + + +def get_call_value_by_function(function_name): + valtemp = [] + if hasattr(platform_status_class, function_name): + test2_func = getattr(platform_status_class, function_name) + test2_func(valtemp) + return valtemp + + +def getsensors(): + print_platform() + print_cputemp_sensors() + print_boardtemp() + print_mactemp_sensors() + print_macpower_sensors() + print_fan_sensor() + print_psu_sensor() + print_slot_sensor() + print_boarddcdc() + + +if __name__ == "__main__": + getsensors() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_util.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_util.py new file mode 100755 index 000000000000..b0593b40cdf7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/platform_util.py @@ -0,0 +1,539 @@ +#!/usr/bin/python3 +# ------------------------------------------------------------------------- +# +# Author: sonic_rd +# +# Created: 02/07/2018 +# Copyright: (c) sonic_rd 2018 +# ------------------------------------------------------------------------- +import sys +import os +import subprocess +import time +import mmap +import glob + + +CONFIG_DB_PATH = "/etc/sonic/config_db.json" + + +__all__ = [ + "byteTostr", + "getplatform_name", + "rji2cget", + "rji2cset", + "rjpcird", + "rjpciwr", + "rji2cgetWord", + "rji2csetWord", + "dev_file_read", + "dev_file_write", + "rj_os_system", + "io_rd", + "io_wr", + "exec_os_cmd", + "exec_os_cmd_log", + "write_sysfs", + "read_sysfs", + "get_value", + "set_value", +] + +def inttostr(vl, len): + if not isinstance(vl, int): + raise Exception(" type error") + index = 0 + ret_t = "" + while index < len: + ret = 0xff & (vl >> index * 8) + ret_t += chr(ret) + index += 1 + return ret_t + + +def byteTostr(val): + strtmp = '' + for i in range(len(val)): + strtmp += chr(val[i]) + return strtmp + + +def typeTostr(val): + strtmp = '' + if isinstance(val, bytes): + strtmp = byteTostr(val) + return strtmp + + +def getonieplatform(path): + if not os.path.isfile(path): + return "" + machine_vars = {} + with open(path) as machine_file: + for line in machine_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + machine_vars[tokens[0]] = tokens[1].strip() + return machine_vars.get("onie_platform") + + +def getplatform_config_db(): + if not os.path.isfile(CONFIG_DB_PATH): + return "" + val = os.popen("sonic-cfggen -j %s -v DEVICE_METADATA.localhost.platform" % CONFIG_DB_PATH).read().strip() + if len(val) <= 0: + return "" + else: + return val + + +def getplatform_name(): + if os.path.isfile('/host/machine.conf'): + return getonieplatform('/host/machine.conf') + elif os.path.isfile('/usr/share/sonic/hwsku/machine.conf'): + return getonieplatform('/usr/share/sonic/hwsku/machine.conf') + else: + return getplatform_config_db() + + +def rji2cget(bus, devno, address, word=None): + if word is None: + command_line = "i2cget -f -y %d 0x%02x 0x%02x " % (bus, devno, address) + else: + command_line = "i2cget -f -y %d 0x%02x 0x%02x %s" % (bus, devno, address, word) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = rj_os_system(command_line) + if ret == 0: + return True, ret_t + time.sleep(0.1) + return False, ret_t + + +def rji2cset(bus, devno, address, byte): + command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%02x" % ( + bus, devno, address, byte) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = rj_os_system(command_line) + if ret == 0: + return True, ret_t + return False, ret_t + + +def rjpcird(pcibus, slot, fn, bar, offset): + '''read pci register''' + if offset % 4 != 0: + return "ERR offset: %d not 4 bytes align" + filename = "/sys/bus/pci/devices/0000:%02x:%02x.%x/resource%d" % (int(pcibus), int(slot), int(fn), int(bar)) + with open(filename, "r+") as file: + size = os.path.getsize(filename) + data = mmap.mmap(file.fileno(), size) + result = data[offset: offset + 4] + s = result[::-1] + val = 0 + for i in range(0, len(s)): + val = val << 8 | s[i] + data.close() + return "0x%08x" % val + + +def rjpciwr(pcibus, slot, fn, bar, offset, data): + '''write pci register''' + ret = inttostr(data, 4) + filename = "/sys/bus/pci/devices/0000:%02x:%02x.%x/resource%d" % (int(pcibus), int(slot), int(fn), int(bar)) + with open(filename, "r+") as file: + size = os.path.getsize(filename) + data = mmap.mmap(file.fileno(), size) + data[offset: offset + 4] = ret + result = data[offset: offset + 4] + s = result[::-1] + val = 0 + for i in range(0, len(s)): + val = val << 8 | ord(s[i]) + data.close() + + +def rji2cgetWord(bus, devno, address): + command_line = "i2cget -f -y %d 0x%02x 0x%02x w" % (bus, devno, address) + retrytime = 3 + ret_t = "" + for i in range(retrytime): + ret, ret_t = rj_os_system(command_line) + if ret == 0: + return True, ret_t + return False, ret_t + + +def rji2csetWord(bus, devno, address, byte): + command_line = "i2cset -f -y %d 0x%02x 0x%02x 0x%x w" % ( + bus, devno, address, byte) + retrytime = 6 + ret_t = "" + for i in range(retrytime): + ret, ret_t = rj_os_system(command_line) + if ret == 0: + return True, ret_t + return False, ret_t + + +def dev_file_read(path, offset, read_len): + val_list = [] + msg = "" + ret = "" + fd = -1 + + if not os.path.exists(path): + msg = path + " not found !" + return False, msg + + try: + fd = os.open(path, os.O_RDONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.read(fd, read_len) + for item in ret: + val_list.append(item) + except Exception as e: + msg = str(e) + return False, msg + finally: + if fd > 0: + os.close(fd) + return True, val_list + + +def dev_file_write(path, offset, buf_list): + msg = "" + fd = -1 + + if not isinstance(buf_list, list) or len(buf_list) == 0: + msg = "buf:%s is not list type or is NONE !" % buf_list + return False, msg + + if not os.path.exists(path): + msg = path + " not found !" + return False, msg + + try: + fd = os.open(path, os.O_WRONLY) + os.lseek(fd, offset, os.SEEK_SET) + ret = os.write(fd, bytes(buf_list)) + except Exception as e: + msg = str(e) + return False, msg + finally: + if fd > 0: + os.close(fd) + + return True, ret + + +def rj_os_system(cmd): + status, output = subprocess.getstatusoutput(cmd) + return status, output + + +def io_rd(reg_addr, read_len=1): + try: + regaddr = 0 + if isinstance(reg_addr, int): + regaddr = reg_addr + else: + regaddr = int(reg_addr, 16) + devfile = "/dev/port" + fd = os.open(devfile, os.O_RDWR | os.O_CREAT) + os.lseek(fd, regaddr, os.SEEK_SET) + str = os.read(fd, read_len) + return "".join(["%02x" % item for item in str]) + except ValueError: + return None + except Exception as e: + print(e) + return None + finally: + os.close(fd) + + +def io_wr(reg_addr, reg_data): + try: + regdata = 0 + regaddr = 0 + if isinstance(reg_addr, int): + regaddr = reg_addr + else: + regaddr = int(reg_addr, 16) + if isinstance(reg_data, int): + regdata = reg_data + else: + regdata = int(reg_data, 16) + devfile = "/dev/port" + fd = os.open(devfile, os.O_RDWR | os.O_CREAT) + os.lseek(fd, regaddr, os.SEEK_SET) + os.write(fd, regdata.to_bytes(1, 'little')) + return True + except ValueError as e: + print(e) + return False + except Exception as e: + print(e) + return False + finally: + os.close(fd) + + +def exec_os_cmd(cmd): + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + stdout = typeTostr(stdout) + return proc.returncode, stdout + + +def exec_os_cmd_log(cmd): + proc = subprocess.Popen((cmd), stdin=subprocess.PIPE, shell=True, stderr=sys.stderr, close_fds=True, + stdout=sys.stdout, universal_newlines=True, bufsize=1) + + stdout = proc.communicate()[0] + stdout = typeTostr(stdout) + return proc.returncode, stdout + + +def write_sysfs(location, value): + try: + if not os.path.isfile(location): + return False, ("location[%s] not found !" % location) + with open(location, 'w') as fd1: + fd1.write(value) + except Exception as e: + return False, (str(e) + " location[%s]" % location) + return True, ("set location[%s] %s success !" % (location, value)) + + +def read_sysfs(location): + try: + locations = glob.glob(location) + with open(locations[0], 'rb') as fd1: + retval = fd1.read() + retval = typeTostr(retval) + retval = retval.rstrip('\r\n') + retval = retval.lstrip(" ") + except Exception as e: + return False, (str(e) + "location[%s]" % location) + return True, retval + + +def get_value_once(config): + try: + way = config.get("gettype") + int_decode = config.get("int_decode", 16) + if way == 'sysfs': + loc = config.get("loc") + ret, val = read_sysfs(loc) + if ret == True: + return True, int(val, int_decode) + else: + return False, ("sysfs read %s failed. log:%s" % (loc, val)) + elif way == "i2c": + bus = config.get("bus") + addr = config.get("loc") + offset = config.get("offset", 0) + ret, val = rji2cget(bus, addr, offset) + if ret == True: + return True, int(val, int_decode) + else: + return False, ("i2c read failed. bus:%d , addr:0x%x, offset:0x%x" % (bus, addr, offset)) + elif way == "io": + io_addr = config.get('io_addr') + val = io_rd(io_addr) + if len(val) != 0: + return True, int(val, int_decode) + else: + return False, ("io_addr read 0x%x failed" % io_addr) + elif way == "i2cword": + bus = config.get("bus") + addr = config.get("loc") + offset = config.get("offset") + ret, val = rji2cgetWord(bus, addr, offset) + if ret == True: + return True, int(val, int_decode) + else: + return False, ("i2cword read failed. bus:%d, addr:0x%x, offset:0x%x" % (bus, addr, offset)) + elif way == "devfile": + path = config.get("path") + offset = config.get("offset") + read_len = config.get("read_len") + ret, val_list = dev_file_read(path, offset, read_len) + if ret == True: + return True, val_list + else: + return False, ("devfile read failed. path:%s, offset:0x%x, read_len:%d" % (path, offset, read_len)) + elif way == 'cmd': + cmd = config.get("cmd") + ret, val = exec_os_cmd(cmd) + if ret: + return False, ("cmd read exec %s failed, log: %s" % (cmd, val)) + else: + return True, int(val, int_decode) + elif way == 'file_exist': + judge_file = config.get('judge_file', None) + if os.path.exists(judge_file): + return True, True + return True, False + else: + return False, "not support read type" + except Exception as e: + return False, ("get_value_once exception:%s happen" % str(e)) + + +def set_value_once(config): + try: + delay_time = config.get("delay", None) + if delay_time is not None: + time.sleep(delay_time) + + way = config.get("gettype") + if way == 'sysfs': + loc = config.get("loc") + value = config.get("value") + mask = config.get("mask", 0xff) + if mask != 0xff and mask != 0: + ret, read_value = read_sysfs(loc) + if ret == True: + read_value = int(read_value, base=16) + value = (read_value & mask) | value + else: + return False, ("sysfs read %s failed. log:%s" % (loc, read_value)) + ret, log = write_sysfs(loc, "0x%02x" % value) + if ret != True: + return False, ("sysfs %s write 0x%x failed" % (loc, value)) + else: + return True, ("sysfs write 0x%x success" % value) + elif way == "i2c": + bus = config.get("bus") + addr = config.get("loc") + offset = config.get("offset") + value = config.get("value") + mask = config.get("mask", 0xff) + if mask != 0xff and mask != 0: + ret, read_value = rji2cget(bus, addr, offset) + if ret == True: + read_value = int(read_value, base=16) + value = (read_value & mask) | value + else: + return False, ("i2c read failed. bus:%d , addr:0x%x, offset:0x%x" % (bus, addr, offset)) + ret, log = rji2cset(bus, addr, offset, value) + if ret != True: + return False, ("i2c write bus:%d, addr:0x%x, offset:0x%x, value:0x%x failed" % + (bus, addr, offset, value)) + else: + return True, ("i2c write bus:%d, addr:0x%x, offset:0x%x, value:0x%x success" % + (bus, addr, offset, value)) + elif way == "io": + io_addr = config.get('io_addr') + value = config.get('value') + mask = config.get("mask", 0xff) + if mask != 0xff and mask != 0: + read_value = io_rd(io_addr) + if read_value is None: + return False, ("io_addr 0x%x read failed" % (io_addr)) + read_value = int(read_value, base=16) + value = (read_value & mask) | value + ret = io_wr(io_addr, value) + if ret != True: + return False, ("io_addr 0x%x write 0x%x failed" % (io_addr, value)) + else: + return True, ("io_addr 0x%x write 0x%x success" % (io_addr, value)) + elif way == 'i2cword': + bus = config.get("bus") + addr = config.get("loc") + offset = config.get("offset") + value = config.get("value") + mask = config.get("mask", 0xff) + if mask != 0xff and mask != 0: + ret, read_value = rji2cgetWord(bus, addr, offset) + if ret == True: + read_value = int(read_value, base=16) + value = (read_value & mask) | value + else: + return False, ("i2c read word failed. bus:%d , addr:0x%x, offset:0x%x" % (bus, addr, offset)) + ret, log = rji2csetWord(bus, addr, offset, value) + if ret != True: + return False, ("i2cword write bus:%d, addr:0x%x, offset:0x%x, value:0x%x failed" % + (bus, addr, offset, value)) + else: + return True, ("i2cword write bus:%d, addr:0x%x, offset:0x%x, value:0x%x success" % + (bus, addr, offset, value)) + elif way == "devfile": + path = config.get("path") + offset = config.get("offset") + buf_list = config.get("value") + ret, log = dev_file_write(path, offset, buf_list) + if ret == True: + return True, ("devfile write path:%s, offset:0x%x, buf_list:%s success." % (path, offset, buf_list)) + else: + return False, ("devfile read path:%s, offset:0x%x, buf_list:%s failed.log:%s" % + (path, offset, buf_list, log)) + elif way == 'cmd': + cmd = config.get("cmd") + ret, log = exec_os_cmd(cmd) + if ret: + return False, ("cmd write exec %s failed, log: %s" % (cmd, log)) + else: + return True, ("cmd write exec %s success" % cmd) + elif way == 'bit_wr': + mask = config.get("mask") + bit_val = config.get("value") + val_config = config.get("val_config") + ret, rd_value = get_value_once(val_config) + if ret is False: + return False, ("bit_wr read failed, log: %s" % rd_value) + wr_val = (rd_value & mask) | bit_val + val_config["value"] = wr_val + ret, log = set_value_once(val_config) + if ret is False: + return False, ("bit_wr failed, log: %s" % log) + return True, ("bit_wr success, log: %s" % log) + elif way == 'creat_file': + file_name = config.get("file") + ret, log = exec_os_cmd("touch %s" % file_name) + if ret: + return False, ("creat file %s failed, log: %s" % (file_name, log)) + exec_os_cmd("sync") + return True, ("creat file %s success" % file_name) + elif way == 'remove_file': + file_name = config.get("file") + ret, log = exec_os_cmd("rm -rf %s" % file_name) + if ret: + return False, ("remove file %s failed, log: %s" % (file_name, log)) + exec_os_cmd("sync") + return True, ("remove file %s success" % file_name) + else: + return False, "not support write type" + except Exception as e: + return False, ("set_value_once exception:%s happen" % str(e)) + + +def get_value(config): + retrytime = 6 + for i in range(retrytime): + ret, val = get_value_once(config) + if ret == True: + return True, val + time.sleep(0.1) + return False, val + + +def set_value(config): + retrytime = 6 + ignore_result_flag = config.get("ignore_result", 0) + for i in range(retrytime): + ret, log = set_value_once(config) + if ret == True: + return True, log + if ignore_result_flag == 1: + return True, log + time.sleep(0.1) + return False, log diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_driver.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_driver.py new file mode 100755 index 000000000000..92e18c0525b9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_driver.py @@ -0,0 +1,244 @@ +#!/usr/bin/env python3 +import click +import os +import subprocess +import time +from ruijieconfig import GLOBALCONFIG + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class AliasedGroup(click.Group): + def get_command(self, ctx, cmd_name): + rv = click.Group.get_command(self, ctx, cmd_name) + if rv is not None: + return rv + matches = [x for x in self.list_commands(ctx) + if x.startswith(cmd_name)] + if not matches: + return None + elif len(matches) == 1: + return click.Group.get_command(self, ctx, matches[0]) + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) + return None + +def log_os_system(cmd): + status, output = subprocess.getstatusoutput(cmd) + if status: + print(output) + return status, output + + +def check_driver(): + status, output = log_os_system("lsmod | grep rg | wc -l") + if status: + return False + if output.isdigit() and int(output) > 0: + return True + else: + return False + + +def removeDev(bus, loc): + cmd = "echo 0x%02x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (loc, bus) + devpath = "/sys/bus/i2c/devices/%d-%04x" % (bus, loc) + if os.path.exists(devpath): + log_os_system(cmd) + + +def addDev(name, bus, loc): + if name == "lm75": + time.sleep(0.1) + pdevpath = "/sys/bus/i2c/devices/i2c-%d/" % (bus) + for i in range(1, 100): + if os.path.exists(pdevpath) == True: + break + time.sleep(0.1) + if i % 10 == 0: + click.echo("%%RG_PLATFORM_DRIVER-INIT: %s not found, wait 0.1 second ! i %d " % (pdevpath, i)) + + cmd = "echo %s 0x%02x > /sys/bus/i2c/devices/i2c-%d/new_device" % (name, loc, bus) + devpath = "/sys/bus/i2c/devices/%d-%04x" % (bus, loc) + if os.path.exists(devpath) == False: + os.system(cmd) + + +def removeOPTOE(name, startbus, endbus): + for bus in range(endbus, startbus - 1, -1): + removeDev(bus, 0x50) + + +def addOPTOE(name, startbus, endbus): + for bus in range(startbus, endbus + 1): + addDev(name, bus, 0x50) + + +def removeoptoes(): + optoes = GLOBALCONFIG["OPTOE"] + for index in range(len(optoes) - 1, -1, -1): + removeOPTOE(optoes[index]["name"], optoes[index]["startbus"], optoes[index]["endbus"]) + + +def addoptoes(): + optoes = GLOBALCONFIG["OPTOE"] + for index in range(0, len(optoes)): + addOPTOE(optoes[index]["name"], optoes[index]["startbus"], optoes[index]["endbus"]) + + +def removedevs(): + devs = GLOBALCONFIG["DEVS"] + for index in range(len(devs) - 1, -1, -1): + removeDev(devs[index]["bus"], devs[index]["loc"]) + + +def adddevs(): + devs = GLOBALCONFIG["DEVS"] + for dev in range(0, devs.__len__()): + addDev(devs[dev]["name"], devs[dev]["bus"], devs[dev]["loc"]) + + +def checksignaldriver(name): + modisexistcmd = "lsmod | grep -w %s | wc -l" % name + status, output = log_os_system(modisexistcmd) + if status: + return False + if output.isdigit() and int(output) > 0: + return True + else: + return False + + +def adddriver(name, delay): + cmd = "modprobe %s" % name + if delay != 0: + time.sleep(delay) + if checksignaldriver(name) != True: + log_os_system(cmd) + + +def removedriver(name, delay, removeable=1): + realname = name.lstrip().split(" ")[0] + cmd = "rmmod -f %s" % realname + if checksignaldriver(realname) and removeable: + log_os_system(cmd) + + +def removedrivers(): + if GLOBALCONFIG is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load global config failed.") + return + drivers = GLOBALCONFIG.get("DRIVERLISTS", None) + if drivers is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load driver list failed.") + return + for index in range(len(drivers) - 1, -1, -1): + delay = 0 + name = "" + removeable = drivers[index].get("removable", 1) + if isinstance(drivers[index], dict) and "delay" in drivers[index]: + name = drivers[index].get("name") + delay = drivers[index]["delay"] + else: + name = drivers[index] + removedriver(name, delay, removeable) + + +def adddrivers(): + if GLOBALCONFIG is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load global config failed.") + return + drivers = GLOBALCONFIG.get("DRIVERLISTS", None) + if drivers is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load driver list failed.") + return + for index in range(0, len(drivers)): + delay = 0 + name = "" + if isinstance(drivers[index], dict) and "delay" in drivers[index]: + name = drivers[index].get("name") + delay = drivers[index]["delay"] + else: + name = drivers[index] + adddriver(name, delay) + + +def blacklist_driver_remove(): + if GLOBALCONFIG is None: + click.echo("%%RG_PLATFORM_DRIVER-INIT: load global config failed.") + return + blacklist_drivers = GLOBALCONFIG.get("BLACKLIST_DRIVERS", []) + for index in range(len(blacklist_drivers)): + delay = 0 + name = "" + if isinstance(blacklist_drivers[index], dict) and "delay" in blacklist_drivers[index]: + name = blacklist_drivers[index].get("name") + delay = blacklist_drivers[index]["delay"] + else: + name = blacklist_drivers[index] + removedriver(name, delay) + + +def unload_driver(): + removeoptoes() + removedevs() + removedrivers() + + +def reload_driver(): + removedevs() + removedrivers() + time.sleep(1) + adddrivers() + adddevs() + + +def i2c_check(bus, retrytime=6): + try: + i2cpath = "/sys/bus/i2c/devices/" + bus + while retrytime and not os.path.exists(i2cpath): + click.echo("%%RG_PLATFORM_DRIVER-HA: i2c bus abnormal, last bus %s is not exist." % i2cpath) + reload_driver() + retrytime -= 1 + time.sleep(1) + except Exception as e: + click.echo("%%RG_PLATFORM_DRIVER-HA: %s" % str(e)) + return + + +def load_driver(): + adddrivers() + adddevs() + addoptoes() + + +@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) +def main(): + '''device operator''' + pass + + +@main.command() +def start(): + '''load drivers and device ''' + blacklist_driver_remove() + if check_driver(): + unload_driver() + load_driver() + + +@main.command() +def stop(): + '''stop drivers device ''' + unload_driver() + + +@main.command() +def restart(): + '''restart drivers and device''' + unload_driver() + load_driver() + + +if __name__ == '__main__': + u'''platform drivers and device init operation''' + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_process.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_process.py new file mode 100755 index 000000000000..2c581fa0672c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_platform_process.py @@ -0,0 +1,227 @@ +#!/usr/bin/env python3 +import click +import os +import subprocess +from ruijieconfig import STARTMODULE, GLOBALINITPARAM, GLOBALINITCOMMAND, GLOBALINITPARAM_PRE, GLOBALINITCOMMAND_PRE + + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class AliasedGroup(click.Group): + def get_command(self, ctx, cmd_name): + rv = click.Group.get_command(self, ctx, cmd_name) + if rv is not None: + return rv + matches = [x for x in self.list_commands(ctx) + if x.startswith(cmd_name)] + if not matches: + return None + elif len(matches) == 1: + return click.Group.get_command(self, ctx, matches[0]) + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) + return None + + +def log_os_system(cmd): + status, output = subprocess.getstatusoutput(cmd) + if status: + print(output) + return status, output + + +def write_sysfs_value(reg_name, value): + mb_reg_file = "/sys/bus/i2c/devices/" + reg_name + if (not os.path.isfile(mb_reg_file)): + print(mb_reg_file, 'not found !') + return False + try: + with open(mb_reg_file, 'w') as fd: + fd.write(value) + except Exception as error: + return False + return True + + +def getPid(name): + ret = [] + for dirname in os.listdir('/proc'): + if dirname == 'curproc': + continue + try: + with open('/proc/{}/cmdline'.format(dirname), mode='r') as fd: + content = fd.read() + except Exception: + continue + if name in content: + ret.append(dirname) + return ret + + +def startxdpe_avscontrol(): + if STARTMODULE.get('xdpe_avscontrol', 0) == 1: + cmd = "nohup xdpe_avscontrol.py start >/dev/null 2>&1 &" + rets = getPid("xdpe_avscontrol.py") + if len(rets) == 0: + os.system(cmd) + return + +def starthal_fanctrl(): + if STARTMODULE.get('hal_fanctrl', 0) == 1: + cmd = "nohup hal_fanctrl.py start >/dev/null 2>&1 &" + rets = getPid("hal_fanctrl.py") + if len(rets) == 0: + os.system(cmd) + return + +def starthal_ledctrl(): + if STARTMODULE.get('hal_ledctrl', 0) == 1: + cmd = "nohup hal_ledctrl.py start >/dev/null 2>&1 &" + rets = getPid("hal_ledctrl.py") + if len(rets) == 0: + os.system(cmd) + return + +def startDevmonitor(): + if STARTMODULE.get('dev_monitor', 0) == 1: + cmd = "nohup dev_monitor.py start >/dev/null 2>&1 &" + rets = getPid("dev_monitor.py") + if len(rets) == 0: + os.system(cmd) + return + +def startSff_temp_polling(): + if STARTMODULE.get('sff_temp_polling', 0) == 1: + cmd = "nohup sfp_highest_temperatue.py >/dev/null 2>&1 &" + rets = getPid("sfp_highest_temperatue.py") + if len(rets) == 0: + os.system(cmd) + return + +def startPMON_sys(): + if STARTMODULE.get('rg_pmon_syslog', 0) == 1: + cmd = "nohup rg_pmon_syslog.py >/dev/null 2>&1 &" + rets = getPid("rg_pmon_syslog.py") + if len(rets) == 0: + os.system(cmd) + return + +def stopxdpe_avscontrol(): + if STARTMODULE.get('xdpe_avscontrol', 0) == 1: + rets = getPid("xdpe_avscontrol.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stophal_fanctrl(): + if STARTMODULE.get('hal_fanctrl', 0) == 1: + rets = getPid("hal_fanctrl.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stophal_ledctrl(): + if STARTMODULE.get('hal_ledctrl', 0) == 1: + rets = getPid("hal_ledctrl.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stopDevmonitor(): + if STARTMODULE.get('dev_monitor', 0) == 1: + rets = getPid("dev_monitor.py") # + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stopSff_temp_polling(): + if STARTMODULE.get('sff_temp_polling', 0) == 1: + rets = getPid("sfp_highest_temperatue.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def stopPMON_sys(): + if STARTMODULE.get('rg_pmon_syslog', 0) == 1: + rets = getPid("rg_pmon_syslog.py") + for ret in rets: + cmd = "kill " + ret + os.system(cmd) + return + + +def otherinit(): + for index in GLOBALINITPARAM: + write_sysfs_value(index["loc"], index["value"]) + + for index in GLOBALINITCOMMAND: + log_os_system(index) + return + + +def otherinit_pre(): + for index in GLOBALINITPARAM_PRE: + write_sysfs_value(index["loc"], index["value"]) + + for index in GLOBALINITCOMMAND_PRE: + log_os_system(index) + + +def unload_apps(): + stopPMON_sys() + stopDevmonitor() + stopxdpe_avscontrol() + stophal_ledctrl() + stophal_fanctrl() + stopSff_temp_polling() + + +def load_apps(): + otherinit_pre() + startSff_temp_polling() + starthal_fanctrl() + starthal_ledctrl() + startxdpe_avscontrol() + startDevmonitor() + startPMON_sys() + otherinit() + + +@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) +def main(): + '''device operator''' + pass + + +@main.command() +def start(): + '''load process ''' + load_apps() + + +@main.command() +def stop(): + '''stop process ''' + unload_apps() + + +@main.command() +def restart(): + '''restart process''' + unload_apps() + load_apps() + + +if __name__ == '__main__': + u'''process init operation''' + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_pmon_syslog.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_pmon_syslog.py new file mode 100755 index 000000000000..ff19078c9e9f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/rg_pmon_syslog.py @@ -0,0 +1,518 @@ +#!/usr/bin/python3 +# * onboard interval check +# * FAN trays +# * PSU +# * SFF +import time +import platform +import syslog +import traceback +import glob +from ruijieconfig import PMON_SYSLOG_STATUS + +PMON_DEBUG_FILE = "/etc/.pmon_syslog_debug_flag" +debuglevel = 0 +PMONERROR = 1 +PMONDEBUG = 2 + + +def pmon_debug(s): + if PMONDEBUG & debuglevel: + syslog.openlog("PMON_SYSLOG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def pmon_error(s): + if PMONERROR & debuglevel: + syslog.openlog("PMON_SYSLOG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def dev_syslog(s): + syslog.openlog("PMON_SYSLOG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_NOTICE, s) + + +# status +STATUS_PRESENT = 'PRESENT' +STATUS_ABSENT = 'ABSENT' +STATUS_OK = 'OK' +STATUS_NOT_OK = 'NOT OK' +STATUS_FAILED = 'FAILED' + + +class checkBase(object): + def __init__(self, path, name, config): + self._peroid_syslog = None + self._peroid_failed_syslog = None # exception + self._preDevStatus = None + self._path = path + self._name = name + self._config = config + + def getCurstatus(self): + # get ok/not ok/absent status + status, log = self.getPresent() + if status == STATUS_PRESENT: + # check status + property_status, log = self.getStatus() + if property_status is not None: + status = property_status + return status, log + + def getPresent(self): + presentFilepath = self.getPath() + try: + # get ok/not ok/absent status + presentConfig = self._config["present"] + mask = presentConfig.get("mask", 0xff) + absent_val = presentConfig.get("ABSENT", None) + absent_val = absent_val & mask + with open(presentFilepath, "r") as fd: + retval = fd.read() + if int(retval) == absent_val: + return STATUS_ABSENT, None + else: + return STATUS_PRESENT, None + except Exception as e: + return STATUS_FAILED, (str(e) + " location[%s]" % presentFilepath) + + def getStatus(self): + if "status" in self._config: + statusConfig = self._config["status"] + for itemConfig in statusConfig: + mask = itemConfig.get("mask", 0xff) + ok_val = itemConfig.get("okval", None) + ok_val = ok_val & mask + Filepath = itemConfig["path"] % self._name + try: + with open(Filepath, "r") as fd1: + retval = fd1.read() + if int(retval) != ok_val: + return STATUS_NOT_OK, None + except Exception as e: + return STATUS_FAILED, (str(e) + " location[%s]" % Filepath) + return STATUS_OK, None + return None, None + + def getPath(self): + pass + + def getName(self): + pass + + def getType(self): + pass + + def getnochangedMsgFlag(self): + return self._config["nochangedmsgflag"] + + def getnochangedMsgTime(self): + return self._config["nochangedmsgtime"] + + def getnoprintFirstTimeFlag(self): + return self._config["noprintfirsttimeflag"] + + def checkStatus(self): + # syslog msg + dev_type = self.getType() + dev_name = self.getName() + nochangedMsgTime = self.getnochangedMsgTime() + getnochangedMsgFlag = self.getnochangedMsgFlag() + noprintFirstTimeFlag = self.getnoprintFirstTimeFlag() + MSG_IN = '%%PMON-5-' + dev_type + '_PLUG_IN: %s is PRESENT.' + MSG_OUT = '%%PMON-5-' + dev_type + '_PLUG_OUT: %s is ABSENT.' + MSG_OK = '%%PMON-5-' + dev_type + '_OK: %s is OK.' + MSG_NOT_OK = '%%PMON-5-' + dev_type + '_FAILED: %s is NOT OK.' + MSG_ABSENT = '%%PMON-5-' + dev_type + '_ABSENT: %s is ABSENT.' + MSG_UNKNOWN = '%%PMON-5-' + dev_type + '_UNKNOWN: %s is UNKNOWN.%s' + MSG_RECOVER = '%%PMON-5-' + dev_type + '_OK: %s is OK. Recover from ' + dev_type + ' FAILED.' + + curStatus, log = self.getCurstatus() + pmon_debug("%s: current status %s" % (dev_name, curStatus)) + pmon_debug("%s: pre status %s" % (dev_name, self._preDevStatus)) + pmon_debug("%s: peroid_syslog %s" % (dev_name, self._peroid_syslog)) + + if curStatus == STATUS_FAILED: + # get status failed + if self._peroid_failed_syslog is not None: + if getnochangedMsgFlag and time.time() - self._peroid_failed_syslog >= nochangedMsgTime: + # absent as before for some time, notice + dev_syslog(MSG_UNKNOWN % (dev_name, log)) + self._peroid_failed_syslog = time.time() + else: # first time failed + dev_syslog(MSG_UNKNOWN % (dev_name, log)) + self._peroid_failed_syslog = time.time() + return + self._peroid_failed_syslog = time.time() + + if self._preDevStatus is None: + # 1st time + if noprintFirstTimeFlag == 1: + self._peroid_syslog = time.time() + else: + if curStatus == STATUS_PRESENT: + # present + dev_syslog(MSG_IN % dev_name) + elif curStatus == STATUS_OK: + # ok + dev_syslog(MSG_OK % dev_name) + elif curStatus == STATUS_NOT_OK: + # not ok + dev_syslog(MSG_NOT_OK % dev_name) + self._peroid_syslog = time.time() + else: + # absent + dev_syslog(MSG_ABSENT % dev_name) + self._peroid_syslog = time.time() + else: + # from 2nd time... + if self._preDevStatus == curStatus: + # status not changed + if self._preDevStatus == STATUS_ABSENT: + if self._peroid_syslog is not None: + if getnochangedMsgFlag and time.time() - self._peroid_syslog >= nochangedMsgTime: + # absent as before for some time, notice + dev_syslog(MSG_ABSENT % dev_name) + self._peroid_syslog = time.time() + elif self._preDevStatus == STATUS_NOT_OK: + if self._peroid_syslog is not None: + if getnochangedMsgFlag and time.time() - self._peroid_syslog >= nochangedMsgTime: + # not ok as before for some time, notice + dev_syslog(MSG_NOT_OK % dev_name) + self._peroid_syslog = time.time() + else: + pass + else: + # status changed + if self._preDevStatus == STATUS_ABSENT: + if curStatus == STATUS_NOT_OK: + # absent -> not ok + dev_syslog(MSG_IN % dev_name) + dev_syslog(MSG_NOT_OK % dev_name) + self._peroid_syslog = time.time() + elif curStatus == STATUS_OK: + # absent -> ok + dev_syslog(MSG_IN % dev_name) + dev_syslog(MSG_OK % dev_name) + else: + # absent -> prsent + dev_syslog(MSG_IN % dev_name) + + elif self._preDevStatus == STATUS_OK: + if(curStatus == STATUS_NOT_OK): + # ok -> not ok + dev_syslog(MSG_NOT_OK % dev_name) + self._peroid_syslog = time.time() + elif curStatus == STATUS_ABSENT: + # ok -> absent + dev_syslog(MSG_OUT % dev_name) + self._peroid_syslog = time.time() + else: + pass + elif self._preDevStatus == STATUS_PRESENT: + # present -> absent + dev_syslog(MSG_OUT % dev_name) + self._peroid_syslog = time.time() + else: # not ok + if curStatus == STATUS_OK: + # not ok -> ok + dev_syslog(MSG_RECOVER % dev_name) + dev_syslog(MSG_OK % dev_name) + else: + # not ok -> absent + dev_syslog(MSG_OUT % dev_name) + self._peroid_syslog = time.time() + self._preDevStatus = curStatus + + +class checkSfp(checkBase): + def __init__(self, path, name, config): + super(checkSfp, self).__init__(path, name, config) + + def getPath(self): + super(checkSfp, self).getPath() + return self._path + + def getName(self): + super(checkSfp, self).getName() + return self._name + + def getType(self): + super(checkSfp, self).getType() + return 'XCVR' + + +class checkSlot(checkBase): + def __init__(self, path, name, config): + super(checkSlot, self).__init__(path, name, config) + + def getPath(self): + super(checkSlot, self).getPath() + return self._path + + def getName(self): + super(checkSlot, self).getName() + return self._name + + def getType(self): + super(checkSlot, self).getType() + return 'SLOT' + + +class checkPSU(checkBase): + def __init__(self, path, name, config): + super(checkPSU, self).__init__(path, name, config) + + def getPath(self): + super(checkPSU, self).getPath() + return self._path + + def getName(self): + super(checkPSU, self).getName() + return self._name + + def getType(self): + super(checkPSU, self).getType() + return 'PSU' + + +class checkFAN(checkBase): + def __init__(self, path, name, config): + super(checkFAN, self).__init__(path, name, config) + + def getPath(self): + super(checkFAN, self).getPath() + return self._path + + def getName(self): + super(checkFAN, self).getName() + return self._name + + def getType(self): + super(checkFAN, self).getType() + return 'FAN' + + +class platformSyslog(): + def __init__(self): + self.__sfp_checklist = list() + self.__fan_checklist = list() + self.__psu_checklist = list() + self.__slot_checklist = list() + self.__temp_checklist = list() + self.temps_peroid_syslog = {} + self.normal_status = 0 + self.warning_status = 1 + self.critical_status = 2 + self.poweron_flag = 0 + + self.pmon_syslog_config = PMON_SYSLOG_STATUS.copy() + self.__pollingtime = self.pmon_syslog_config.get('polling_time', 3) + + tmpconfig = self.pmon_syslog_config.get('sffs', None) + if tmpconfig is not None: + preset_item = tmpconfig.get("present", {}) + path = preset_item.get("path", []) + for location in path: + if '*' not in location: + pmon_error("sff location config error: %s" % location) + continue + dev_name_index = 0 + loc_split_list = location.split('/') + for i in range(len(loc_split_list)): + if '*' in loc_split_list[i]: + dev_name_index = i + break + locations = glob.glob(location) + for dev_path in locations: + dev_name_list = dev_path.split('/') + dev_name = dev_name_list[dev_name_index] # explame:get eth1 from /sys_switch/transceiver/eth1/present + dev_name_alias = tmpconfig.get("alias", {}) + dev_name = dev_name_alias.get(dev_name, dev_name) + dev = checkSfp(dev_path, dev_name, tmpconfig) + self.__sfp_checklist.append(dev) + + tmpconfig = self.pmon_syslog_config.get('fans', None) + if tmpconfig is not None: + preset_item = tmpconfig.get("present", {}) + path = preset_item.get("path", []) + for location in path: + if '*' not in location: + pmon_error("fan location config error: %s" % location) + continue + dev_name_index = 0 + loc_split_list = location.split('/') + for i in range(len(loc_split_list)): + if '*' in loc_split_list[i]: + dev_name_index = i + break + locations = glob.glob(location) + for dev_path in locations: + dev_name_list = dev_path.split('/') + dev_name = dev_name_list[dev_name_index] + dev_name_alias = tmpconfig.get("alias", {}) + dev_name = dev_name_alias.get(dev_name, dev_name) + dev = checkFAN(dev_path, dev_name, tmpconfig) + self.__fan_checklist.append(dev) + + tmpconfig = self.pmon_syslog_config.get('psus', None) + if tmpconfig is not None: + preset_item = tmpconfig.get("present", {}) + path = preset_item.get("path", []) + for location in path: + if '*' not in location: + pmon_error("psu location config error: %s" % location) + continue + dev_name_index = 0 + loc_split_list = location.split('/') + for i in range(len(loc_split_list)): + if '*' in loc_split_list[i]: + dev_name_index = i + break + locations = glob.glob(location) + for dev_path in locations: + dev_name_list = dev_path.split('/') + dev_name = dev_name_list[dev_name_index] + dev_name_alias = tmpconfig.get("alias", {}) + dev_name = dev_name_alias.get(dev_name, dev_name) + dev = checkPSU(dev_path, dev_name, tmpconfig) + self.__psu_checklist.append(dev) + + tmpconfig = self.pmon_syslog_config.get('slots', None) + if tmpconfig is not None: + preset_item = tmpconfig.get("present", {}) + path = preset_item.get("path", []) + for location in path: + if '*' not in location: + pmon_error("slot location config error: %s" % location) + continue + dev_name_index = 0 + loc_split_list = location.split('/') + for i in range(len(loc_split_list)): + if '*' in loc_split_list[i]: + dev_name_index = i + break + locations = glob.glob(location) + for dev_path in locations: + dev_name_list = dev_path.split('/') + dev_name = dev_name_list[dev_name_index] + dev_name_alias = tmpconfig.get("alias", {}) + dev_name = dev_name_alias.get(dev_name, dev_name) + dev = checkSlot(dev_path, dev_name, tmpconfig) + self.__slot_checklist.append(dev) + + tmpconfig = self.pmon_syslog_config.get('temps', None) + if tmpconfig is not None: + self.__temp_checklist = tmpconfig.get('temps_list', []) + self.__temps_pollingseconds = tmpconfig.get('over_temps_polling_seconds', None) + + def checkTempStaus(self, temp_item): + temp_name = temp_item.get('name', None) + input_path = temp_item.get('input_path', None) + warning_temp = temp_item.get('warning', None) + critical_temp = temp_item.get('critical', None) + input_accuracy = temp_item.get('input_accuracy', None) + if temp_name is None or input_path is None or warning_temp is None or critical_temp is None: + dev_syslog('%%PMON-5-TEMP_NOTICE: get temperature config parament failed.') + return + try: + locations = glob.glob(input_path) + with open(locations[0], "r") as fd: + input_temp = fd.read() + input_temp = float(input_temp) / float(input_accuracy) + + if 'time' not in temp_item: + temp_item['time'] = time.time() + temp_item['status'] = self.normal_status + if float(input_temp) >= float(warning_temp): + if float(input_temp) >= float(critical_temp): + if time.time() - temp_item['time'] >= self.__temps_pollingseconds or temp_item['status'] != self.critical_status: + dev_syslog('%%PMON-5-TEMP_HIGH: %s temperature %sC is larger than max critical threshold %sC.' + % (temp_name, input_temp, critical_temp)) + temp_item['status'] = self.critical_status + temp_item['time'] = time.time() + else: + if time.time() - temp_item['time'] >= self.__temps_pollingseconds or temp_item['status'] != self.warning_status: + dev_syslog('%%PMON-5-TEMP_HIGH: %s temperature %sC is larger than max warning threshold %sC.' + % (temp_name, input_temp, warning_temp)) + temp_item['status'] = self.warning_status + temp_item['time'] = time.time() + else: + pmon_debug("%s temperature %sC is in range [%s, %s]" % (temp_name, input_temp, warning_temp, critical_temp)) + temp_item['status'] = self.normal_status + temp_item['time'] = time.time() + except Exception as e: + dev_syslog('%%PMON-5-TEMP_NOTICE: Cannot get %s temperature. Exception log: %s' % (temp_name, str(e))) + return + + def sysfs_precondition_check(self, check_module, check_project): + try: + tmpconfig = self.pmon_syslog_config.get(check_module, None) + if tmpconfig is not None: + check_list = tmpconfig.get(check_project, []) + for check_item in check_list: + location = check_item.get("path", None) + ok_val = check_item.get("ok_val", None) + mask = check_item.get("mask", 0xff) + ok_val = ok_val & mask + locations = glob.glob(location) + for power_path in locations: + with open(power_path, "r") as fd: + retval = fd.read() + if int(retval) == ok_val: + continue + else: + return + self.poweron_flag = 1 + except Exception as e: + dev_syslog('%%PMON-5-TEMP_NOTICE: Cannot check power status. Exception log: %s' % str(e)) + return + + def updateSysDeviceStatus(self): + if self.poweron_flag == 1: + for dev in self.__sfp_checklist: + dev.checkStatus() + else: + self.sysfs_precondition_check('sffs', 'power') + + for dev in self.__fan_checklist: + dev.checkStatus() + for dev in self.__psu_checklist: + dev.checkStatus() + for dev in self.__slot_checklist: + dev.checkStatus() + for temp_item in self.__temp_checklist: + self.checkTempStaus(temp_item) + + def getPollingtime(self): + return self.__pollingtime + + def debug_init(self): + global debuglevel + try: + with open(PMON_DEBUG_FILE, "r") as fd: + value = fd.read() + debuglevel = int(value) + except Exception as e: + debuglevel = 0 + return + + def doWork(self): + try: + self.debug_init() + self.updateSysDeviceStatus() + except Exception as e: + MSG_EXCEPTION = '%%PMON-5-NOTICE: Exception happened! info:{%s}' + pmon_error(MSG_EXCEPTION % traceback.format_exc()) + + +def run(platform): + while True: + platform.doWork() + time.sleep(platform.getPollingtime()) + + +if __name__ == '__main__': + platform = platformSyslog() + run(platform) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijiecommon.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijiecommon.py new file mode 100755 index 000000000000..539a1a3ff7db --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijiecommon.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 +# ------------------------------------------------------------------------------- +# Author: sonic_rd@ruijie.com.cn +# +# Created: 02/07/2018 +# Copyright: 2001-2022 Ruijie Network. All rights reserved. +# ------------------------------------------------------------------------------- +__all__ = [ + "GLOBALCONFIG", + "STARTMODULE", + "MAC_AVS_PARAM", + "MAC_DEFAULT_PARAM", + "DEV_MONITOR_PARAM", + "MANUINFO_CONF", + "AVS_VOUT_MODE_PARAM", + "PMON_SYSLOG_STATUS", + "OPTOE", + "BLACKLIST_DRIVERS", + "INIT_PARAM_PRE", + "INIT_COMMAND_PRE", + "INIT_PARAM", + "INIT_COMMAND", + "DRIVERLISTS", + "DEVICE", +] + + +GLOBALCONFIG = {} +STARTMODULE = {} +MAC_AVS_PARAM = {} +MAC_DEFAULT_PARAM = {} +DEV_MONITOR_PARAM = {} +MANUINFO_CONF = {} +AVS_VOUT_MODE_PARAM = {} +PMON_SYSLOG_STATUS = {} +OPTOE = [] +BLACKLIST_DRIVERS = [] +INIT_PARAM_PRE = [] +INIT_COMMAND_PRE = [] +INIT_PARAM = [] +INIT_COMMAND = [] +DRIVERLISTS = [] +DEVICE = [] diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieconfig.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieconfig.py new file mode 100755 index 000000000000..4559d2201dfb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieconfig.py @@ -0,0 +1,86 @@ +#!/usr/bin/python3 +#------------------------------------------------------------------------------- +# Name: ruijieconfig.py +# +# Author: sonic_rd@ruijie.com.cn +# +# Created: 02/07/2018 +# Copyright: 2001-2022 Ruijie Network. All rights reserved. +#------------------------------------------------------------------------------- +import sys +import os +from rjutil.baseutil import get_machine_info +from rjutil.baseutil import get_platform_info +from rjutil.baseutil import get_board_id + + +def getdeviceplatform(): + x = get_platform_info(get_machine_info()) + if x is not None: + filepath = "/usr/share/sonic/device/" + x + return filepath + return None + + +platform = get_platform_info(get_machine_info()) +board_id = get_board_id(get_machine_info()) +platformpath = getdeviceplatform() +MAILBOX_DIR = "/sys/bus/i2c/devices/" +grtd_productfile = (platform + "_config").replace("-", "_") +common_productfile = "ruijiecommon" +platform_configfile = (platform + "_" + board_id + "_config").replace("-", "_") # platfrom + board_id +configfile_pre = "/usr/local/bin/" +sys.path.append(platformpath) +sys.path.append(configfile_pre) + + +def get_rjconfig_info(attr_key): + rjconf_filename = platformpath + "/plugins" + "/rj.conf" + if not os.path.isfile(rjconf_filename): + return None + with open(rjconf_filename) as rjconf_file: + for line in rjconf_file: + tokens = line.split('=') + if len(tokens) < 2: + continue + if tokens[0] == attr_key: + return tokens[1].strip() + return None + + +############################################################################################ +if os.path.exists(configfile_pre + platform_configfile + ".py"): + module_product = __import__(platform_configfile, globals(), locals(), [], 0) +elif os.path.exists(configfile_pre + grtd_productfile + ".py"): + module_product = __import__(grtd_productfile, globals(), locals(), [], 0) +elif os.path.exists(configfile_pre + common_productfile + ".py"): + module_product = __import__(common_productfile, globals(), locals(), [], 0) +else: + print("config file not exist") + exit(-1) +############################################################################################ + +DEVICE = module_product.DEVICE + +RUIJIE_GLOBALCONFIG ={ + "DRIVERLISTS":module_product.DRIVERLISTS, + "OPTOE": module_product.OPTOE, + "DEVS": DEVICE, + "BLACKLIST_DRIVERS": module_product.BLACKLIST_DRIVERS +} +GLOBALCONFIG = RUIJIE_GLOBALCONFIG +GLOBALINITPARAM = module_product.INIT_PARAM +GLOBALINITCOMMAND = module_product.INIT_COMMAND +GLOBALINITPARAM_PRE = module_product.INIT_PARAM_PRE +GLOBALINITCOMMAND_PRE = module_product.INIT_COMMAND_PRE + +STARTMODULE = module_product.STARTMODULE + +DEV_MONITOR_PARAM = module_product.DEV_MONITOR_PARAM +PMON_SYSLOG_STATUS = module_product.PMON_SYSLOG_STATUS + +MAC_AVS_PARAM = module_product.MAC_AVS_PARAM +MAC_DEFAULT_PARAM = module_product.MAC_DEFAULT_PARAM + +MANUINFO_CONF = module_product.MANUINFO_CONF +AVS_VOUT_MODE_PARAM = module_product.AVS_VOUT_MODE_PARAM diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieutil.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieutil.py new file mode 100755 index 000000000000..13bcbf7ba036 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/ruijieutil.py @@ -0,0 +1,72 @@ +#!/usr/bin/python3 +# ------------------------------------------------------------------------- +# +# Author: sonic_rd +# +# Created: 02/07/2018 +# Copyright: 2001-2022 Ruijie Network. All rights reserved. +# ------------------------------------------------------------------------- +import sys +import os +import re +import time +from ruijieconfig import STARTMODULE +from platform_util import rj_os_system + + +def getSdkReg(reg): + try: + cmd = "bcmcmd -t 1 'getr %s ' < /dev/null" % reg + ret, result = rj_os_system(cmd) + result_t = result.strip().replace("\r", "").replace("\n", "") + if ret != 0 or "Error:" in result_t: + return False, result + patt = r"%s.(.*):(.*)>drivshell" % reg + rt = re.findall(patt, result_t, re.S) + test = re.findall("=(.*)", rt[0][0])[0] + except Exception as e: + return False, 'getsdk register error' + return True, test + + +def waitForDhcp(timeout): + time_cnt = 0 + while True: + try: + ret, status = rj_os_system("systemctl status dhcp_relay.service") + if (ret == 0 and "running" in status) or "SUCCESS" in status: + break + else: + sys.stdout.write(".") + sys.stdout.flush() + time_cnt = time_cnt + 1 + if time_cnt > timeout: + raise Exception("waitForDhcp timeout") + time.sleep(1) + except Exception as e: + return False + return True + +def waitForSdk(sdk_fpath ,timeout): + time_cnt = 0 + while True: + try: + if os.path.exists(sdk_fpath): + break + else: + #sys.stdout.write(".") + #sys.stdout.flush() + time_cnt = time_cnt + 1 + if time_cnt > timeout: + raise Exception("waitForSdk timeout") + time.sleep(1) + except Exception as e: + return False + return True + +def waitForDocker(need_restart=False,timeout=180): + sdkcheck_params = STARTMODULE.get("sdkcheck",{}) + if sdkcheck_params.get("checktype") == "file": + sdk_fpath = sdkcheck_params.get("sdk_fpath") + return waitForSdk(sdk_fpath,timeout) + return waitForDhcp(timeout) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/sensors b/platform/broadcom/sonic-platform-modules-tencent/common/script/sensors new file mode 100755 index 000000000000..a2c72b123a43 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/sensors @@ -0,0 +1,8 @@ +#!/bin/bash +#docker exec -i pmon sensors "$@" + + +#To probe sensors not part of lm-sensors +if [ -r /usr/local/bin/platform_sensors.py ]; then + python /usr/local/bin/platform_sensors.py +fi diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/sfp_highest_temperatue.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/sfp_highest_temperatue.py new file mode 100755 index 000000000000..be1960a131ea --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/sfp_highest_temperatue.py @@ -0,0 +1,150 @@ +#!/usr/bin/python3 +import os +import importlib.machinery +import time +import syslog +import subprocess +import fcntl + +sfp_temperature_file = "/tmp/highest_sff_temp" + +SFP_TEMP_DEBUG_FILE = "/etc/.sfp_temp_debug_flag" +SFP_TEMP_RECORD_DEBUG = 1 +SFP_TEMP_RECORD_ERROR = 2 +debuglevel = 0 + + +def sfp_temp_debug(s): + if SFP_TEMP_RECORD_DEBUG & debuglevel: + syslog.openlog("SFP_TEMP_DEBUG", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def sfp_temp_error(s): + if SFP_TEMP_RECORD_ERROR & debuglevel: + syslog.openlog("SFP_TEMP_ERROR", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +pidfile = -1 + + +def file_rw_lock(): + global pidfile + pidfile = open(sfp_temperature_file, "r") + try: + fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB) + sfp_temp_debug("file lock success") + return True + except Exception as e: + pidfile.close() + pidfile = -1 + return False + + +def file_rw_unlock(): + try: + global pidfile + + if pidfile != -1: + fcntl.flock(pidfile, fcntl.LOCK_UN) + pidfile.close() + pidfile = -1 + sfp_temp_debug("file unlock success") + else: + sfp_temp_debug("pidfile is invalid, do nothing") + return True + except Exception as e: + sfp_temp_error("file unlock err, msg:%s" % (str(e))) + return False + + +def get_sfp_highest_temperature(): + highest_temperature = 0 + platform_sfputil = None + + sfputil_dir = "/usr/share/sonic/device/" + try: + if not os.path.exists(sfputil_dir): + sfputil_dir = "/usr/share/sonic/platform/" + sfputil_path = sfputil_dir + "/plugins/sfputil.py" + else: + cmd = "cat /host/machine.conf | grep onie_build_platform" + ret, output = subprocess.getstatusoutput(cmd) + if ret != 0: + sfp_temp_error("cmd: %s execution fail, output: %s" % (cmd, output)) + + onie_platform = output.split("=")[1] + sfputil_path = sfputil_dir + onie_platform + "/plugins/sfputil.py" + + module = importlib.machinery.SourceFileLoader("sfputil", sfputil_path).load_module() + platform_sfputil_class = getattr(module, "SfpUtil") + platform_sfputil = platform_sfputil_class() + + temperature = platform_sfputil.get_highest_temperature() + highest_temperature = int(temperature) * 1000 + except Exception as e: + sfp_temp_error("get sfp temperature error, msg:%s" % str(e)) + highest_temperature = -9999000 + + return highest_temperature + + +def write_sfp_highest_temperature(temperature): + + loop = 1000 + ret = False + try: + if os.path.exists(sfp_temperature_file) is False: + with open(sfp_temperature_file, 'w') as sfp_f: + pass + for i in range(0, loop): + ret = file_rw_lock() + if ret is True: + break + time.sleep(0.001) + + if ret is False: + sfp_temp_error("take file lock timeout") + return + + with open(sfp_temperature_file, 'w') as sfp_f: + sfp_f.write("%s\n" % str(temperature)) + + file_rw_unlock() + return + except Exception as e: + sfp_temp_error("write sfp temperature error, msg:%s" % str(e)) + file_rw_unlock() + return + + +def debug_init(): + global debuglevel + + try: + with open(SFP_TEMP_DEBUG_FILE, "r") as fd: + value = fd.read() + debuglevel = int(value) + except Exception as e: + debuglevel = 0 + return + + +def main(): + with open(sfp_temperature_file, 'w') as sfp_f: + pass + while True: + debug_init() + temperature = 0 + try: + temperature = get_sfp_highest_temperature() + write_sfp_highest_temperature(temperature) + except Exception as e: + sfp_temp_error("get/write sfp temperature error, msg:%s" % str(e)) + write_sfp_highest_temperature(-9999000) + time.sleep(5) + + +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/script/xdpe_avscontrol.py b/platform/broadcom/sonic-platform-modules-tencent/common/script/xdpe_avscontrol.py new file mode 100755 index 000000000000..515a8aa01c74 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/script/xdpe_avscontrol.py @@ -0,0 +1,217 @@ +#!/usr/bin/env python3 +import click +import os +import time +import syslog +from ruijieconfig import MAC_DEFAULT_PARAM, MAC_AVS_PARAM, AVS_VOUT_MODE_PARAM +from ruijieutil import getSdkReg +from platform_util import rji2cget, rji2cset, rji2csetWord, rji2cgetWord, write_sysfs, get_value + + +AVSCTROL_DEBUG_FILE = "/etc/.avscontrol_debug_flag" + +AVSCTROLERROR = 1 +AVSCTROLDEBUG = 2 + +debuglevel = 0 + +CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) + + +class AliasedGroup(click.Group): + def get_command(self, ctx, cmd_name): + rv = click.Group.get_command(self, ctx, cmd_name) + if rv is not None: + return rv + matches = [x for x in self.list_commands(ctx) + if x.startswith(cmd_name)] + if not matches: + return None + elif len(matches) == 1: + return click.Group.get_command(self, ctx, matches[0]) + ctx.fail('Too many matches: %s' % ', '.join(sorted(matches))) + return None + + +def avscontrol_debug(s): + if AVSCTROLDEBUG & debuglevel: + syslog.openlog("AVSCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_DEBUG, s) + + +def avscontrol_error(s): + if AVSCTROLERROR & debuglevel: + syslog.openlog("AVSCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def avserror(s): + # s = s.decode('utf-8').encode('gb2312') + syslog.openlog("AVSCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_ERR, s) + + +def avsinfo(s): + syslog.openlog("AVSCONTROL", syslog.LOG_PID) + syslog.syslog(syslog.LOG_INFO, s) + + +def debug_init(): + global debuglevel + if os.path.exists(AVSCTROL_DEBUG_FILE): + debuglevel = debuglevel | AVSCTROLDEBUG | AVSCTROLERROR + else: + debuglevel = debuglevel & ~(AVSCTROLDEBUG | AVSCTROLERROR) + + +def set_avs_value_i2c(dcdc_value): + avs_bus = MAC_DEFAULT_PARAM["bus"] + avs_addr = MAC_DEFAULT_PARAM["devno"] + avs_loop_addr = MAC_DEFAULT_PARAM["loopaddr"] + avs_loop_val = MAC_DEFAULT_PARAM["loop"] + vout_mode_addr = MAC_DEFAULT_PARAM["vout_mode_addr"] + vout_cmd_addr = MAC_DEFAULT_PARAM["vout_cmd_addr"] + org_loop_value = None + try: + status, val = rji2cget(avs_bus, avs_addr, avs_loop_addr) + if status is not True: + raise Exception("get original loop value failed.") + org_loop_value = int(val, 16) + + status, val = rji2cset(avs_bus, avs_addr, avs_loop_addr, avs_loop_val) + if status is not True: + raise Exception("set loop value failed.") + + status, val = rji2cget(avs_bus, avs_addr, vout_mode_addr) + if status is not True: + raise Exception("get vout mode failed.") + vout_mode_value = int(val, 16) + if vout_mode_value not in AVS_VOUT_MODE_PARAM.keys(): + raise Exception("invalid vout mode.") + + vout_cmd_val = int(dcdc_value * AVS_VOUT_MODE_PARAM[vout_mode_value]) + avscontrol_debug("org_loop:0x%x, dcdc_value:%s, vout_mode:0x%x, vout_cmd_val:0x%x." % + (org_loop_value, dcdc_value, vout_mode_value, vout_cmd_val)) + rji2csetWord(avs_bus, avs_addr, vout_cmd_addr, vout_cmd_val) + status, val = rji2cgetWord(avs_bus, avs_addr, vout_cmd_addr) + if status is not True or strtoint(val) != vout_cmd_val: + raise Exception("set vout command data failed. status:%s, write value:0x%x, read value:0x%x" % + (status, vout_cmd_val, strtoint(val))) + avscontrol_debug("set vout command data success.") + + except Exception as e: + avscontrol_error(str(e)) + status = False + + if org_loop_value is not None: + rji2cset(avs_bus, avs_addr, avs_loop_addr, org_loop_value) + return status + + +def set_avs_value_sysfs(conf, dcdc_value): + loc = conf.get("loc") + formula = conf.get("formula", None) + avscontrol_debug("set_avs_value_sysfs, loc: %s, origin dcdc value: %s, formula: %s" % + (loc, dcdc_value, formula)) + if formula is not None: + dcdc_value = eval(formula % (dcdc_value)) + wr_val = str(dcdc_value) + avscontrol_debug("set_avs_value_sysfs, write val: %s" % wr_val) + ret, msg = write_sysfs(loc, wr_val) + if ret is False: + avscontrol_error("set_avs_value_sysfs failed, msg: %s" % msg) + return ret + + +def set_avs_value(dcdc_value): + set_avs_way = MAC_DEFAULT_PARAM.get("set_avs", {}).get("gettype") + if set_avs_way == "sysfs": + ret = set_avs_value_sysfs(MAC_DEFAULT_PARAM["set_avs"], dcdc_value) + else: + ret = set_avs_value_i2c(dcdc_value) + return ret + +def get_dcdc_value(rov_value): + if rov_value not in MAC_AVS_PARAM.keys(): + if MAC_DEFAULT_PARAM["type"] == 0: + avsinfo("VID:0x%x out of range, voltage regulate stop." % rov_value) + return False, None + dcdc_value = MAC_AVS_PARAM[MAC_DEFAULT_PARAM["default"]] + avsinfo("VID:0x%x out of range, use default VID:0x%x." % (rov_value, dcdc_value)) + else: + dcdc_value = MAC_AVS_PARAM[rov_value] + return True, dcdc_value + + +def get_rov_value_cpld(): + cpld_avs_config = MAC_DEFAULT_PARAM["cpld_avs"] + return get_value(cpld_avs_config) + + +def get_rov_value_sdk(): + name = MAC_DEFAULT_PARAM["sdkreg"] + ret, status = getSdkReg(name) + if ret == False: + return False, None + status = strtoint(status) + # shift operation + if MAC_DEFAULT_PARAM["sdktype"] != 0: + status = ( + status >> MAC_DEFAULT_PARAM["macregloc"]) & MAC_DEFAULT_PARAM["mask"] + macavs = status + return True, macavs + + +def doAvsCtrol(): + try: + rov_source = MAC_DEFAULT_PARAM["rov_source"] + if rov_source == 0: + ret, rov_value = get_rov_value_cpld() # get rov from cpld reg + else: + ret, rov_value = get_rov_value_sdk() # get rov from sdk reg + if ret is False: + return False + avscontrol_debug("rov_value:0x%x." % rov_value) + ret, dcdc_value = get_dcdc_value(rov_value) + if ret is False: + return False + ret = set_avs_value(dcdc_value) + return ret + except Exception as e: + avscontrol_error(str(e)) + return False + + +def run(): + index = 0 + # wait 30s for device steady + time.sleep(30) + while True: + debug_init() + ret = doAvsCtrol() + if ret is True: + avsinfo("%%AVSCONTROL success") + time.sleep(5) + exit(0) + index += 1 + if index >= 10: + avserror("%%DEV_MONITOR-AVS: MAC Voltage adjust failed.") + exit(-1) + time.sleep(1) + + +@click.group(cls=AliasedGroup, context_settings=CONTEXT_SETTINGS) +def main(): + '''device operator''' + pass + + +@main.command() +def start(): + '''start AVS control''' + avsinfo("%%AVSCONTROL start") + run() + + +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_driver.service b/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_driver.service new file mode 100755 index 000000000000..ad10dcad87e0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_driver.service @@ -0,0 +1,15 @@ +[Unit] +Description= Ruijie Global Initialize platform drivers. +After=local-fs.target +Before=pmon.service rg_platform_process.service swss.service syncd.service +#DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/rg_platform_driver.py start +ExecStop=/usr/local/bin/rg_platform_driver.py stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_process.service b/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_process.service new file mode 100755 index 000000000000..18c911bd48e5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/service/rg_platform_process.service @@ -0,0 +1,15 @@ +[Unit] +Description= Ruijie Global Load process. +After=rg_platform_driver.service s3ip_sysfs.service +Requires=rg_platform_driver.service +#DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/rg_platform_process.py start +ExecStop=/usr/local/bin/rg_platform_process.py stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/__init__.py new file mode 100755 index 000000000000..052dab2e8797 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/__init__.py @@ -0,0 +1,2 @@ +__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "thermal", "psu", "fan", "fan_drawer", "watchdog"] +from . import platform \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/chassis.py new file mode 100755 index 000000000000..1ac10917c738 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/chassis.py @@ -0,0 +1,577 @@ +#!/usr/bin/env python3 + +############################################################################# +# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + import time + from sonic_platform_base.chassis_base import ChassisBase + from sonic_platform.sfp import Sfp + from sonic_platform.psu import Psu + from sonic_platform.fan import Fan + from sonic_platform.fan_drawer import FanDrawer + from sonic_platform.thermal import Thermal + from sonic_platform.component import Component + from sonic_platform.eeprom import Eeprom + from sonic_platform.logger import logger + from sonic_platform.dcdc import Dcdc + + from plat_hal.interface import interface + from plat_hal.baseutil import baseutil +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +class Chassis(ChassisBase): + """ + Platform-specific Chassis class + """ + # List of Dcdc objects representing all dcdc + # available on the chassis + _dcdc_list = None + + STATUS_INSERTED = "1" + STATUS_REMOVED = "0" + STATUS_NORMAL = "0" + STATUS_ABNORMAL = "1" + port_dict = {} + fan_present_dict = {} + voltage_status_dict = {} + + + def __init__(self): + ChassisBase.__init__(self) + self._dcdc_list = [] + self.int_case = interface() + conf = None + conf = baseutil.get_config() + port_cfg = conf.get("sfps", None) + self.port_start = port_cfg.get("port_start", 0) + self.port_end = port_cfg.get("port_end", 0) + + sfp_node = Sfp(self.port_start) + if sfp_node._get_config("port_index_start") == 1: + self._sfp_list.append(sfp_node) + # Initialize SFP list + + # sfp.py will read eeprom contents and retrive the eeprom data. + # It will also provide support sfp controls like reset and setting + # low power mode. + # We pass the eeprom path and sfp control path from chassis.py + # So that sfp.py implementation can be generic to all platforms + for index in range(self.port_start, self.port_end + 1): + sfp_node = Sfp(index) + self._sfp_list.append(sfp_node) + if sfp_node.get_presence(): + self.port_dict[index] = self.STATUS_INSERTED + # sfp_node.check_sfp_optoe_type() + else: + self.port_dict[index] = self.STATUS_REMOVED + + self._eeprom = Eeprom(self.int_case) + + fan_num = self.int_case.get_fan_total_number() + drawer_fan_list = [] + for index in range(fan_num): + fanobj = Fan(self.int_case, index + 1) + self._fan_list.append(fanobj) + drawer_fan_list.append(fanobj) + if drawer_fan_list: + fan_drawer = FanDrawer(0, fan_list=drawer_fan_list) + self._fan_drawer_list.append(fan_drawer) + + psu_num = self.int_case.get_psu_total_number() + for index in range(psu_num): + psuobj = Psu(self.int_case, index + 1) + self._psu_list.append(psuobj) + + thermal_num = self.int_case.get_temp_id_number() + for index in range(thermal_num): + thermalobj = Thermal(self.int_case, index + 1) + self._thermal_list.append(thermalobj) + + component_num = self.int_case.get_cpld_total_number() + for index in range(component_num): + componentobj = Component(self.int_case, index + 1) + self._component_list.append(componentobj) + + dcdc_num = self.int_case.get_dcdc_total_number() + for index in range(dcdc_num): + dcdcobj = Dcdc(self.int_case, index + 1) + self._dcdc_list.append(dcdcobj) + ''' + # init fan present status + for index in range(0, len(self._fan_list)): + if self._fan_list[index].get_presence() is True: + self.fan_present_dict[index] = self.STATUS_INSERTED + else: + self.fan_present_dict[index] = self.STATUS_REMOVED + + # init voltage status + for index in range(0, len(self._dcdc_list)): + name = self._dcdc_list[index].get_name() + value = self._dcdc_list[index].get_value() + high = self._dcdc_list[index].get_high_threshold() + low = self._dcdc_list[index].get_low_threshold() + if (value is None) or (value > high) or (value < low): + self.voltage_status_dict[name] = self.STATUS_ABNORMAL + else: + self.voltage_status_dict[name] = self.STATUS_NORMAL + ''' + + def get_name(self): + """ + Retrieves the name of the chassis + Returns: + string: The name of the chassis + """ + name = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + name = sys_eeprom.modelstr(e) + if name is None: + self.log_error('syseeprom name is error.') + return '' + return name + + def get_presence(self): + """ + Retrieves the presence of the chassis + Returns: + bool: True if chassis is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the chassis + Returns: + string: Model/part number of chassis + """ + model = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + model = sys_eeprom.modelnumber(e) + if model is None: + self.log_error('syseeprom model number is error.') + return '' + return model + + def get_serial_number(self): + """ + Retrieves the hardware serial number for the chassis + + Returns: + A string containing the hardware serial number for this chassis. + """ + serial_number = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + serial_number = sys_eeprom.serial_number_str(e) + if serial_number is None: + self.log_error('syseeprom serial number is error.') + return '' + + return serial_number + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + device_version = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + device_version = sys_eeprom.deviceversion(e) + if device_version is None: + self.log_error('syseeprom serial number is error.') + return '' + + return device_version + + def get_serial(self): + """ + Retrieves the serial number of the chassis (Service tag) + Returns: + string: Serial number of chassis + """ + return self.get_serial_number() + + def get_status(self): + """ + Retrieves the operational status of the chassis + Returns: + bool: A boolean value, True if chassis is operating properly + False if not + """ + return True + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + def get_status_led(self): + """ + Gets the state of the system LED + + Returns: + A string, one of the valid LED color strings which could be vendor + specified. + """ + ret, color = self.int_case.get_led_color_by_type('SYS_LED') + if ret is True: + return color + else: + return 'N/A' + + def get_base_mac(self): + """ + Retrieves the base MAC address for the chassis + + Returns: + A string containing the MAC address in the format + 'XX:XX:XX:XX:XX:XX' + """ + base_mac = '' + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return '' + + e = sys_eeprom.read_eeprom() + base_mac = sys_eeprom.base_mac_addr(e) + if base_mac is None: + self.log_error('syseeprom base mac is error.') + return '' + + return base_mac.upper() + + def get_system_eeprom_info(self): + """ + Retrieves the full content of system EEPROM information for the chassis + + Returns: + A dictionary where keys are the type code defined in + OCP ONIE TlvInfo EEPROM format and values are their corresponding + values. + Ex. { '0x21':'AG9064', '0x22':'V1.0', '0x23':'AG9064-0109867821', + '0x24':'001c0f000fcd0a', '0x25':'02/03/2018 16:22:00', + '0x26':'01', '0x27':'REV01', '0x28':'AG9064-C2358-16G'} + """ + sys_eeprom_dict = dict() + sys_eeprom = self.get_eeprom() + if sys_eeprom is None: + self.log_error('syseeprom is not inited.') + return {} + + e = sys_eeprom.read_eeprom() + if sys_eeprom._TLV_HDR_ENABLED: + if not sys_eeprom.is_valid_tlvinfo_header(e): + self.log_error('syseeprom tlv header error.') + return {} + total_len = (e[9] << 8) | e[10] + tlv_index = sys_eeprom._TLV_INFO_HDR_LEN + tlv_end = sys_eeprom._TLV_INFO_HDR_LEN + total_len + else: + tlv_index = sys_eeprom.eeprom_start + tlv_end = sys_eeprom._TLV_INFO_MAX_LEN + + while (tlv_index + 2) < len(e) and tlv_index < tlv_end: + if not sys_eeprom.is_valid_tlv(e[tlv_index:]): + self.log_error("Invalid TLV field starting at EEPROM offset %d" % tlv_index) + break + + tlv = e[tlv_index:tlv_index + 2 + e[tlv_index + 1]] + name, value = sys_eeprom.decoder(None, tlv) + sys_eeprom_dict[name] = value + + if e[tlv_index] == sys_eeprom._TLV_CODE_QUANTA_CRC or \ + e[tlv_index] == sys_eeprom._TLV_CODE_CRC_32: + break + tlv_index += e[tlv_index + 1] + 2 + + return sys_eeprom_dict + + def get_thermal_manager(self): + """ + Retrieves thermal manager class on this chassis + :return: A class derived from ThermalManagerBase representing the + specified thermal manager. ThermalManagerBase is returned as default + """ + return False + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + reset_num = self.int_case.get_cpu_reset_num() + # cold reboot + if reset_num == 0: + return(self.REBOOT_CAUSE_POWER_LOSS, None) + + return (self.REBOOT_CAUSE_NON_HARDWARE, None) + + def get_module(self, index): + """ + Retrieves module represented by (0-based) index + + Args: + index: An integer, the index (0-based) of the module to + retrieve + + Returns: + An object dervied from ModuleBase representing the specified + module + """ + module = None + + try: + if self.get_num_modules(): + module = self._module_list[index] + except IndexError: + sys.stderr.write("Module index {} out of range (0-{})\n".format( + index, len(self._module_list)-1)) + + return module + + def get_fan_drawer(self, index): + """ + Retrieves fan drawers represented by (0-based) index + + Args: + index: An integer, the index (0-based) of the fan drawer to + retrieve + + Returns: + An object dervied from FanDrawerBase representing the specified fan + drawer + """ + fan_drawer = None + + try: + if self.get_num_fan_drawers(): + fan_drawer = self._fan_drawer_list[index] + except IndexError: + sys.stderr.write("Fan drawer index {} out of range (0-{})\n".format( + index, len(self._fan_drawer_list)-1)) + + return fan_drawer + + def get_change_event(self, timeout=0): + """ + Returns a nested dictionary containing all devices which have + experienced a change at chassis level + + Args: + timeout: Timeout in milliseconds (optional). If timeout == 0, + this method will block until a change is detected. + + Returns: + (bool, dict): + - bool: True if call successful, False if not; + - dict: A nested dictionary where key is a device type, + value is a dictionary with key:value pairs in the format of + {'device_id':'device_event'}, where device_id is the device ID + for this device and device_event. + The known devices's device_id and device_event was defined as table below. + ----------------------------------------------------------------- + device | device_id | device_event | annotate + ----------------------------------------------------------------- + 'fan' '' '0' Fan removed + '1' Fan inserted + + 'sfp' '' '0' Sfp removed + '1' Sfp inserted + '2' I2C bus stuck + '3' Bad eeprom + '4' Unsupported cable + '5' High Temperature + '6' Bad cable + + 'voltage' '' '0' Vout normal + '1' Vout abnormal + -------------------------------------------------------------------- + Ex. {'fan':{'0':'0', '2':'1'}, 'sfp':{'11':'0', '12':'1'}, + 'voltage':{'U20':'0', 'U21':'1'}} + Indicates that: + fan 0 has been removed, fan 2 has been inserted. + sfp 11 has been removed, sfp 12 has been inserted. + monitored voltage U20 became normal, voltage U21 became abnormal. + Note: For sfp, when event 3-6 happened, the module will not be avalaible, + XCVRD shall stop to read eeprom before SFP recovered from error status. + """ + + change_event_dict = {"fan": {}, "sfp": {}, "voltage": {}} + + start_time = time.time() + forever = False + + if timeout == 0: + forever = True + elif timeout > 0: + timeout = timeout / float(1000) # Convert to secs + else: + print("get_change_event:Invalid timeout value", timeout) + return False, change_event_dict + + end_time = start_time + timeout + if start_time > end_time: + print( + "get_change_event:" "time wrap / invalid timeout value", + timeout, + ) + return False, change_event_dict # Time wrap or possibly incorrect timeout + try: + while timeout >= 0: + # check for sfp + sfp_change_dict = self.get_transceiver_change_event() + # check for fan + fan_change_dict = self.get_fan_change_event() + # check for voltage + voltage_change_dict = self.get_voltage_change_event() + + if sfp_change_dict or fan_change_dict or voltage_change_dict: + change_event_dict["sfp"] = sfp_change_dict + change_event_dict["fan"] = fan_change_dict + change_event_dict["voltage"] = voltage_change_dict + return True, change_event_dict + if forever: + time.sleep(1) + else: + timeout = end_time - time.time() + if timeout >= 1: + time.sleep(1) # We poll at 1 second granularity + else: + if timeout > 0: + time.sleep(timeout) + return True, change_event_dict + except Exception as e: + logger.error(str(e)) + print(e) + print("get_change_event: Should not reach here.") + return False, change_event_dict + + def get_transceiver_change_event(self): + current_port_dict = {} + ret_dict = {} + + # Check for OIR events and return ret_dict + for index in range(self.port_start, self.port_end + 1): + if self._sfp_list[index].get_presence(): + current_port_dict[index] = self.STATUS_INSERTED + else: + current_port_dict[index] = self.STATUS_REMOVED + + if len(self.port_dict) == 0: # first time + self.port_dict = current_port_dict + return {} + + if current_port_dict == self.port_dict: + return {} + + # Update reg value + for index, status in current_port_dict.items(): + if self.port_dict[index] != status: + ret_dict[index] = status + #ret_dict[str(index)] = status + self.port_dict = current_port_dict + for index, status in ret_dict.items(): + if int(status) == 1: + pass + #self._sfp_list[int(index)].check_sfp_optoe_type() + return ret_dict + + def get_fan_change_event(self): + currernt_fan_present_dict = {} + ret_dict = {} + + # Check for OIR events and return ret_dict + for index in range(0, len(self._fan_list)): + if self._fan_list[index].get_presence() is True: + currernt_fan_present_dict[index] = self.STATUS_INSERTED + else: + currernt_fan_present_dict[index] = self.STATUS_REMOVED + + if len(self.fan_present_dict) == 0: # first time + self.fan_present_dict = currernt_fan_present_dict + return {} + + if currernt_fan_present_dict == self.fan_present_dict: + return {} + + # updated fan_present_dict + for index, status in currernt_fan_present_dict.items(): + if self.fan_present_dict[index] != status: + ret_dict[str(index)] = status + self.fan_present_dict = currernt_fan_present_dict + return ret_dict + + def get_voltage_change_event(self): + currernt_voltage_status_dict = {} + ret_dict = {} + + # Check for OIR events and return ret_dict + for index in range(0, len(self._dcdc_list)): + name = self._dcdc_list[index].get_name() + value = self._dcdc_list[index].get_value() + high = self._dcdc_list[index].get_high_threshold() + low = self._dcdc_list[index].get_low_threshold() + if (value is None) or (value > high) or (value < low): + currernt_voltage_status_dict[name] = self.STATUS_ABNORMAL + else: + currernt_voltage_status_dict[name] = self.STATUS_NORMAL + + if len(self.voltage_status_dict) == 0: # first time + self.voltage_status_dict = currernt_voltage_status_dict + return {} + + if currernt_voltage_status_dict == self.voltage_status_dict: + return {} + + # updated voltage_status_dict + for name, status in currernt_voltage_status_dict.items(): + if self.voltage_status_dict[name] != status: + ret_dict[name] = status + self.voltage_status_dict = currernt_voltage_status_dict + return ret_dict diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/component.py new file mode 100755 index 000000000000..4fb655540ce2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/component.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 + +######################################################################## +# Ruijie B6510-48VS8CQ +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Components' (e.g., BIOS, CPLD, FPGA, etc.) available in +# the platform +# +######################################################################## + +try: + import time + from sonic_platform_base.component_base import ComponentBase + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Component(ComponentBase): + """Ruijie Platform-specific Component class""" + + def __init__(self, interface_obj, index): + self.cpld_dict = {} + self.int_case = interface_obj + self.index = index + self.update_time = 0 + self.cpld_id = "CPLD" + str(index) + + def cpld_dict_update(self): + local_time = time.time() + if not self.cpld_dict or (local_time - self.update_time) >= 1: # update data every 1 seconds + self.update_time = local_time + self.cpld_dict = self.int_case.get_cpld_version_by_id(self.cpld_id) + + def get_name(self): + """ + Retrieves the name of the component + + Returns: + A string containing the name of the component + """ + self.cpld_dict_update() + return self.cpld_dict["Name"] + + def get_description(self): + """ + Retrieves the description of the component + + Returns: + A string containing the description of the component + """ + self.cpld_dict_update() + return self.cpld_dict["Desc"] + + def get_firmware_version(self): + """ + Retrieves the firmware version of the component + + Returns: + A string containing the firmware version of the component + """ + self.cpld_dict_update() + return self.cpld_dict["Version"] + + def install_firmware(self, image_path): + """ + Installs firmware to the component + + Args: + image_path: A string, path to firmware image + + Returns: + A boolean, True if install was successful, False if not + """ + # not supported + return False + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/dcdc.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/dcdc.py new file mode 100755 index 000000000000..9500b3a6a79f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/dcdc.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 + +######################################################################## +# RUIJIE +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Thermals' information which are available in the platform +# +######################################################################## + + +try: + import time + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Dcdc(object): + + def __init__(self, interface_obj, index): + self.dcdc_dict = {} + self.int_case = interface_obj + self.index = index + self.update_time = 0 + self.dcdc_id = "DCDC" + str(index) + + #self.dcdc_dict = self.int_case.get_dcdc_by_id(self.dcdc_id) + + def dcdc_dict_update(self): + local_time = time.time() + if not self.dcdc_dict or (local_time - self.update_time) >= 1: # update data every 1 seconds + self.update_time = local_time + self.dcdc_dict = self.int_case.get_dcdc_by_id(self.dcdc_id) + + def get_name(self): + """ + Retrieves the name of the sensor + + Returns: + string: The name of the sensor + """ + self.dcdc_dict_update() + return self.dcdc_dict["Name"] + + def get_value(self): + """ + Retrieves current value reading from sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["Value"] + if value is None: + value = 0 + return round(float(value), 3) + + def get_high_threshold(self): + """ + Retrieves the high threshold temperature of sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["High"] + if value is None: + value = 0 + return round(float(value), 3) + + def get_low_threshold(self): + """ + Retrieves the low threshold temperature of sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["Low"] + if value is None: + value = 0 + return round(float(value), 3) + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature of sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["Max"] + if value is None: + value = 0 + return round(float(value), 3) + + def get_low_critical_threshold(self): + """ + Retrieves the low critical threshold temperature of sensor + """ + self.dcdc_dict_update() + value = self.dcdc_dict["Min"] + if value is None: + value = 0 + return round(float(value), 3) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/eeprom.py new file mode 100755 index 000000000000..16dbd76fb150 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/eeprom.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +######################################################################## +# Ruijie +# +# Module contains platform specific implementation of SONiC Platform +# Base API and provides the EEPROMs' information. +# +# The different EEPROMs available are as follows: +# - System EEPROM : Contains Serial number, Service tag, Base MA +# address, etc. in ONIE TlvInfo EEPROM format. +# - PSU EEPROM : Contains Serial number, Part number, Service Tag, +# PSU type, Revision. +# - Fan EEPROM : Contains Serial number, Part number, Service Tag, +# Fan type, Number of Fans in Fantray, Revision. +######################################################################## + +try: + from sonic_eeprom import eeprom_tlvinfo +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): + + def __init__(self, interface_obj): + self.int_case = interface_obj + self.name = "ONIE_E2" + + eeprom_path = self.int_case.get_onie_e2_path(self.name) + if eeprom_path is None: + raise ValueError("get eeprom path failed") + + super(Eeprom, self).__init__(eeprom_path, 0, "", True) + + + def modelnumber(self, e): + ''' + Returns the value field of the model(part) number TLV as a string + ''' + (is_valid, t) = self.get_tlv_field(e, self._TLV_CODE_PART_NUMBER) + if not is_valid: + return super(TlvInfoDecoder, self).part_number_str(e) + + return t[2].decode("ascii") + + def deviceversion(self, e): + ''' + Returns the value field of the Device Version as a string + ''' + (is_valid, t) = self.get_tlv_field(e, self._TLV_CODE_DEVICE_VERSION) + if not is_valid: + return "N/A" + + return str(ord(t[2])) + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan.py new file mode 100755 index 000000000000..27bd3ff47986 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan.py @@ -0,0 +1,310 @@ +#!/usr/bin/env python3 +######################################################################## +# Ruijie +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Fans' information which are available in the platform. +# +######################################################################## + +try: + import time + from sonic_platform_base.fan_base import FanBase + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Fan(FanBase): + """Ruijie Platform-specific Fan class""" + + def __init__(self, interface_obj, index, psu_fan=False, psu_index=0): + self.fan_dict = {} + self.int_case = interface_obj + self.index = index + self.psu_index = psu_index + self.is_psu_fan = psu_fan + + if not self.is_psu_fan: + self.name = "FAN" + str(index) + else: + self.name = "PSU" + str(psu_index) + + def fan_dict_update(self): + local_time = time.time() + if not self.fan_dict or (local_time - self.update_time) >= 1: # update data every 1 seconds + self.update_time = local_time + if not self.is_psu_fan: + self.fan_dict = self.int_case.get_fan_info(self.name) + else: + self.fan_dict = self.int_case.get_psu_fru_info(self.name) + + def get_name(self): + """ + Retrieves the fan name + Returns: + string: The name of the device + """ + if not self.is_psu_fan: + return "Fan{}".format(self.index) + else: + return "Psu{}-Fan{}".format(self.psu_index, self.index) + + def get_model(self): + """ + Retrieves the part number of the FAN + Returns: + string: Part number of FAN + """ + if not self.is_psu_fan: + self.fan_dict_update() + return self.fan_dict["NAME"] + else: + return 'N/A' + + def get_serial(self): + """ + Retrieves the serial number of the FAN + Returns: + string: Serial number of FAN + """ + if not self.is_psu_fan: + self.fan_dict_update() + return self.fan_dict["SN"] + else: + return 'N/A' + + def get_presence(self): + """ + Retrieves the presence of the FAN + Returns: + bool: True if fan is present, False if not + """ + if not self.is_psu_fan: + return self.int_case.get_fan_presence(self.name) + else: + return self.int_case.get_psu_presence(self.name) + + def checkFanRotorStatus(self): + err_num = 0 + rotor_num = self.int_case.get_fan_rotor_number(self.name) + for i in range(rotor_num): + rotor_name = "Rotor" + str(i + 1) + status = self.int_case.get_fan_rotor_status(self.name, rotor_name) + if status == False: + err_num = err_num + 1 + if (err_num == 0): + return True + else: + return False + + def get_status(self): + """ + Retrieves the operational status of the FAN + Returns: + bool: True if FAN is operating properly, False if not + """ + if not self.get_presence(): + return False + + speed = self.get_speed() + tolerance = self.get_speed_tolerance() + target = self.get_target_speed() + if (speed - target) > target * tolerance / 100: + return False + if (target - speed) > target * tolerance / 100: + return False + + return True + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + + def get_direction(self): + """ + Retrieves the fan airflow direction + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + + Notes: + - Forward/Exhaust : Air flows from Port side to Fan side. + - Reverse/Intake : Air flows from Fan side to Port side. + """ + self.fan_dict_update() + air_flow = self.fan_dict["AirFlow"] + if air_flow == "F2B": + return self.FAN_DIRECTION_INTAKE + elif air_flow == "B2F": + return self.FAN_DIRECTION_EXHAUST + else: + return self.FAN_DIRECTION_NOT_APPLICABLE + + def get_speed(self): + """ + Retrieves the speed of fan as a percentage of full speed + + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + if not self.get_presence(): + return 0 + + if not self.is_psu_fan: + fan_dir = {} + fan_dir = self.int_case.get_fan_info_rotor(self.name) + # get fan rotor1 pwm + value = fan_dir["Rotor1"]["Speed"] + max = fan_dir["Rotor1"]["SpeedMax"] + else: + psu_status_dict = self.int_case.get_psu_status(self.name) + value = psu_status_dict["FanSpeed"]["Value"] + max = psu_status_dict["FanSpeed"]["Max"] + + if isinstance(value, str) or value is None: + return 0 + pwm = value * 100 / max + if pwm > 100: + pwm = 100 + elif pwm < 0: + pwm = 0 + return int(pwm) + + def get_speed_tolerance(self): + """ + Retrieves the speed tolerance of the fan + Returns: + An integer, the percentage of variance from target speed which is + considered tolerable + """ + # The default tolerance value is fixed as 30% for all the Ruijie platform + if not self.is_psu_fan: + fan_dir = {} + fan_dir = self.int_case.get_fan_info_rotor(self.name) + # get fan rotor1 tolerance + tolerance = fan_dir["Rotor1"]["Tolerance"] + else: + psu_status_dict = self.int_case.get_psu_status(self.name) + tolerance = psu_status_dict["FanSpeed"]["Tolerance"] + + if isinstance(tolerance, str) or tolerance is None: + return 30 + return tolerance + + def fan_set_speed_pwm(self, pwm): + err_num = 0 + rotor_num = self.int_case.get_fan_rotor_number(self.name) + for i in range(rotor_num): + status = self.int_case.set_fan_speed_pwm(self.name, i + 1, pwm) + if status == -1: + err_num = err_num + 1 + if err_num == 0: + return True + else: + return False + + def set_speed(self, speed): + """ + Set fan speed to expected value + Args: + speed: An integer, the percentage of full fan speed to set fan to, + in the range 0 (off) to 100 (full speed) + Returns: + bool: True if set success, False if fail. + """ + if not self.is_psu_fan: + return self.fan_set_speed_pwm(speed) + else: + return self.int_case.set_psu_fan_speed_pwm(self.name, int(speed)) + + def set_status_led(self, color): + """ + Set led to expected color + Args: + color: A string representing the color with which to set the + fan module status LED + Returns: + bool: True if set success, False if fail. + """ + # not supported + return False + + def get_status_led(self): + """ + Gets the state of the Fan status LED + + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings. + """ + if self.is_psu_fan: + # No LED available for PSU Fan + return 'N/A' + + ret, color = self.int_case.get_fan_led(self.name) + if ret is True: + return color + else: + return 'N/A' + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + if not self.is_psu_fan: + # get fan rotor1 pwm + pwm = int(self.int_case.get_fan_speed_pwm(self.name, 0)) + else: + psu_status_dict = self.int_case.get_psu_status(self.name) + if psu_status_dict["InputStatus"] is False: + pwm = 0 + else: + psu_pwm = int(self.int_case.get_psu_fan_speed_pwm(self.name)) + if psu_pwm == 0: # psu fan not control + pwm = self.get_speed() # target equal to real pwm, to avoid alarm + else: + pwm = psu_pwm + return int(pwm) + + def get_vendor(self): + """ + Retrieves the vendor name of the fan + + Returns: + string: Vendor name of fan + """ + if not self.is_psu_fan: + return "Ruijie" + else: + return 'N/A' + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + if not self.is_psu_fan: + self.fan_dict_update() + return self.fan_dict["HW"] + else: + return 'N/A' + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan_drawer.py new file mode 100755 index 000000000000..a99ec6ae0705 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/fan_drawer.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +# +# fan_drawer_base.py +# +# Abstract base class for implementing a platform-specific class with which +# to interact with a fan drawer module in SONiC +# + +try: + from sonic_platform_base.fan_drawer_base import FanDrawerBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class FanDrawer(FanDrawerBase): + """ + Abstract base class for interfacing with a fan drawer + """ + # Device type definition. Note, this is a constant. + DEVICE_TYPE = "fan_drawer" + + def __init__(self, index, fan_list): + FanDrawerBase.__init__(self) + + self._fan_list = fan_list + self._index = index + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return "fan {}".format(self._index) + + def get_num_fans(self): + """ + Retrieves the number of fans available on this fan drawer + Returns: + An integer, the number of fan modules available on this fan drawer + """ + return len(self._fan_list) + + def get_all_fans(self): + """ + Retrieves all fan modules available on this fan drawer + Returns: + A list of objects derived from FanBase representing all fan + modules available on this fan drawer + """ + return self._fan_list + + def set_status_led(self, color): + """ + Sets the state of the fan drawer status LED + Args: + color: A string representing the color with which to set the + fan drawer status LED + Returns: + bool: True if status LED state is set successfully, False if not + """ + # not supported + return False + + def get_status_led(self, color): + """ + Gets the state of the fan drawer LED + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings above + """ + # not supported + return False + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return 'N/A' + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/logger.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/logger.py new file mode 100755 index 000000000000..61ef1647e5f2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/logger.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +import logging + + +def _init_logger(): + formatter = logging.Formatter( + "%(asctime)s %(levelname)s %(filename)s[%(funcName)s][%(lineno)s]: %(message)s" + ) + handler = logging.FileHandler("/var/log/syslog") + handler.setFormatter(formatter) + + logger = logging.getLogger(__name__) + logger.setLevel(logging.DEBUG) + logger.addHandler(handler) + return logger + + +logger = _init_logger() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/platform.py new file mode 100755 index 000000000000..ddf670369226 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/platform.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +############################################################################# +# Ruijie +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + from sonic_platform_base.platform_base import PlatformBase + from sonic_platform.chassis import Chassis +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PlatformBase): + """ + Ruijie Platform-specific class + """ + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/psu.py new file mode 100755 index 000000000000..70e8fb588387 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/psu.py @@ -0,0 +1,360 @@ +#!/usr/bin/env python3 +######################################################################## +# Ruijie +# +# Module contains an implementation of SONiC Platform Base API and +# provides the PSUs' information which are available in the platform +# +######################################################################## + + +try: + import time + from sonic_platform_base.psu_base import PsuBase + from sonic_platform.fan import Fan + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Psu(PsuBase): + """Ruijie Platform-specific PSU class""" + + def __init__(self, interface_obj, index): + self.psu_dict = {} + self.psu_status_dict = {} + self.psu_power_dict = {} + self._fan_list = [] + self._thermal_list = [] + self.int_case = interface_obj + self.index = index + self.name = "PSU" + str(index) + + self.psu_dict_update_time = 0 + self.psu_status_dict_update_time = 0 + self.psu_power_dict_update_time = 0 + + self._fan_list.append(Fan(self.int_case, 1, psu_fan=True, psu_index=index)) + + def psu_dict_update(self): + local_time = time.time() + if not self.psu_dict or (local_time - self.psu_dict_update_time) >= 1: # update data every 1 seconds + self.psu_dict_update_time = local_time + self.psu_dict = self.int_case.get_psu_fru_info(self.name) + + def psu_status_dict_update(self): + local_time = time.time() + if not self.psu_status_dict or ( + local_time - self.psu_status_dict_update_time) >= 1: # update data every 1 seconds + self.psu_status_dict_update_time = local_time + self.psu_status_dict = self.int_case.get_psu_status(self.name) + + def psu_power_dict_update(self): + local_time = time.time() + if not self.psu_power_dict or ( + local_time - self.psu_power_dict_update_time) >= 1: # update data every 1 seconds + self.psu_power_dict_update_time = local_time + self.psu_power_dict = self.int_case.get_psu_power_status(self.name) + + def get_name(self): + """ + Retrieves the name of the device + + Returns: + string: The name of the device + """ + return "Psu{}".format(self.index) + + def get_presence(self): + """ + Retrieves the presence of the Power Supply Unit (PSU) + + Returns: + bool: True if PSU is present, False if not + """ + return self.int_case.get_psu_presence(self.name) + + def get_model(self): + """ + Retrieves the part number of the PSU + + Returns: + string: Part number of PSU + """ + self.psu_dict_update() + return self.psu_dict["DisplayName"] + + def get_serial(self): + """ + Retrieves the serial number of the PSU + + Returns: + string: Serial number of PSU + """ + self.psu_dict_update() + return self.psu_dict["SN"] + + def get_status(self): + """ + Retrieves the operational status of the PSU + + Returns: + bool: True if PSU is operating properly, False if not + """ + return self.int_case.get_psu_input_output_status(self.name) + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Voltage"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_current(self): + """ + Retrieves present electric current supplied by PSU + + Returns: + A float number, electric current in amperes, + e.g. 15.4 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Current"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_power(self): + """ + Retrieves current energy supplied by PSU + + Returns: + A float number, the power in watts, + e.g. 302.6 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Power"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_powergood_status(self): + """ + Retrieves the powergood status of PSU + + Returns: + A boolean, True if PSU has stablized its output voltages and + passed all its internal self-tests, False if not. + """ + return self.int_case.get_psu_input_output_status(self.name) + + def get_status_led(self): + """ + Gets the state of the PSU status LED + + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings. + """ + if self.int_case.get_psu_input_output_status(self.name): + return self.STATUS_LED_COLOR_GREEN + else: + return self.STATUS_LED_COLOR_RED + + def set_status_led(self, color): + """ + Sets the state of the PSU status LED + Args: + color: A string representing the color with which to set the + PSU status LED + Returns: + bool: True if status LED state is set successfully, False if + not + """ + # not supported + return False + + def get_temperature(self): + """ + Retrieves current temperature reading from PSU + + Returns: + A float number of current temperature in Celsius up to nearest thousandth + of one degree Celsius, e.g. 30.125 + """ + self.psu_status_dict_update() + value = self.psu_status_dict["Temperature"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_temperature_high_threshold(self): + """ + Retrieves the high threshold temperature of PSU + + Returns: + A float number, the high threshold temperature of PSU in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + self.psu_status_dict_update() + value = self.psu_status_dict["Temperature"]["Max"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Voltage"]["HighAlarm"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + self.psu_power_dict_update() + value = self.psu_power_dict["Outputs"]["Voltage"]["LowAlarm"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_input_voltage(self): + """ + Get the input voltage of the PSU + + Returns: + A float number, the input voltage in volts, + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Inputs"]["Voltage"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_input_current(self): + """ + Get the input electric current of the PSU + + Returns: + A float number, the input current in amperes, e.g 220.3 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Inputs"]["Current"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_input_power(self): + """ + Get the input current energy of the PSU + + Returns: + A float number, the input power in watts, e.g. 302.6 + """ + self.psu_status_dict_update() + if self.psu_status_dict["InputStatus"] is False: + value = 0 + else: + self.psu_power_dict_update() + value = self.psu_power_dict["Inputs"]["Power"]["Value"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + self.psu_dict_update() + return self.psu_dict["HW"] + + def get_vendor(self): + """ + Retrieves the vendor name of the psu + + Returns: + string: Vendor name of psu + """ + self.psu_dict_update() + return self.psu_dict["VENDOR"] + + def get_maximum_supplied_power(self): + """ + Retrieves the maximum supplied power by PSU + + Returns: + A float number, the maximum power output in Watts. + e.g. 1200.1 + """ + return False + + def get_thermal(self, index): + """ + Retrieves thermal unit represented by (0-based) index + + Args: + index: An integer, the index (0-based) of the thermal to + retrieve + + Returns: + An object dervied from ThermalBase representing the specified thermal + """ + return False diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/sfp.py new file mode 100755 index 000000000000..60115886ee8e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/sfp.py @@ -0,0 +1,301 @@ +#!/usr/bin/python3 +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# +import time +import syslog +import traceback + +try: + from platform_intf import platform_get_optoe_type, platform_set_optoe_type + from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase + +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +LOG_DEBUG_LEVEL = 1 +LOG_WARNING_LEVEL = 2 +LOG_ERROR_LEVEL = 3 + +EEPROM_RETRY = 5 +EEPROM_RETRY_BREAK_SEC = 0.2 + +SYSFS_VAL_IS_PRESENT = 1 +SYSFS_VAL_IS_RESET = 1 +SYSFS_VAL_IS_LPMODE = 1 + +class Sfp(SfpOptoeBase): + + QSFP_DEVICE_TYPE = 1 + SFP_DEVICE_TYPE = 2 + CMIS_DEVICE_TYPE = 3 + + def __init__(self, index): + SfpOptoeBase.__init__(self) + self._port_id = index + 1 if self._get_config("port_index_start") == 0 else index + self._device_type = None + self.log_level = 1 + self.sfp_type = None + # self._set_log_level(self._get_config("sfp_log_level")) + + def get_eeprom_path(self): + return self._get_config("eeprom_path") % self._port_id + + def read_eeprom(self, offset, num_bytes): + eeprom_raw = None + try: + for i in range(EEPROM_RETRY): + eeprom_raw = SfpOptoeBase.read_eeprom(self, offset, num_bytes) + if eeprom_raw is None: + time.sleep(EEPROM_RETRY_BREAK_SEC) + continue + break + except Exception as e: + self._log_error(traceback.format_exc(e)) + return eeprom_raw + + def write_eeprom(self, offset, num_bytes, write_buffer): + try: + for i in range(EEPROM_RETRY): + ret = SfpOptoeBase.write_eeprom(self, offset, num_bytes, write_buffer) + if ret is False: + time.sleep(EEPROM_RETRY_BREAK_SEC) + continue + break + except Exception as e: + self._log_error(traceback.format_exc(e)) + ret = False + + return ret + + def get_presence(self): + try: + presence_sysfs_path = self._get_config("presence_path") % self._port_id + ret, result = self._read_sysfs(presence_sysfs_path) + if ret is False: + return False + return result == SYSFS_VAL_IS_PRESENT + except Exception as err: + self._log_error(traceback.format_exc(err)) + + return False + + def reset(self): + if self.get_presence() is False: + return False + + if self.sfp_type is None: + self.refresh_xcvr_api() + + if self.sfp_type == 'SFP': + self._log_warning('SFP does not support reset') + return False + + self._log_debug('port_num:%d resetting...' % self._port_id) + ret = self._set_reset(True) + if ret: + time.sleep(0.5) + ret = self._set_reset(False) + + return ret + + def get_lpmode(self): + if not self.get_presence(): + return False + + if self.sfp_type is None: + self.refresh_xcvr_api() + + if self.sfp_type == 'SFP': + self._log_warning('SFP does not support reset') + return False + + try: + lpmode_sysfs_path = self._get_config("lpmode_path") % self._port_id + ret, result = self._read_sysfs(lpmode_sysfs_path) + if ret is False: + return False + return result == SYSFS_VAL_IS_LPMODE + except Exception as err: + self._log_error(traceback.format_exc(err)) + + return False + + def set_lpmode(self, lpmode): + if not self.get_presence(): + return False + + if self.sfp_type is None or self._xcvr_api is None: + self.refresh_xcvr_api() + + if self.sfp_type == 'QSFP-DD': + return SfpOptoeBase.set_lpmode(self, lpmode) + elif self.sfp_type == 'QSFP': + if lpmode: + return self._xcvr_api.set_power_override(True, lpmode) + else: + return self._xcvr_api.set_power_override(False, lpmode) + else: + self._log_warning('SFP does not support reset') + return False + + def set_optoe_write_max(self, write_max): + """ + This func is declared and implemented by SONiC but we're not supported + so override it as NotImplemented + """ + self._log_debug("set_optoe_write_max NotImplemented") + return + + def refresh_xcvr_api(self): + """ + Updates the XcvrApi associated with this SFP + """ + self._xcvr_api = self._xcvr_api_factory.create_xcvr_api() + + class_name = self._xcvr_api.__class__.__name__ + self._set_optoe_driver(class_name) + +#################### inner api #################### + + def _get_device_type(self, class_name): + if (class_name == 'CmisApi'): + self._device_type = self.CMIS_DEVICE_TYPE + self.sfp_type = 'QSFP-DD' + elif (class_name == 'Sff8472Api'): + self._device_type = self.SFP_DEVICE_TYPE + self.sfp_type = 'SFP' + elif (class_name == 'Sff8636Api'): + self._device_type = self.QSFP_DEVICE_TYPE + self.sfp_type = 'QSFP' + else: + self._log_error("get_device_type error, class_name not supported:%s" % class_name) + self._device_type = None + self.sfp_type = None + + def _set_reset(self, reset): + try: + reset_sysfs_path = self._get_config("reset_path") % self._port_id + ret, result = self._read_sysfs(reset_sysfs_path) + if ret is False: + return False + if reset: + result = SYSFS_VAL_IS_RESET + else: + result = 0 + + ret = self._write_sysfs(reset_sysfs_path, result) + if ret is False: + return False + except Exception as err: + self._log_error(traceback.format_exc()) + return False + return True + + def _read_sysfs(self, sysfs_path): + val = 0 + if sysfs_path is None: + self._log_error("sysfs_path is None") + return False, 0 + + try: + with open(sysfs_path, "rb") as data: + sysfs_data = data.read(2) + if sysfs_data != "": + val = int(sysfs_data, 16) + except Exception as err: + self._log_error(traceback.format_exc(err)) + return False, 0 + + return True, val + + def _write_sysfs(self, sysfs_path, val): + if sysfs_path is None: + self._log_error("sysfs_path is None") + return False + + try: + with open(sysfs_path, "r+") as data: + data.seek(0) + sres = hex(val)[2:] + data.write(sres) + except Exception as err: + self._log_error(traceback.format_exc(err)) + return False + + self._log_debug("write sysfs_path:%s success, val:%d" % (sysfs_path, val)) + return True + + def _set_optoe_driver(self, class_name): + self._get_device_type(class_name) + if self._device_type is None: + return + try: + ret, output = platform_get_optoe_type(self._port_id) + if ret is False: + self._log_error("port %s get optoe type fail, output:%s" % (self._port_id, output)) + if int(output) != self._device_type: + ret, output = platform_set_optoe_type(self._port_id, self._device_type) + if ret is False: + self._log_error("port %s set optoe type fail, output:%s" % (self._port_id, output)) + self._log_debug("port_num:%d optoe_type:%s set success" % (self._port_id, self._device_type)) + except Exception as err: + print("Set optoe err %s" % err) + return + + def _get_config(self, key=None, default_val=None): + config = { + "port_index_start": 1, + "sfp_log_level": 1, + "presence_path": "/sys/s3ip/transceiver/eth%d/present", + "eeprom_path": "/sys/s3ip/transceiver/eth%d/eeprom", + "lpmode_path": "/sys/s3ip/transceiver/eth%d/low_power_mode", + "reset_path": "/sys/s3ip/transceiver/eth%d/reset", + } + return config.get(key, default_val) + + ####### SfpLog class ##### + + def _set_log_level(self, level): + if (level == LOG_DEBUG_LEVEL + or level == LOG_ERROR_LEVEL): + self.log_level = level + else: + self.log_error("unavailable loglevel:%d" % level) + + def _log_debug(self, msg): + if self.log_level <= LOG_DEBUG_LEVEL: + try: + syslog.openlog("Sfp") + syslog.syslog(syslog.LOG_DEBUG, msg) + syslog.closelog() + + except Exception as e: + msg = traceback.format_exc(e) + print("Exception_info:\n%s" % msg) + + def _log_warning(self, msg): + if self.log_level <= LOG_WARNING_LEVEL: + try: + syslog.openlog("Sfp") + syslog.syslog(syslog.LOG_WARNING, msg) + syslog.closelog() + + except Exception as e: + msg = traceback.format_exc(e) + print("Exception_info:\n%s" % msg) + + def _log_error(self, msg): + if self.log_level <= LOG_ERROR_LEVEL: + try: + syslog.openlog("Sfp") + syslog.syslog(syslog.LOG_ERR, msg) + syslog.closelog() + + except Exception as e: + msg = traceback.format_exc(e) + print("Exception_info:\n%s" % msg) + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/thermal.py new file mode 100755 index 000000000000..a02f0bc06dab --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/thermal.py @@ -0,0 +1,237 @@ +#!/usr/bin/env python3 + +######################################################################## +# Ruijie +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Thermals' information which are available in the platform +# +######################################################################## + + +try: + import time + from sonic_platform_base.thermal_base import ThermalBase + from sonic_platform.logger import logger +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Thermal(ThermalBase): + + def __init__(self, interface_obj, index): + self.temp_dict = {} + self.temperature_list = [] + self.int_case = interface_obj + self.index = index + self.update_time = 0 + self.temp_id = "TEMP" + str(index) + + def temp_dict_update(self): + local_time = time.time() + if not self.temp_dict or (local_time - self.update_time) >= 1: # update data every 1 seconds + self.update_time = local_time + self.temp_dict = self.int_case.get_monitor_temp_by_id(self.temp_id) + + def get_name(self): + """ + Retrieves the name of the thermal + + Returns: + string: The name of the thermal + """ + self.temp_dict_update() + return self.temp_dict["Api_name"] + + def get_presence(self): + """ + Retrieves the presence of the thermal + + Returns: + bool: True if thermal is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the Thermal + + Returns: + string: Model/part number of Thermal + """ + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the Thermal + + Returns: + string: Serial number of Thermal + """ + return "N/A" + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return "N/A" + + def get_status(self): + """ + Retrieves the operational status of the thermal + + Returns: + A boolean value, True if thermal is operating properly, + False if not + """ + self.temp_dict_update() + if (self.temp_dict["Value"] >= self.temp_dict["High"]) or (self.temp_dict["Value"] <= self.temp_dict["Low"]): + return False + + return True + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position + for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + def get_temperature(self): + """ + Retrieves current temperature reading from thermal + + Returns: + A float number of current temperature in Celsius up to nearest thousandth + of one degree Celsius, e.g. 30.125 + """ + self.temp_dict_update() + value = self.temp_dict["Value"] + if value is None: + value = 0 + if (len(self.temperature_list) >= 1000): + del self.temperature_list[0] + self.temperature_list.append(float(value)) + return round(float(value), 1) + + def get_high_threshold(self): + """ + Retrieves the high threshold temperature of thermal + + Returns: + A float number, the high threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + self.temp_dict_update() + value = self.temp_dict["High"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_low_threshold(self): + """ + Retrieves the low threshold temperature of thermal + + Returns: + A float number, the low threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + self.temp_dict_update() + value = self.temp_dict["Low"] + if value is None: + value = 0 + return round(float(value), 1) + + def set_high_threshold(self, temperature): + """ + Sets the high threshold temperature of thermal + + Args : + temperature: A float number up to nearest thousandth of one degree Celsius, + e.g. 30.125 + + Returns: + A boolean, True if threshold is set successfully, False if not + """ + # not supported + return False + + def set_low_threshold(self, temperature): + """ + Sets the low threshold temperature of thermal + + Args : + temperature: A float number up to nearest thousandth of one degree Celsius, + e.g. 30.125 + + Returns: + A boolean, True if threshold is set successfully, False if not + """ + # not supported + return False + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature of thermal + + Returns: + A float number, the high critical threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + self.temp_dict_update() + value = self.temp_dict["Max"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_low_critical_threshold(self): + """ + Retrieves the low critical threshold temperature of thermal + + Returns: + A float number, the low critical threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + self.temp_dict_update() + value = self.temp_dict["Min"] + if value is None: + value = 0 + return round(float(value), 1) + + def get_minimum_recorded(self): + """ + Retrieves the minimum recorded temperature of thermal + + Returns: + A float number, the minimum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if len(self.temperature_list) == 0: + self.get_temperature() + return round(float(min(self.temperature_list)), 1) + + def get_maximum_recorded(self): + """ + Retrieves the maximum recorded temperature of thermal + + Returns: + A float number, the maximum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if len(self.temperature_list) == 0: + self.get_temperature() + return round(float(max(self.temperature_list)), 1) + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/watchdog.py new file mode 100755 index 000000000000..59440492f730 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common/sonic_platform/watchdog.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 + +######################################################################## +# +# Ruijie +# +# Abstract base class for implementing a platform-specific class with +# which to interact with a hardware watchdog module in SONiC +# +######################################################################## + +try: + from sonic_platform_base.watchdog_base import WatchdogBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Watchdog(WatchdogBase): + """ + Abstract base class for interfacing with a hardware watchdog module + """ + + def __init__(self): + print("INFO: Watchdog __init__") + + def arm(self, seconds): + """ + Arm the hardware watchdog with a timeout of seconds. + If the watchdog is currently armed, calling this function will + simply reset the timer to the provided value. If the underlying + hardware does not support the value provided in , this + method should arm the watchdog with the *next greater* available + value. + + Returns: + An integer specifying the *actual* number of seconds the watchdog + was armed with. On failure returns -1. + """ + print("ERROR: Platform did not implement arm()") + raise NotImplementedError + + def disarm(self): + """ + Disarm the hardware watchdog + + Returns: + A boolean, True if watchdog is disarmed successfully, False if not + """ + print("ERROR: Platform did not implement disarm()") + raise NotImplementedError + + def is_armed(self): + """ + Retrieves the armed state of the hardware watchdog. + + Returns: + A boolean, True if watchdog is armed, False if not + """ + print("ERROR: Platform did not implement is_armed()") + raise NotImplementedError + + def get_remaining_time(self): + """ + If the watchdog is armed, retrieve the number of seconds remaining on + the watchdog timer + + Returns: + An integer specifying the number of seconds remaining on thei + watchdog timer. If the watchdog is not armed, returns -1. + """ + print("ERROR: Platform did not implement get_remaining_time()") + raise NotImplementedError diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/Makefile new file mode 100755 index 000000000000..2f3a7ccaddd8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/Makefile @@ -0,0 +1,39 @@ +PWD = $(shell pwd) +CC ?=gcc +INSTALL_MOD_DIR ?=extra +KVERSION ?= $(shell uname -r) +KERNEL_SRC ?= /lib/modules/$(KVERSION) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUB_BUILD_DIR = $(PWD)/build +SERVICE_DIR = $(PWD)/service +SYSFS_DIR = $(PWD)/S3IP_sysfs +SYSFS_BUILD_DIR = $(SYSFS_DIR)/build +INSTALL_MODULE_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3/dist-packages +INSTALL_SERVICE_DIR = $(SUB_BUILD_DIR)/lib/systemd/system +INSTALL_CFG_DIR = $(SUB_BUILD_DIR)/etc/dfd_cfg +COMMON_TX_OUTPUT := $(shell pwd)/build +export SUB_BUILD_DIR COMMON_TX_OUTPUT + +all : SUBDIRS_OBJ CHECK +CHECK : + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/lib/ ]; then cp -r $(PWD)/lib/* ${INSTALL_LIB_DIR} ;fi + @if [ ! -d ${COMMON_TX_OUTPUT} ]; then mkdir -p ${COMMON_TX_OUTPUT} ;fi + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + @if [ -d $(PWD)/script/ ]; then cp -r $(PWD)/script/* ${INSTALL_SCRIPT_DIR} ;fi + @if [ -d $(INSTALL_SCRIPT_DIR) ]; then chmod +x $(INSTALL_SCRIPT_DIR)/* ;fi + @if [ ! -d ${INSTALL_SERVICE_DIR} ]; then mkdir -p ${INSTALL_SERVICE_DIR} ;fi + cp -r $(SERVICE_DIR)/* $(INSTALL_SERVICE_DIR) + @if [ ! -d ${INSTALL_MODULE_DIR} ]; then mkdir -p ${INSTALL_MODULE_DIR} ;fi + cp -r $(SYSFS_BUILD_DIR)/S3IP_sysfs/*.ko $(INSTALL_MODULE_DIR) + @if [ ! -d ${INSTALL_CFG_DIR} ]; then mkdir -p ${INSTALL_CFG_DIR} ;fi + cp -r $(SYSFS_BUILD_DIR)/dfd_cfg/* $(INSTALL_CFG_DIR) + +SUBDIRS_OBJ : + make -C $(SYSFS_DIR) + +clean: + rm -rf $(SUB_BUILD_DIR) \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/Makefile new file mode 100755 index 000000000000..b509ad28c715 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/Makefile @@ -0,0 +1,19 @@ +PWD = $(shell pwd) +SYSFS_OUT_PUT := $(PWD)/build +sysfs_out_put_dir := $(SYSFS_OUT_PUT)/S3IP_sysfs/ +sysfs_cfg_dir := $(SYSFS_OUT_PUT)/dfd_cfg/ +export sysfs_out_put_dir sysfs_cfg_dir + +SYSFS_DRIVER_DIR = $(PWD)/sysfs_driver +SWITCH_DRIVER_DIR = $(PWD)/switch_driver +DEVICE_DRIVER_DIR = $(PWD)/device_driver + +export SYSFS_DRIVER_DIR SWITCH_DRIVER_DIR + +all : + $(MAKE) -C $(SYSFS_DRIVER_DIR) + $(MAKE) -C $(SWITCH_DRIVER_DIR) + $(MAKE) -C $(DEVICE_DRIVER_DIR) + +clean : + -rm -rf $(SYSFS_OUT_PUT) diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/Makefile new file mode 100755 index 000000000000..a17be3f17dd7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/Makefile @@ -0,0 +1,34 @@ +PWD = $(shell pwd) + +MAKEFILE_FILE_PATH = $(abspath $(lastword $(MAKEFILE_LIST))) +DEV_SYSFS_HEADER_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../sysfs_driver/include) +SWITCH_DVR_HEADER_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../switch_driver/include) +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -I$(DEV_SYSFS_HEADER_DIR) +EXTRA_CFLAGS+= -I$(SWITCH_DVR_HEADER_DIR) +EXTRA_CFLAGS+= -Wall + +KBUILD_EXTRA_SYMBOLS += $(SYSFS_DRIVER_DIR)/Module.symvers +KBUILD_EXTRA_SYMBOLS += $(SWITCH_DRIVER_DIR)/Module.symvers + +obj-m := syseeprom_device_driver.o +obj-m += fan_device_driver.o +obj-m += cpld_device_driver.o +obj-m += sysled_device_driver.o +obj-m += slot_device_driver.o +obj-m += psu_device_driver.o +obj-m += transceiver_device_driver.o +obj-m += temp_sensor_device_driver.o +obj-m += vol_sensor_device_driver.o +obj-m += curr_sensor_device_driver.o +obj-m += fpga_device_driver.o +obj-m += watchdog_device_driver.o + +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(sysfs_out_put_dir) ]; then mkdir -p $(sysfs_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(sysfs_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/cpld_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/cpld_device_driver.c new file mode 100644 index 000000000000..b8fee8e2748d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/cpld_device_driver.c @@ -0,0 +1,207 @@ +/* + * cpld_device_driver.c + * + * This module realize /sys/s3ip/cpld attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "cpld_sysfs.h" +#include "dfd_sysfs_common.h" + +#define CPLD_INFO(fmt, args...) LOG_INFO("cpld: ", fmt, ##args) +#define CPLD_ERR(fmt, args...) LOG_ERR("cpld: ", fmt, ##args) +#define CPLD_DBG(fmt, args...) LOG_DBG("cpld: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/******************************************CPLD***********************************************/ +static int rg_get_main_board_cpld_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_number); + + ret = g_drv->get_main_board_cpld_number(); + return ret; +} + +/* + * rg_get_main_board_cpld_alias - Used to identify the location of cpld, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_alias(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_alias); + + ret = g_drv->get_main_board_cpld_alias(cpld_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_cpld_type - Used to get cpld model name + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_type(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_type); + + ret = g_drv->get_main_board_cpld_type(cpld_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_cpld_firmware_version - Used to get cpld firmware version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_firmware_version(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_firmware_version); + + ret = g_drv->get_main_board_cpld_firmware_version(cpld_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_cpld_board_version - Used to get cpld board version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_board_version(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_board_version); + + ret = g_drv->get_main_board_cpld_board_version(cpld_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_cpld_test_reg - Used to test cpld register read + * filled the value to buf, value is hexadecimal, start with 0x + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_cpld_test_reg(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_cpld_test_reg); + + ret = g_drv->get_main_board_cpld_test_reg(cpld_index, buf, count); + return ret; +} + +/* + * rg_set_main_board_cpld_test_reg - Used to test cpld register write + * @cpld_index: start with 1 + * @value: value write to cpld + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_main_board_cpld_test_reg(unsigned int cpld_index, unsigned int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_main_board_cpld_test_reg); + + ret = g_drv->set_main_board_cpld_test_reg(cpld_index, value); + return ret; +} +/***************************************end of CPLD*******************************************/ + +static struct s3ip_sysfs_cpld_drivers_s drivers = { + /* + * set ODM CPLD drivers to /sys/s3ip/cpld, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_cpld_number = rg_get_main_board_cpld_number, + .get_main_board_cpld_alias = rg_get_main_board_cpld_alias, + .get_main_board_cpld_type = rg_get_main_board_cpld_type, + .get_main_board_cpld_firmware_version = rg_get_main_board_cpld_firmware_version, + .get_main_board_cpld_board_version = rg_get_main_board_cpld_board_version, + .get_main_board_cpld_test_reg = rg_get_main_board_cpld_test_reg, + .set_main_board_cpld_test_reg = rg_set_main_board_cpld_test_reg, +}; + +static int __init cpld_device_driver_init(void) +{ + int ret; + + CPLD_INFO("cpld_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_cpld_drivers_register(&drivers); + if (ret < 0) { + CPLD_ERR("cpld drivers register err, ret %d.\n", ret); + return ret; + } + + CPLD_INFO("cpld_init success.\n"); + return 0; +} + +static void __exit cpld_device_driver_exit(void) +{ + s3ip_sysfs_cpld_drivers_unregister(); + CPLD_INFO("cpld_exit success.\n"); + return; +} + +module_init(cpld_device_driver_init); +module_exit(cpld_device_driver_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("cpld device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/curr_sensor_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/curr_sensor_device_driver.c new file mode 100644 index 000000000000..99021e633664 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/curr_sensor_device_driver.c @@ -0,0 +1,188 @@ +/* + * curr_sensor_device_driver.c + * + * This module realize /sys/s3ip/curr_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "curr_sensor_sysfs.h" +#include "dfd_sysfs_common.h" + +#define CURR_SENSOR_INFO(fmt, args...) LOG_INFO("curr_sensor: ", fmt, ##args) +#define CURR_SENSOR_ERR(fmt, args...) LOG_ERR("curr_sensor: ", fmt, ##args) +#define CURR_SENSOR_DBG(fmt, args...) LOG_DBG("curr_sensor: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/*************************************main board current***************************************/ +static int rg_get_main_board_curr_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_number); + + ret = g_drv->get_main_board_curr_number(); + return ret; +} + +/* + * rg_get_main_board_curr_alias - Used to identify the location of the current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_alias(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_alias); + + ret = g_drv->get_main_board_curr_alias(curr_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_curr_type - Used to get the model of current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_type(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_type); + + ret = g_drv->get_main_board_curr_type(curr_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_curr_max - Used to get the maximum threshold of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_max(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_max); + + ret = g_drv->get_main_board_curr_max(curr_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_curr_min - Used to get the minimum threshold of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_min(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_min); + + ret = g_drv->get_main_board_curr_min(curr_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_curr_value - Used to get the input value of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_curr_value(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_curr_value); + + ret = g_drv->get_main_board_curr_value(curr_index, buf, count); + return ret; +} +/*********************************end of main board current************************************/ + +static struct s3ip_sysfs_curr_sensor_drivers_s drivers = { + /* + * set ODM current sensor drivers to /sys/s3ip/curr_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_curr_number = rg_get_main_board_curr_number, + .get_main_board_curr_alias = rg_get_main_board_curr_alias, + .get_main_board_curr_type = rg_get_main_board_curr_type, + .get_main_board_curr_max = rg_get_main_board_curr_max, + .get_main_board_curr_min = rg_get_main_board_curr_min, + .get_main_board_curr_value = rg_get_main_board_curr_value, +}; + +static int __init curr_sensor_dev_drv_init(void) +{ + int ret; + + CURR_SENSOR_INFO("curr_sensor_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_curr_sensor_drivers_register(&drivers); + if (ret < 0) { + CURR_SENSOR_ERR("curr sensor drivers register err, ret %d.\n", ret); + return ret; + } + + CURR_SENSOR_INFO("curr_sensor_init success.\n"); + return 0; +} + +static void __exit curr_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_curr_sensor_drivers_unregister(); + CURR_SENSOR_INFO("curr_sensor_exit success.\n"); + return; +} + +module_init(curr_sensor_dev_drv_init); +module_exit(curr_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("current sensors device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fan_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fan_device_driver.c new file mode 100644 index 000000000000..f4d30b5fb563 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fan_device_driver.c @@ -0,0 +1,459 @@ +/* + * fan_device_driver.c + * + * This module realize /sys/s3ip/fan attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "fan_sysfs.h" +#include "dfd_sysfs_common.h" + +#define FAN_INFO(fmt, args...) LOG_INFO("fan: ", fmt, ##args) +#define FAN_ERR(fmt, args...) LOG_ERR("fan: ", fmt, ##args) +#define FAN_DBG(fmt, args...) LOG_DBG("fan: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/********************************************fan**********************************************/ +static int rg_get_fan_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_fan_number); + + ret = g_drv->get_fan_number(); + return ret; +} + +static int rg_get_fan_motor_number(unsigned int fan_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_number); + + ret = g_drv->get_fan_motor_number(fan_index); + return ret; +} + +/* + * rg_get_fan_model_name - Used to get fan model name, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_model_name(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_model_name); + + ret = g_drv->get_fan_model_name(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_serial_number - Used to get fan serial number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_serial_number(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_serial_number); + + ret = g_drv->get_fan_serial_number(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_part_number - Used to get fan part number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_part_number(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_part_number); + + ret = g_drv->get_fan_part_number(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_hardware_version - Used to get fan hardware version, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_hardware_version(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_hardware_version); + + ret = g_drv->get_fan_hardware_version(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_status - Used to get fan status, + * filled the value to buf, fan status define as below: + * 0: ABSENT + * 1: OK + * 2: NOT OK + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_status(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_status); + + ret = g_drv->get_fan_status(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_led_status - Used to get fan led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_led_status(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_led_status); + + ret = g_drv->get_fan_led_status(fan_index, buf, count); + return ret; +} + +/* + * rg_set_fan_led_status - Used to set fan led status + * @fan_index: start with 1 + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_fan_led_status(unsigned int fan_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_fan_led_status); + + ret = g_drv->set_fan_led_status(fan_index, status); + return ret; +} + +/* + * rg_get_fan_direction - Used to get fan air flow direction, + * filled the value to buf, air flow direction define as below: + * 0: F2B + * 1: B2F + * + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_direction(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_direction); + + ret = g_drv->get_fan_direction(fan_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed - Used to get fan motor speed + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed); + + ret = g_drv->get_fan_motor_speed(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed_tolerance - Used to get fan motor speed tolerance + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed_tolerance(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed_tolerance); + + ret = g_drv->get_fan_motor_speed_tolerance(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed_target - Used to get fan motor speed target + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed_target(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed_target); + + ret = g_drv->get_fan_motor_speed_target(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed_max - Used to get the maximum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed_max(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed_max); + + ret = g_drv->get_fan_motor_speed_max(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_motor_speed_min - Used to get the minimum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_motor_speed_min(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_motor_speed_min); + + ret = g_drv->get_fan_motor_speed_min(fan_index, motor_index, buf, count); + return ret; +} + +/* + * rg_get_fan_ratio - Used to get the ratio of fan + * filled the value to buf + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_fan_ratio(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_fan_ratio); + + ret = g_drv->get_fan_ratio(fan_index, buf, count); + return ret; +} + +/* + * rg_set_fan_ratio - Used to set the ratio of fan + * @fan_index: start with 1 + * @ratio: motor speed ratio, from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_fan_ratio(unsigned int fan_index, int ratio) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_fan_ratio); + + ret = g_drv->set_fan_ratio(fan_index, ratio); + return ret; +} +/****************************************end of fan*******************************************/ + +static struct s3ip_sysfs_fan_drivers_s drivers = { + /* + * set ODM fan drivers to /sys/s3ip/fan, + * if not support the function, set corresponding hook to NULL. + */ + .get_fan_number = rg_get_fan_number, + .get_fan_motor_number = rg_get_fan_motor_number, + .get_fan_model_name = rg_get_fan_model_name, + .get_fan_serial_number = rg_get_fan_serial_number, + .get_fan_part_number = rg_get_fan_part_number, + .get_fan_hardware_version = rg_get_fan_hardware_version, + .get_fan_status = rg_get_fan_status, + .get_fan_led_status = rg_get_fan_led_status, + .set_fan_led_status = rg_set_fan_led_status, + .get_fan_direction = rg_get_fan_direction, + .get_fan_motor_speed = rg_get_fan_motor_speed, + .get_fan_motor_speed_tolerance = rg_get_fan_motor_speed_tolerance, + .get_fan_motor_speed_target = rg_get_fan_motor_speed_target, + .get_fan_motor_speed_max = rg_get_fan_motor_speed_max, + .get_fan_motor_speed_min = rg_get_fan_motor_speed_min, + .get_fan_ratio = rg_get_fan_ratio, + .set_fan_ratio = rg_set_fan_ratio +}; + +static int __init fan_dev_drv_init(void) +{ + int ret; + + FAN_INFO("fan_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_fan_drivers_register(&drivers); + if (ret < 0) { + FAN_ERR("fan drivers register err, ret %d.\n", ret); + return ret; + } + + FAN_INFO("fan_init success.\n"); + return 0; +} + +static void __exit fan_dev_drv_exit(void) +{ + s3ip_sysfs_fan_drivers_unregister(); + FAN_INFO("fan_exit success.\n"); + return; +} + +module_init(fan_dev_drv_init); +module_exit(fan_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("fan device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fpga_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fpga_device_driver.c new file mode 100644 index 000000000000..b9b75a9a671b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/fpga_device_driver.c @@ -0,0 +1,206 @@ +/* + * fpga_device_driver.c + * + * This module realize /sys/s3ip/fpga attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "fpga_sysfs.h" +#include "dfd_sysfs_common.h" + +#define FPGA_INFO(fmt, args...) LOG_INFO("fpga: ", fmt, ##args) +#define FPGA_ERR(fmt, args...) LOG_ERR("fpga: ", fmt, ##args) +#define FPGA_DBG(fmt, args...) LOG_DBG("fpga: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/******************************************FPGA***********************************************/ +static int rg_get_main_board_fpga_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_number); + + ret = g_drv->get_main_board_fpga_number(); + return ret; +} + +/* + * rg_get_main_board_fpga_alias - Used to identify the location of fpga, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_alias(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_alias); + + ret = g_drv->get_main_board_fpga_alias(fpga_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_fpga_type - Used to get fpga model name + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_type(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_type); + + ret = g_drv->get_main_board_fpga_type(fpga_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_fpga_firmware_version - Used to get fpga firmware version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_firmware_version(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_firmware_version); + + ret = g_drv->get_main_board_fpga_firmware_version(fpga_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_fpga_board_version - Used to get fpga board version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_board_version(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_board_version); + + ret = g_drv->get_main_board_fpga_board_version(fpga_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_fpga_test_reg - Used to test fpga register read + * filled the value to buf, value is hexadecimal, start with 0x + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_fpga_test_reg(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_fpga_test_reg); + + ret = g_drv->get_main_board_fpga_test_reg(fpga_index, buf, count); + return ret; +} + +/* + * rg_set_main_board_fpga_test_reg - Used to test fpga register write + * @fpga_index: start with 1 + * @value: value write to fpga + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_main_board_fpga_test_reg(unsigned int fpga_index, unsigned int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_main_board_fpga_test_reg); + + ret = g_drv->set_main_board_fpga_test_reg(fpga_index, value); + return ret; +} +/***************************************end of FPGA*******************************************/ + +static struct s3ip_sysfs_fpga_drivers_s drivers = { + /* + * set ODM FPGA drivers to /sys/s3ip/fpga, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_fpga_number = rg_get_main_board_fpga_number, + .get_main_board_fpga_alias = rg_get_main_board_fpga_alias, + .get_main_board_fpga_type = rg_get_main_board_fpga_type, + .get_main_board_fpga_firmware_version = rg_get_main_board_fpga_firmware_version, + .get_main_board_fpga_board_version = rg_get_main_board_fpga_board_version, + .get_main_board_fpga_test_reg = rg_get_main_board_fpga_test_reg, + .set_main_board_fpga_test_reg = rg_set_main_board_fpga_test_reg, +}; + +static int __init fpga_dev_drv_init(void) +{ + int ret; + + FPGA_INFO("fpga_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_fpga_drivers_register(&drivers); + if (ret < 0) { + FPGA_ERR("fpga drivers register err, ret %d.\n", ret); + return ret; + } + FPGA_INFO("fpga_init success.\n"); + return 0; +} + +static void __exit fpga_dev_drv_exit(void) +{ + s3ip_sysfs_fpga_drivers_unregister(); + FPGA_INFO("fpga_exit success.\n"); + return; +} + +module_init(fpga_dev_drv_init); +module_exit(fpga_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("fpga device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/include/device_driver_common.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/include/device_driver_common.h new file mode 100644 index 000000000000..6386d88fafe9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/include/device_driver_common.h @@ -0,0 +1,49 @@ +#ifndef _DEVICE_DRIVER_COMMON_H_ +#define _DEVICE_DRIVER_COMMON_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +enum LOG_LEVEL{ + INFO = 0x1, + ERR = 0x2, + DBG = 0x4, + ALL = 0xf +}; + +#define LOG_INFO(_prefix, fmt, args...) do { \ + if (g_loglevel & INFO) { \ + printk( KERN_INFO _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define LOG_ERR(_prefix, fmt, args...) do { \ + if (g_loglevel & ERR) { \ + printk( KERN_ERR _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define LOG_DBG(_prefix, fmt, args...) do { \ + if (g_loglevel & DBG) { \ + printk( KERN_DEBUG _prefix "%s "fmt, __FUNCTION__, ##args); \ + } \ +} while (0) + +#define check_pfun(p) do { \ + if (p == NULL) { \ + if (g_loglevel & ERR) { \ + printk( KERN_ERR "%s, %s is NULL.\n", __FUNCTION__, #p); \ + } \ + return -ENOSYS; \ + } \ +} while(0) + +#define check_p(p) check_pfun(p) + +#endif /* _DEVICE_DRIVER_COMMON_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/psu_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/psu_device_driver.c new file mode 100644 index 000000000000..1147ed3a2786 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/psu_device_driver.c @@ -0,0 +1,737 @@ +/* + * psu_device_driver.c + * + * This module realize /sys/s3ip/psu attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "psu_sysfs.h" +#include "dfd_sysfs_common.h" + +#define PSU_INFO(fmt, args...) LOG_INFO("psu: ", fmt, ##args) +#define PSU_ERR(fmt, args...) LOG_ERR("psu: ", fmt, ##args) +#define PSU_DBG(fmt, args...) LOG_DBG("psu: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/********************************************psu**********************************************/ +static int rg_get_psu_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_psu_number); + + ret = g_drv->get_psu_number(); + return ret; +} + +static int rg_get_psu_temp_number(unsigned int psu_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_number); + + ret = g_drv->get_psu_temp_number(psu_index); + return ret; +} + +/* + * rg_get_psu_model_name - Used to get psu model name, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_model_name(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_model_name); + + ret = g_drv->get_psu_model_name(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_serial_number - Used to get psu serial number, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_serial_number(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_serial_number); + + ret = g_drv->get_psu_serial_number(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_part_number - Used to get psu part number, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_part_number(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_part_number); + + ret = g_drv->get_psu_part_number(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_hardware_version - Used to get psu hardware version, + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_hardware_version(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_hardware_version); + + ret = g_drv->get_psu_hardware_version(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_type - Used to get the input type of psu + * filled the value to buf, input type value define as below: + * 0: DC + * 1: AC + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_type(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_type); + + ret = g_drv->get_psu_type(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_in_curr - Used to get the input current of psu + * filled the value to buf, the value is integer with mA + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_in_curr(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_in_curr); + + ret = g_drv->get_psu_in_curr(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_in_vol - Used to get the input voltage of psu + * filled the value to bu, the value is integer with mV + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_in_vol(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_in_vol); + + ret = g_drv->get_psu_in_vol(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_in_power - Used to get the input power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_in_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_in_power); + + ret = g_drv->get_psu_in_power(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_curr - Used to get the output current of psu + * filled the value to buf, the value is integer with mA + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_curr(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_curr); + + ret = g_drv->get_psu_out_curr(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_vol - Used to get the output voltage of psu + * filled the value to buf, the value is integer with mV + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_vol(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_vol); + + ret = g_drv->get_psu_out_vol(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_power - Used to get the output power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_power); + + ret = g_drv->get_psu_out_power(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_max_power - Used to get the output max power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_max_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_max_power); + + ret = g_drv->get_psu_out_max_power(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_present_status - Used to get psu present status + * filled the value to buf, psu present status define as below: + * 0: ABSENT + * 1: PRESENT + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_present_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_present_status); + + ret = g_drv->get_psu_present_status(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_in_status - Used to get psu input status + * filled the value to buf, psu input status define as below: + * 0: NOT OK + * 1: OK + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_in_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_in_status); + + ret = g_drv->get_psu_in_status(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_out_status - Used to get psu output status + * filled the value to buf, psu output status define as below: + * 0: NOT OK + * 1: OK + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_out_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_out_status); + + ret = g_drv->get_psu_out_status(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_fan_speed - Used to get psu fan speed + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_fan_speed(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_fan_speed); + + ret = g_drv->get_psu_fan_speed(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_fan_ratio - Used to get the ratio of psu fan + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_fan_ratio(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_fan_ratio); + + ret = g_drv->get_psu_fan_ratio(psu_index, buf, count); + return ret; +} + +/* + * rg_set_psu_fan_ratio - Used to set the ratio of psu fan + * @psu_index: start with 1 + * @ratio: from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_psu_fan_ratio(unsigned int psu_index, int ratio) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->set_psu_fan_ratio); + + ret = g_drv->set_psu_fan_ratio(psu_index, ratio); + return ret; +} + +/* + * rg_get_psu_fan_direction - Used to get psu air flow direction, + * filled the value to buf, air flow direction define as below: + * 0: F2B + * 1: B2F + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_fan_direction(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_fan_direction); + + ret = g_drv->get_psu_fan_direction(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_led_status - Used to get psu led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_led_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_led_status); + + ret = g_drv->get_psu_led_status(psu_index, buf, count); + return ret; +} + +/* + * rg_get_psu_temp_alias - Used to identify the location of the temperature sensor of psu, + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_alias(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_alias); + + ret = g_drv->get_psu_temp_alias(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_psu_temp_type - Used to get the model of temperature sensor of psu, + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_type(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_type); + + ret = g_drv->get_psu_temp_type(psu_index, temp_index, buf, count); + return ret; + +} + +/* + * rg_get_psu_temp_max - Used to get the maximum threshold of temperature sensor of psu, + * filled the value to buf, the value is integer with millidegree Celsius + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_max); + + ret = g_drv->get_psu_temp_max(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_set_psu_temp_max - Used to set the maximum threshold of temperature sensor of psu, + * get value from buf and set it to maximum threshold of psu temperature sensor + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '80.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->set_psu_temp_max); + + ret = g_drv->set_psu_temp_max(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_psu_temp_min - Used to get the minimum threshold of temperature sensor of psu, + * filled the value to buf, the value is integer with millidegree Celsius + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_min); + + ret = g_drv->get_psu_temp_min(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_set_psu_temp_min - Used to set the minimum threshold of temperature sensor of psu, + * get value from buf and set it to minimum threshold of psu temperature sensor + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: the buf store the data to be set, eg '50.000' + * @count: length of buf + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->set_psu_temp_min); + + ret = g_drv->set_psu_temp_min(psu_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_psu_temp_value - Used to get the input value of temperature sensor of psu + * filled the value to buf, the value is integer with millidegree Celsius + * @psu_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_psu_temp_value(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_psu_temp_value); + + ret = g_drv->get_psu_temp_value(psu_index, temp_index, buf, count); + return ret; +} +/****************************************end of psu*******************************************/ + +static struct s3ip_sysfs_psu_drivers_s drivers = { + /* + * set ODM psu drivers to /sys/s3ip/psu, + * if not support the function, set corresponding hook to NULL. + */ + .get_psu_number = rg_get_psu_number, + .get_psu_temp_number = rg_get_psu_temp_number, + .get_psu_model_name = rg_get_psu_model_name, + .get_psu_serial_number = rg_get_psu_serial_number, + .get_psu_part_number = rg_get_psu_part_number, + .get_psu_hardware_version = rg_get_psu_hardware_version, + .get_psu_type = rg_get_psu_type, + .get_psu_in_curr = rg_get_psu_in_curr, + .get_psu_in_vol = rg_get_psu_in_vol, + .get_psu_in_power = rg_get_psu_in_power, + .get_psu_out_curr = rg_get_psu_out_curr, + .get_psu_out_vol = rg_get_psu_out_vol, + .get_psu_out_power = rg_get_psu_out_power, + .get_psu_out_max_power = rg_get_psu_out_max_power, + .get_psu_present_status = rg_get_psu_present_status, + .get_psu_in_status = rg_get_psu_in_status, + .get_psu_out_status = rg_get_psu_out_status, + .get_psu_fan_speed = rg_get_psu_fan_speed, + .get_psu_fan_ratio = rg_get_psu_fan_ratio, + .set_psu_fan_ratio = rg_set_psu_fan_ratio, + .get_psu_fan_direction = rg_get_psu_fan_direction, + .get_psu_led_status = rg_get_psu_led_status, + .get_psu_temp_alias = rg_get_psu_temp_alias, + .get_psu_temp_type = rg_get_psu_temp_type, + .get_psu_temp_max = rg_get_psu_temp_max, + .set_psu_temp_max = rg_set_psu_temp_max, + .get_psu_temp_min = rg_get_psu_temp_min, + .set_psu_temp_min = rg_set_psu_temp_min, + .get_psu_temp_value = rg_get_psu_temp_value, +}; + +static int __init psu_dev_drv_init(void) +{ + int ret; + + PSU_INFO("psu_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_psu_drivers_register(&drivers); + if (ret < 0) { + PSU_ERR("psu drivers register err, ret %d.\n", ret); + return ret; + } + PSU_INFO("psu_init success.\n"); + return 0; +} + +static void __exit psu_dev_drv_exit(void) +{ + s3ip_sysfs_psu_drivers_unregister(); + PSU_INFO("psu_exit ok.\n"); + + return; +} + +module_init(psu_dev_drv_init); +module_exit(psu_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("psu device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/slot_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/slot_device_driver.c new file mode 100644 index 000000000000..f59515a20422 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/slot_device_driver.c @@ -0,0 +1,1016 @@ +/* + * slot_device_driver.c + * + * This module realize /sys/s3ip/slot attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "slot_sysfs.h" +#include "dfd_sysfs_common.h" + +#define SLOT_INFO(fmt, args...) LOG_INFO("slot: ", fmt, ##args) +#define SLOT_ERR(fmt, args...) LOG_ERR("slot: ", fmt, ##args) +#define SLOT_DBG(fmt, args...) LOG_DBG("slot: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/******************************************slot***********************************************/ +static int rg_get_slot_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_number); + + ret = g_drv->get_slot_number(); + return ret; +} + +static int rg_get_slot_temp_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_number); + + ret = g_drv->get_slot_temp_number(slot_index); + return ret; +} + +static int rg_get_slot_vol_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_number); + + ret = g_drv->get_slot_vol_number(slot_index); + return ret; +} + +static int rg_get_slot_curr_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_number); + + ret = g_drv->get_slot_curr_number(slot_index); + return ret; +} + +static int rg_get_slot_fpga_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_number); + + ret = g_drv->get_slot_fpga_number(slot_index); + return ret; +} + +static int rg_get_slot_cpld_number(unsigned int slot_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_number); + + ret = g_drv->get_slot_cpld_number(slot_index); + return ret; +} + +/* + * rg_get_slot_model_name - Used to get slot model name, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_model_name(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_model_name); + + ret = g_drv->get_slot_model_name(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_serial_number - Used to get slot serial number, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_serial_number(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_serial_number); + + ret = g_drv->get_slot_serial_number(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_part_number - Used to get slot part number, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_part_number(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_part_number); + + ret = g_drv->get_slot_part_number(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_hardware_version - Used to get slot hardware version, + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_hardware_version(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_hardware_version); + + ret = g_drv->get_slot_hardware_version(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_status - Used to get slot status, + * filled the value to buf, slot status define as below: + * 0: ABSENT + * 1: OK + * 2: NOT OK + * + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_status(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_status); + + ret = g_drv->get_slot_status(slot_index, buf, count); + return ret; +} + +/* + * rg_get_slot_led_status - Used to get slot led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * @slot_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_led_status(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_led_status); + + ret = g_drv->get_slot_led_status(slot_index, buf, count); + return ret; +} + +/* + * rg_set_slot_led_status - Used to set slot led status + * @slot_index: start with 1 + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_slot_led_status(unsigned int slot_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_slot_led_status); + + ret = g_drv->set_slot_led_status(slot_index, status); + return ret; +} + +/* + * rg_get_slot_temp_alias - Used to identify the location of the temperature sensor of slot, + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_alias(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_alias); + + ret = g_drv->get_slot_temp_alias(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_temp_type - Used to get the model of temperature sensor of slot, + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_type(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_type); + + ret = g_drv->get_slot_temp_type(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_temp_max - Used to get the maximum threshold of temperature sensor of slot, + * filled the value to buf, the value is integer with millidegree Celsius + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_max(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_max); + + ret = g_drv->get_slot_temp_max(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_temp_min - Used to get the minimum threshold of temperature sensor of slot, + * filled the value to buf, the value is integer with millidegree Celsius + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_min(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_min); + + ret = g_drv->get_slot_temp_min(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_temp_value - Used to get the input value of temperature sensor of slot, + * filled the value to buf, the value is integer with millidegree Celsius + * @slot_index: start with 1 + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_temp_value(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_temp_value); + + ret = g_drv->get_slot_temp_value(slot_index, temp_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_alias - Used to identify the location of the voltage sensor of slot, + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_alias(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_alias); + + ret = g_drv->get_slot_vol_alias(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_type - Used to get the model of voltage sensor of slot, + * such as udc90160, tps53622 and so on + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_type(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_type); + + ret = g_drv->get_slot_vol_type(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_max - Used to get the maximum threshold of voltage sensor of slot, + * filled the value to buf, the value is integer with mV + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_max(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_max); + + ret = g_drv->get_slot_vol_max(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_min - Used to get the minimum threshold of voltage sensor of slot, + * filled the value to buf, the value is integer with mV + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_min(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_min); + + ret = g_drv->get_slot_vol_min(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_range - Used to get the output error value of voltage sensor of slot, + * filled the value to buf + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_range(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_range); + + ret = g_drv->get_slot_vol_range(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_nominal_value - Used to get the nominal value of voltage sensor of slot, + * filled the value to buf + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_nominal_value(unsigned int slot_index, + unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_nominal_value); + + ret = g_drv->get_slot_vol_nominal_value(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_vol_value - Used to get the input value of voltage sensor of slot, + * filled the value to buf, the value is integer with mV + * @slot_index: start with 1 + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_vol_value(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_vol_value); + + ret = g_drv->get_slot_vol_value(slot_index, vol_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_alias - Used to identify the location of the current sensor of slot, + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_alias(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_alias); + + ret = g_drv->get_slot_curr_alias(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_type - Used to get the model of current sensor of slot, + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_type(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_type); + + ret = g_drv->get_slot_curr_type(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_max - Used to get the maximum threshold of current sensor of slot, + * filled the value to buf, the value is integer with mA + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_max(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_max); + + ret = g_drv->get_slot_curr_max(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_min - Used to get the minimum threshold of current sensor of slot, + * filled the value to buf, the value is integer with mA + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_min(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_min); + + ret = g_drv->get_slot_curr_min(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_curr_value - Used to get the input value of current sensor of slot, + * filled the value to buf, the value is integer with mA + * @slot_index: start with 1 + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_curr_value(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_curr_value); + + ret = g_drv->get_slot_curr_value(slot_index, curr_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_alias - Used to identify the location of slot fpga, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_alias(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_alias); + + ret = g_drv->get_slot_fpga_alias(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_type - Used to get slot fpga model name + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_type(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_type); + + ret = g_drv->get_slot_fpga_type(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_firmware_version - Used to get slot fpga firmware version, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_firmware_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_firmware_version); + + ret = g_drv->get_slot_fpga_firmware_version(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_board_version - Used to get slot fpga board version, + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_board_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_board_version); + + ret = g_drv->get_slot_fpga_board_version(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_get_slot_fpga_test_reg - Used to test slot fpga register read + * filled the value to buf, value is hexadecimal, start with 0x + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_fpga_test_reg); + + ret = g_drv->get_slot_fpga_test_reg(slot_index, fpga_index, buf, count); + return ret; +} + +/* + * rg_set_slot_fpga_test_reg - Used to test slot fpga register write + * @slot_index: start with 1 + * @fpga_index: start with 1 + * @value: value write to slot fpga + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + unsigned int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_slot_fpga_test_reg); + + ret = g_drv->set_slot_fpga_test_reg(slot_index, fpga_index, value); + return ret; +} + +/* + * rg_get_slot_cpld_alias - Used to identify the location of slot cpld, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_alias(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_alias); + + ret = g_drv->get_slot_cpld_alias(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_get_slot_cpld_type - Used to get slot cpld model name + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_type(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_type); + + ret = g_drv->get_slot_cpld_type(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_get_slot_cpld_firmware_version - Used to get slot cpld firmware version, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_firmware_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_firmware_version); + + ret = g_drv->get_slot_cpld_firmware_version(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_get_slot_cpld_board_version - Used to get slot cpld board version, + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_board_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_board_version); + + ret = g_drv->get_slot_cpld_board_version(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_get_slot_cpld_test_reg - Used to test slot cpld register read + * filled the value to buf, value is hexadecimal, start with 0x + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_slot_cpld_test_reg); + + ret = g_drv->get_slot_cpld_test_reg(slot_index, cpld_index, buf, count); + return ret; +} + +/* + * rg_set_slot_cpld_test_reg - Used to test slot cpld register write + * @slot_index: start with 1 + * @cpld_index: start with 1 + * @value: value write to slot cpld + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + unsigned int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_slot_cpld_test_reg); + + ret = g_drv->set_slot_cpld_test_reg(slot_index, cpld_index, value); + return ret; +} +/***************************************end of slot*******************************************/ + +static struct s3ip_sysfs_slot_drivers_s drivers = { + /* + * set ODM slot drivers to /sys/s3ip/slot, + * if not support the function, set corresponding hook to NULL. + */ + .get_slot_number = rg_get_slot_number, + .get_slot_temp_number = rg_get_slot_temp_number, + .get_slot_vol_number = rg_get_slot_vol_number, + .get_slot_curr_number = rg_get_slot_curr_number, + .get_slot_cpld_number = rg_get_slot_cpld_number, + .get_slot_fpga_number = rg_get_slot_fpga_number, + .get_slot_model_name = rg_get_slot_model_name, + .get_slot_serial_number = rg_get_slot_serial_number, + .get_slot_part_number = rg_get_slot_part_number, + .get_slot_hardware_version = rg_get_slot_hardware_version, + .get_slot_status = rg_get_slot_status, + .get_slot_led_status = rg_get_slot_led_status, + .set_slot_led_status = rg_set_slot_led_status, + .get_slot_temp_alias = rg_get_slot_temp_alias, + .get_slot_temp_type = rg_get_slot_temp_type, + .get_slot_temp_max = rg_get_slot_temp_max, + .get_slot_temp_min = rg_get_slot_temp_min, + .get_slot_temp_value = rg_get_slot_temp_value, + .get_slot_vol_alias = rg_get_slot_vol_alias, + .get_slot_vol_type = rg_get_slot_vol_type, + .get_slot_vol_max = rg_get_slot_vol_max, + .get_slot_vol_min = rg_get_slot_vol_min, + .get_slot_vol_range = rg_get_slot_vol_range, + .get_slot_vol_nominal_value = rg_get_slot_vol_nominal_value, + .get_slot_vol_value = rg_get_slot_vol_value, + .get_slot_curr_alias = rg_get_slot_curr_alias, + .get_slot_curr_type = rg_get_slot_curr_type, + .get_slot_curr_max = rg_get_slot_curr_max, + .get_slot_curr_min = rg_get_slot_curr_min, + .get_slot_curr_value = rg_get_slot_curr_value, + .get_slot_fpga_alias = rg_get_slot_fpga_alias, + .get_slot_fpga_alias = rg_get_slot_fpga_alias, + .get_slot_fpga_type = rg_get_slot_fpga_type, + .get_slot_fpga_firmware_version = rg_get_slot_fpga_firmware_version, + .get_slot_fpga_board_version = rg_get_slot_fpga_board_version, + .get_slot_fpga_test_reg = rg_get_slot_fpga_test_reg, + .set_slot_fpga_test_reg = rg_set_slot_fpga_test_reg, + .get_slot_cpld_alias = rg_get_slot_cpld_alias, + .get_slot_cpld_type = rg_get_slot_cpld_type, + .get_slot_cpld_firmware_version = rg_get_slot_cpld_firmware_version, + .get_slot_cpld_board_version = rg_get_slot_cpld_board_version, + .get_slot_cpld_test_reg = rg_get_slot_cpld_test_reg, + .set_slot_cpld_test_reg = rg_set_slot_cpld_test_reg, +}; + +static int __init slot_dev_drv_init(void) +{ + int ret; + + SLOT_INFO("slot_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_slot_drivers_register(&drivers); + if (ret < 0) { + SLOT_ERR("slot drivers register err, ret %d.\n", ret); + return ret; + } + SLOT_INFO("slot_init success.\n"); + return 0; +} + +static void __exit slot_dev_drv_exit(void) +{ + s3ip_sysfs_slot_drivers_unregister(); + SLOT_INFO("slot_exit success.\n"); + return; +} + +module_init(slot_dev_drv_init); +module_exit(slot_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("slot device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/syseeprom_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/syseeprom_device_driver.c new file mode 100644 index 000000000000..b92acb40d75f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/syseeprom_device_driver.c @@ -0,0 +1,125 @@ +/* + * syseeprom_device_driver.c + * + * This module realize /sys/s3ip/syseeprom attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "syseeprom_sysfs.h" +#include "dfd_sysfs_common.h" + +#define SYSE2_INFO(fmt, args...) LOG_INFO("syseeprom: ", fmt, ##args) +#define SYSE2_ERR(fmt, args...) LOG_ERR("syseeprom: ", fmt, ##args) +#define SYSE2_DBG(fmt, args...) LOG_DBG("syseeprom: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/*****************************************syseeprom*******************************************/ +/* + * rg_get_syseeprom_size - Used to get syseeprom size + * + * This function returns the size of syseeprom by your switch, + * otherwise it returns a negative value on failed. + */ +static int rg_get_syseeprom_size(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_syseeprom_size); + + ret = g_drv->get_syseeprom_size(); + return ret; +} + +/* + * rg_read_syseeprom_data - Used to read syseeprom data, + * @buf: Data read buffer + * @offset: offset address to read syseeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_read_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->read_syseeprom_data); + + ret = g_drv->read_syseeprom_data(buf, offset, count); + return ret; +} + +/* + * rg_write_syseeprom_data - Used to write syseeprom data + * @buf: Data write buffer + * @offset: offset address to write syseeprom data + * @count: length of buf + * + * This function returns the written length of syseeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_write_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->write_syseeprom_data); + + ret = g_drv->write_syseeprom_data(buf, offset, count); + return ret; +} +/*************************************end of syseeprom****************************************/ + +static struct s3ip_sysfs_syseeprom_drivers_s drivers = { + /* + * set ODM syseeprom drivers to /sys/s3ip/syseeprom, + * if not support the function, set corresponding hook to NULL. + */ + .get_syseeprom_size = rg_get_syseeprom_size, + .read_syseeprom_data = rg_read_syseeprom_data, + .write_syseeprom_data = rg_write_syseeprom_data, +}; + +static int __init syseeprom_dev_drv_init(void) +{ + int ret; + + SYSE2_INFO("syseeprom_dev_drv_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_syseeprom_drivers_register(&drivers); + if (ret < 0) { + SYSE2_ERR("syseeprom drivers register err, ret %d.\n", ret); + return ret; + } + SYSE2_INFO("syseeprom_dev_drv_init success.\n"); + return 0; +} + +static void __exit syseeprom_dev_drv_exit(void) +{ + s3ip_sysfs_syseeprom_drivers_unregister(); + SYSE2_INFO("syseeprom_exit success.\n"); + return; +} + +module_init(syseeprom_dev_drv_init); +module_exit(syseeprom_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("syseeprom device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/sysled_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/sysled_device_driver.c new file mode 100644 index 000000000000..6f6ab3f280aa --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/sysled_device_driver.c @@ -0,0 +1,229 @@ +/* + * sysled_device_driver.c + * + * This module realize /sys/s3ip/sysled attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "sysled_sysfs.h" +#include "dfd_sysfs_common.h" + +#define SYSLED_INFO(fmt, args...) LOG_INFO("sysled: ", fmt, ##args) +#define SYSLED_ERR(fmt, args...) LOG_ERR("sysled: ", fmt, ##args) +#define SYSLED_DBG(fmt, args...) LOG_DBG("sysled: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/*****************************************sysled**********************************************/ +/* + * rg_get_sys_led_status - Used to get sys led status + * filled the value to buf, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_sys_led_status(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_sys_led_status); + + ret = g_drv->get_sys_led_status(buf, count); + return ret; +} + +/* + * rg_set_sys_led_status - Used to set sys led status + * @status: led status, led status value define as below: + * 0: dark + * 1: green + * 2: yellow + * 3: red + * 4: blue + * 5: green light flashing + * 6: yellow light flashing + * 7: red light flashing + * 8: blue light flashing + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_sys_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_sys_led_status); + + ret = g_drv->set_sys_led_status(status); + return ret; +} + +/* Similar to rg_get_sys_led_status */ +static ssize_t rg_get_bmc_led_status(char *buf, size_t count) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_bmc_led_status); + + ret = g_drv->get_bmc_led_status(buf, count); + return ret; +} + +/* Similar to rg_set_sys_led_status */ +static int rg_set_bmc_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_bmc_led_status); + + ret = g_drv->set_bmc_led_status(status); + return ret; +} + +/* Similar to rg_get_sys_led_status */ +static ssize_t rg_get_sys_fan_led_status(char *buf, size_t count) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_sys_fan_led_status); + + ret = g_drv->get_sys_fan_led_status(buf, count); + return ret; +} + +/* Similar to rg_set_sys_led_status */ +static int rg_set_sys_fan_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_sys_fan_led_status); + + ret = g_drv->set_sys_fan_led_status(status); + return ret; +} + +/* Similar to rg_get_sys_led_status */ +static ssize_t rg_get_sys_psu_led_status(char *buf, size_t count) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_sys_psu_led_status); + + ret = g_drv->get_sys_psu_led_status(buf, count); + return ret; +} + +/* Similar to rg_set_sys_led_status */ +static int rg_set_sys_psu_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_sys_psu_led_status); + + ret = g_drv->set_sys_psu_led_status(status); + return ret; +} + +/* Similar to rg_get_sys_led_status */ +static ssize_t rg_get_id_led_status(char *buf, size_t count) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_id_led_status); + + ret = g_drv->get_id_led_status(buf, count); + return ret; +} + +/* Similar to rg_set_sys_led_status */ +static int rg_set_id_led_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_id_led_status); + + ret = g_drv->set_id_led_status(status); + return ret; +} + +/**************************************end of sysled******************************************/ + +static struct s3ip_sysfs_sysled_drivers_s drivers = { + /* + * set ODM sysled drivers to /sys/s3ip/sysled, + * if not support the function, set corresponding hook to NULL. + */ + .get_sys_led_status = rg_get_sys_led_status, + .set_sys_led_status = rg_set_sys_led_status, + .get_bmc_led_status = rg_get_bmc_led_status, + .set_bmc_led_status = rg_set_bmc_led_status, + .get_sys_fan_led_status = rg_get_sys_fan_led_status, + .set_sys_fan_led_status = rg_set_sys_fan_led_status, + .get_sys_psu_led_status = rg_get_sys_psu_led_status, + .set_sys_psu_led_status = rg_set_sys_psu_led_status, + .get_id_led_status = rg_get_id_led_status, + .set_id_led_status = rg_set_id_led_status, +}; + +static int __init sysled_init(void) +{ + int ret; + + SYSLED_INFO("sysled_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_sysled_drivers_register(&drivers); + if (ret < 0) { + SYSLED_ERR("sysled drivers register err, ret %d.\n", ret); + return ret; + } + + SYSLED_INFO("sysled create success.\n"); + return 0; +} + +static void __exit sysled_exit(void) +{ + s3ip_sysfs_sysled_drivers_unregister(); + SYSLED_INFO("sysled_exit ok.\n"); + return; +} + +module_init(sysled_init); +module_exit(sysled_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("sysled device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/temp_sensor_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/temp_sensor_device_driver.c new file mode 100644 index 000000000000..65b70009ac44 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/temp_sensor_device_driver.c @@ -0,0 +1,196 @@ +/* + * temp_sensor_device_driver.c + * + * This module realize /sys/s3ip/temp_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "temp_sensor_sysfs.h" +#include "dfd_sysfs_common.h" + +#define TEMP_SENSOR_INFO(fmt, args...) LOG_INFO("temp_sensor: ", fmt, ##args) +#define TEMP_SENSOR_ERR(fmt, args...) LOG_ERR("temp_sensor: ", fmt, ##args) +#define TEMP_SENSOR_DBG(fmt, args...) LOG_DBG("temp_sensor: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/***************************************main board temp*****************************************/ +/* + * rg_get_main_board_temp_number - Used to get main board temperature sensors number, + * + * This function returns main board temperature sensors by your switch, + * If there is no main board temperature sensors, returns 0, + * otherwise it returns a negative value on failed. + */ +static int rg_get_main_board_temp_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_number); + + ret = g_drv->get_main_board_temp_number(); + return ret; +} + +/* + * rg_get_main_board_temp_alias - Used to identify the location of the temperature sensor, + * such as air_inlet, air_outlet and so on. + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_alias(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_alias); + + ret = g_drv->get_main_board_temp_alias(temp_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_temp_type - Used to get the model of temperature sensor, + * such as lm75, tmp411 and so on + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_type(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_type); + + ret = g_drv->get_main_board_temp_type(temp_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_temp_max - Used to get the maximum threshold of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_max(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_max); + + ret = g_drv->get_main_board_temp_max(temp_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_temp_min - Used to get the minimum threshold of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_min(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_min); + + ret = g_drv->get_main_board_temp_min(temp_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_temp_value - Used to get the input value of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_temp_value(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_temp_value); + + ret = g_drv->get_main_board_temp_value(temp_index, buf, count); + return ret; +} +/***********************************end of main board temp*************************************/ + +static struct s3ip_sysfs_temp_sensor_drivers_s drivers = { + /* + * set ODM temperature sensor drivers to /sys/s3ip/temp_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_temp_number = rg_get_main_board_temp_number, + .get_main_board_temp_alias = rg_get_main_board_temp_alias, + .get_main_board_temp_type = rg_get_main_board_temp_type, + .get_main_board_temp_max = rg_get_main_board_temp_max, + .get_main_board_temp_min = rg_get_main_board_temp_min, + .get_main_board_temp_value = rg_get_main_board_temp_value, +}; + +static int __init temp_sensor_dev_drv_init(void) +{ + int ret; + + TEMP_SENSOR_INFO("temp_sensor_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_temp_sensor_drivers_register(&drivers); + if (ret < 0) { + TEMP_SENSOR_ERR("temp sensor drivers register err, ret %d.\n", ret); + return ret; + } + TEMP_SENSOR_INFO("temp_sensor_init success.\n"); + return 0; +} + +static void __exit temp_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_temp_sensor_drivers_unregister(); + TEMP_SENSOR_INFO("temp_sensor_exit success.\n"); + return; +} + +module_init(temp_sensor_dev_drv_init); +module_exit(temp_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("temperature sensors device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/transceiver_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/transceiver_device_driver.c new file mode 100644 index 000000000000..81edd935fc99 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/transceiver_device_driver.c @@ -0,0 +1,424 @@ +/* + * transceiver_device_driver.c + * + * This module realize /sys/s3ip/transceiver attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "transceiver_sysfs.h" +#include "dfd_sysfs_common.h" + +#define SFF_INFO(fmt, args...) LOG_INFO("sff: ", fmt, ##args) +#define SFF_ERR(fmt, args...) LOG_ERR("sff: ", fmt, ##args) +#define SFF_DBG(fmt, args...) LOG_DBG("sff: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/****************************************transceiver******************************************/ +static int rg_get_eth_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_eth_number); + + ret = g_drv->get_eth_number(); + return ret; +} + +/* + * rg_get_transceiver_power_on_status - Used to get the whole machine port power on status, + * filled the value to buf, 0: power off, 1: power on + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_transceiver_power_on_status(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_transceiver_power_on_status); + + ret = g_drv->get_transceiver_power_on_status(buf, count); + return ret; +} + +/* + * rg_set_transceiver_power_on_status - Used to set the whole machine port power on status, + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_transceiver_power_on_status(int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_transceiver_power_on_status); + + ret = g_drv->set_transceiver_power_on_status(status); + return ret; +} + +/* + * rg_get_eth_power_on_status - Used to get single port power on status, + * filled the value to buf, 0: power off, 1: power on + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_power_on_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_power_on_status); + + ret = g_drv->get_eth_power_on_status(eth_index, buf, count); + return ret; +} + +/* + * rg_set_eth_power_on_status - Used to set single port power on status, + * @eth_index: start with 1 + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_eth_power_on_status(unsigned int eth_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_eth_power_on_status); + + ret = g_drv->set_eth_power_on_status(eth_index, status); + return ret; +} + +/* + * rg_get_eth_tx_fault_status - Used to get port tx_fault status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_tx_fault_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_tx_fault_status); + + ret = g_drv->get_eth_tx_fault_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_tx_disable_status - Used to get port tx_disable status, + * filled the value to buf, 0: tx_enable, 1: tx_disable + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_tx_disable_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_tx_disable_status); + + ret = g_drv->get_eth_tx_disable_status(eth_index, buf, count); + return ret; +} + +/* + * rg_set_eth_tx_disable_status - Used to set port tx_disable status, + * @eth_index: start with 1 + * @status: tx_disable status, 0: tx_enable, 1: tx_disable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_eth_tx_disable_status(unsigned int eth_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_eth_tx_disable_status); + + ret = g_drv->set_eth_tx_disable_status(eth_index, status); + return ret; +} + +/* + * rg_get_eth_present_status - Used to get port present status, + * filled the value to buf, 1: present, 0: absent + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_present_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_present_status); + + ret = g_drv->get_eth_present_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_rx_los_status - Used to get port rx_los status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_rx_los_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_rx_los_status); + + ret = g_drv->get_eth_rx_los_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_reset_status - Used to get port reset status, + * filled the value to buf, 0: unreset, 1: reset + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_reset_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_reset_status); + + ret = g_drv->get_eth_reset_status(eth_index, buf, count); + return ret; +} + +/* + * rg_set_eth_reset_status - Used to set port reset status, + * @eth_index: start with 1 + * @status: reset status, 0: unreset, 1: reset + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_eth_reset_status(unsigned int eth_index, int status) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_eth_reset_status); + + ret = g_drv->set_eth_reset_status(eth_index, status); + return ret; +} + +/* + * rg_get_eth_low_power_mode_status - Used to get port low power mode status, + * filled the value to buf, 0: high power mode, 1: low power mode + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_low_power_mode_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_low_power_mode_status); + + ret = g_drv->get_eth_low_power_mode_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_interrupt_status - Used to get port interruption status, + * filled the value to buf, 0: no interruption, 1: interruption + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_eth_interrupt_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_eth_interrupt_status); + + ret = g_drv->get_eth_interrupt_status(eth_index, buf, count); + return ret; +} + +/* + * rg_get_eth_eeprom_size - Used to get port eeprom size + * + * This function returns the size of port eeprom, + * otherwise it returns a negative value on failed. + */ +static int rg_get_eth_eeprom_size(unsigned int eth_index) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_eth_eeprom_size); + + ret = g_drv->get_eth_eeprom_size(eth_index); + return ret; +} + +/* + * rg_read_eth_eeprom_data - Used to read port eeprom data, + * @buf: Data read buffer + * @offset: offset address to read port eeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_read_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->read_eth_eeprom_data); + + ret = g_drv->read_eth_eeprom_data(eth_index, buf, offset, count); + return ret; +} + +/* + * rg_write_eth_eeprom_data - Used to write port eeprom data + * @buf: Data write buffer + * @offset: offset address to write port eeprom data + * @count: length of buf + * + * This function returns the written length of port eeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_write_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->write_eth_eeprom_data); + + ret = g_drv->write_eth_eeprom_data(eth_index, buf, offset, count); + return ret; +} +/************************************end of transceiver***************************************/ + +static struct s3ip_sysfs_transceiver_drivers_s drivers = { + /* + * set ODM transceiver drivers to /sys/s3ip/transceiver, + * if not support the function, set corresponding hook to NULL. + */ + .get_eth_number = rg_get_eth_number, + .get_transceiver_power_on_status = rg_get_transceiver_power_on_status, + .set_transceiver_power_on_status = rg_set_transceiver_power_on_status, + .get_eth_power_on_status = rg_get_eth_power_on_status, + .set_eth_power_on_status = rg_set_eth_power_on_status, + .get_eth_tx_fault_status = rg_get_eth_tx_fault_status, + .get_eth_tx_disable_status = rg_get_eth_tx_disable_status, + .set_eth_tx_disable_status = rg_set_eth_tx_disable_status, + .get_eth_present_status = rg_get_eth_present_status, + .get_eth_rx_los_status = rg_get_eth_rx_los_status, + .get_eth_reset_status = rg_get_eth_reset_status, + .set_eth_reset_status = rg_set_eth_reset_status, + .get_eth_low_power_mode_status = rg_get_eth_low_power_mode_status, + .get_eth_interrupt_status = rg_get_eth_interrupt_status, + .get_eth_eeprom_size = rg_get_eth_eeprom_size, + .read_eth_eeprom_data = rg_read_eth_eeprom_data, + .write_eth_eeprom_data = rg_write_eth_eeprom_data, +}; + +static int __init sff_dev_drv_init(void) +{ + int ret; + + SFF_INFO("sff_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_sff_drivers_register(&drivers); + if (ret < 0) { + SFF_ERR("transceiver drivers register err, ret %d.\n", ret); + return ret; + } + SFF_INFO("sff_init success.\n"); + return 0; +} + +static void __exit sff_dev_drv_exit(void) +{ + s3ip_sysfs_sff_drivers_unregister(); + SFF_INFO("sff_exit success.\n"); + return; +} + +module_init(sff_dev_drv_init); +module_exit(sff_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("transceiver device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/vol_sensor_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/vol_sensor_device_driver.c new file mode 100644 index 000000000000..a58e122ac782 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/vol_sensor_device_driver.c @@ -0,0 +1,234 @@ +/* + * vol_sensor_device_driver.c + * + * This module realize /sys/s3ip/vol_sensor attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "vol_sensor_sysfs.h" +#include "dfd_sysfs_common.h" + +#define VOL_SENSOR_INFO(fmt, args...) LOG_INFO("vol_sensor: ", fmt, ##args) +#define VOL_SENSOR_ERR(fmt, args...) LOG_ERR("vol_sensor: ", fmt, ##args) +#define VOL_SENSOR_DBG(fmt, args...) LOG_DBG("vol_sensor: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/*************************************main board voltage***************************************/ +static int rg_get_main_board_vol_number(void) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_number); + + ret = g_drv->get_main_board_vol_number(); + return ret; +} + +/* + * rg_get_main_board_vol_alias - Used to identify the location of the voltage sensor, + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_alias(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_alias); + + ret = g_drv->get_main_board_vol_alias(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_type - Used to get the model of voltage sensor, + * such as udc90160, tps53622 and so on + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_type(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_type); + + ret = g_drv->get_main_board_vol_type(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_max - Used to get the maximum threshold of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_max(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_max); + + ret = g_drv->get_main_board_vol_max(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_min - Used to get the minimum threshold of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_min(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_min); + + ret = g_drv->get_main_board_vol_min(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_range - Used to get the output error value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_range(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_range); + + ret = g_drv->get_main_board_vol_range(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_nominal_value - Used to get the nominal value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_nominal_value(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_nominal_value); + + ret = g_drv->get_main_board_vol_nominal_value(vol_index, buf, count); + return ret; +} + +/* + * rg_get_main_board_vol_value - Used to get the input value of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_main_board_vol_value(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_main_board_vol_value); + + ret = g_drv->get_main_board_vol_value(vol_index, buf, count); + return ret; +} +/*********************************end of main board voltage************************************/ + +static struct s3ip_sysfs_vol_sensor_drivers_s drivers = { + /* + * set ODM voltage sensor drivers to /sys/s3ip/vol_sensor, + * if not support the function, set corresponding hook to NULL. + */ + .get_main_board_vol_number = rg_get_main_board_vol_number, + .get_main_board_vol_alias = rg_get_main_board_vol_alias, + .get_main_board_vol_type = rg_get_main_board_vol_type, + .get_main_board_vol_max = rg_get_main_board_vol_max, + .get_main_board_vol_min = rg_get_main_board_vol_min, + .get_main_board_vol_range = rg_get_main_board_vol_range, + .get_main_board_vol_nominal_value = rg_get_main_board_vol_nominal_value, + .get_main_board_vol_value = rg_get_main_board_vol_value, +}; + +static int __init vol_sensor_dev_drv_init(void) +{ + int ret; + + VOL_SENSOR_INFO("vol_sensor_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_vol_sensor_drivers_register(&drivers); + if (ret < 0) { + VOL_SENSOR_ERR("vol sensor drivers register err, ret %d.\n", ret); + return ret; + } + VOL_SENSOR_INFO("vol_sensor_init success.\n"); + return 0; +} + +static void __exit vol_sensor_dev_drv_exit(void) +{ + s3ip_sysfs_vol_sensor_drivers_unregister(); + VOL_SENSOR_INFO("vol_sensor_exit success.\n"); + return; +} + +module_init(vol_sensor_dev_drv_init); +module_exit(vol_sensor_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("voltage sensors device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/watchdog_device_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/watchdog_device_driver.c new file mode 100644 index 000000000000..6ac830cfb4ab --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/device_driver/watchdog_device_driver.c @@ -0,0 +1,204 @@ +/* + * watchdog_device_driver.c + * + * This module realize /sys/s3ip/watchdog attributes read and write functions + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "device_driver_common.h" +#include "watchdog_sysfs.h" +#include "dfd_sysfs_common.h" + +#define WDT_INFO(fmt, args...) LOG_INFO("watchdog: ", fmt, ##args) +#define WDT_ERR(fmt, args...) LOG_ERR("watchdog: ", fmt, ##args) +#define WDT_DBG(fmt, args...) LOG_DBG("watchdog: ", fmt, ##args) + +static int g_loglevel = 0; +static struct switch_drivers_s *g_drv = NULL; + +/****************************************watchdog*********************************************/ +/* + * rg_get_watchdog_identify - Used to get watchdog identify, such as iTCO_wdt + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_watchdog_identify(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_watchdog_identify); + + ret = g_drv->get_watchdog_identify(buf, count); + return ret; +} + +/* + * rg_get_watchdog_timeleft - Used to get watchdog timeleft, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_watchdog_timeleft(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_watchdog_timeleft); + + ret = g_drv->get_watchdog_timeleft(buf, count); + return ret; +} + +/* + * rg_get_watchdog_timeout - Used to get watchdog timeout, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_watchdog_timeout(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_watchdog_timeout); + + ret = g_drv->get_watchdog_timeout(buf, count); + return ret; +} + +/* + * rg_set_watchdog_timeout - Used to set watchdog timeout, + * @value: timeout value + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_watchdog_timeout(int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_watchdog_timeout); + + ret = g_drv->set_watchdog_timeout(value); + return ret; +} + +/* + * rg_get_watchdog_enable_status - Used to get watchdog enable status, + * filled the value to buf, 0: disable, 1: enable + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t rg_get_watchdog_enable_status(char *buf, size_t count) +{ + ssize_t ret; + + check_p(g_drv); + check_p(g_drv->get_watchdog_enable_status); + + ret = g_drv->get_watchdog_enable_status(buf, count); + return ret; +} + +/* + * rg_set_watchdog_enable_status - Used to set watchdog enable status, + * @value: enable status value, 0: disable, 1: enable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_watchdog_enable_status(int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_watchdog_enable_status); + + ret = g_drv->set_watchdog_enable_status(value); + return ret; +} + +/* + * rg_set_watchdog_reset - Used to feed watchdog, + * @value: any value to feed watchdog + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int rg_set_watchdog_reset(int value) +{ + int ret; + + check_p(g_drv); + check_p(g_drv->set_watchdog_reset); + + ret = g_drv->set_watchdog_reset(value); + return ret; +} + +/*************************************end of watchdog*****************************************/ + +static struct s3ip_sysfs_watchdog_drivers_s drivers = { + /* + * set ODM watchdog sensor drivers to /sys/s3ip/watchdog, + * if not support the function, set corresponding hook to NULL. + */ + .get_watchdog_identify = rg_get_watchdog_identify, + .get_watchdog_timeleft = rg_get_watchdog_timeleft, + .get_watchdog_timeout = rg_get_watchdog_timeout, + .set_watchdog_timeout = rg_set_watchdog_timeout, + .get_watchdog_enable_status = rg_get_watchdog_enable_status, + .set_watchdog_enable_status = rg_set_watchdog_enable_status, + .set_watchdog_reset = rg_set_watchdog_reset, +}; + +static int __init watchdog_dev_drv_init(void) +{ + int ret; + + WDT_INFO("watchdog_init...\n"); + g_drv = switch_driver_get(); + check_p(g_drv); + + ret = s3ip_sysfs_watchdog_drivers_register(&drivers); + if (ret < 0) { + WDT_ERR("watchdog drivers register err, ret %d.\n", ret); + return ret; + } + WDT_INFO("watchdog create success.\n"); + return 0; +} + +static void __exit watchdog_dev_drv_exit(void) +{ + s3ip_sysfs_watchdog_drivers_unregister(); + WDT_INFO("watchdog_exit success.\n"); + return; +} + +module_init(watchdog_dev_drv_init); +module_exit(watchdog_dev_drv_exit); +module_param(g_loglevel, int, 0644); +MODULE_PARM_DESC(g_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4, all=0xf).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("watchdog device driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/Makefile new file mode 100755 index 000000000000..af3af8c4f2a8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/Makefile @@ -0,0 +1,36 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall + +SUBDIR_CFG = cfg +rg_switch_driver-objs := switch_driver.o rg_module.o \ +rg_fan_driver.o \ +rg_eeprom_driver.o \ +rg_cpld_driver.o \ +rg_fpga_driver.o \ +rg_led_driver.o \ +rg_slot_driver.o \ +rg_sensors_driver.o \ +rg_psu_driver.o \ +rg_sff_driver.o \ +rg_watchdog_driver.o \ +$(SUBDIR_CFG)/dfd_cfg.o \ +$(SUBDIR_CFG)/dfd_cfg_adapter.o \ +$(SUBDIR_CFG)/dfd_cfg_file.o \ +$(SUBDIR_CFG)/dfd_cfg_info.o \ +$(SUBDIR_CFG)/dfd_cfg_listnode.o \ +$(SUBDIR_CFG)/dfd_frueeprom.o \ +$(SUBDIR_CFG)/dfd_tlveeprom.o \ + +obj-m := rg_switch_driver.o +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(sysfs_out_put_dir) ]; then mkdir -p $(sysfs_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(sysfs_out_put_dir) + @if [ ! -d $(sysfs_cfg_dir) ]; then mkdir -p $(sysfs_cfg_dir) ;fi + cp -r $(PWD)/dfd_cfg/* $(sysfs_cfg_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/$(SUBDIR_CFG)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/$(SUBDIR_CFG)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg.c new file mode 100644 index 000000000000..0522e7e5447b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg.c @@ -0,0 +1,964 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + * + */ +#include +#include +#include +#include +#include +#include + +#include "rg_module.h" +#include "dfd_cfg_file.h" +#include "dfd_cfg_listnode.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg.h" + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) _name, +static char *dfd_cfg_item_name[] = { + DFD_CFG_ITEM_ALL +}; + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) {_index_min, _index_max}, +static index_range_t dfd_cfg_item_index_range[] = { + DFD_CFG_ITEM_ALL +}; + +LIST_HEAD(dfd_lib_cfg_led_status_decode_conv_lst); + +LIST_HEAD(dfd_lib_cfg_fan_name_conv_dir_lst); + +LIST_HEAD(dfd_lib_cfg_power_name_conv_lst); + +static lnode_root_t dfd_ko_cfg_list_root; + +void dfd_ko_cfg_del_space_lf_cr(char *str) +{ + int i, j; + int len; + + if (str == NULL) { + DBG_DEBUG(DBG_ERROR, "param error, str is NULL\n"); + return; + } + len = strlen(str); + for (i = 0; i < len; i++) { + if (str[i] == '\r' || str[i] == '\n' || str[i] == ' ') { + for (j = i; j < len - 1; j++) { + str[j] = str[j + 1]; + } + str[j] = '\0'; + len--; + i--; + } + } +} + +void val_convert_node_lst_free(struct list_head *root) +{ + val_convert_node_t *node, *node_next; + + if (root == NULL){ + return ; + } + + list_for_each_entry_safe(node, node_next, root, lst) { + list_del(&node->lst); + kfree(node); + node = NULL; + } + + return ; + +} + +static void dfd_ko_cfg_regval_conv_lst_add(struct list_head *root, int val, char *str, + int index1, int index2) +{ + val_convert_node_t *val_convert; + + val_convert = (val_convert_node_t *)kmalloc(sizeof(val_convert_node_t), GFP_KERNEL); + if (val_convert == NULL) { + DBG_DEBUG(DBG_ERROR, "kmalloc val_convert_node_t fail\n"); + return; + } + memset(val_convert, 0, sizeof(val_convert_node_t)); + + val_convert->int_val = val; + val_convert->index1 = index1; + val_convert->index2 = index2; + if (str != NULL) { + strncpy(val_convert->str_val, str, sizeof(val_convert->str_val) - 1); + } + + list_add_tail(&(val_convert->lst), root); +} + +static int dfd_ko_cfg_get_index2_by_intval(struct list_head *root, int val, int index1, + int *index2) +{ + val_convert_node_t *val_convert; + + list_for_each_entry(val_convert, root, lst){ + if ((val_convert->int_val == val) && (index1 == val_convert->index1)) { + *index2 = val_convert->index2; + return 0; + } + } + + return -1; +} + +static int dfd_ko_cfg_get_index_by_strval(struct list_head *root, char *str, int *index1, int *index2) +{ + val_convert_node_t *val_convert; + + list_for_each_entry(val_convert, root, lst){ + if (strncmp(val_convert->str_val, str, strlen(val_convert->str_val)) == 0) { + *index1 = val_convert->index1; + *index2 = val_convert->index2; + return 0; + } + } + + return -1; +} + +static void dfd_ko_cfg_convert_list_build(dfd_cfg_item_id_t cfg_item_id, int val, char *str, + int index1, int index2) +{ + if (cfg_item_id == DFD_CFG_ITEM_LED_STATUS_DECODE) { + dfd_ko_cfg_regval_conv_lst_add(&dfd_lib_cfg_led_status_decode_conv_lst, val, str, index1, index2); + } else if (cfg_item_id == DFD_CFG_ITEM_FAN_DIRECTION) { + dfd_ko_cfg_regval_conv_lst_add(&dfd_lib_cfg_fan_name_conv_dir_lst, val, str, index1, index2); + } else if (cfg_item_id == DFD_CFG_ITEM_POWER_NAME) { + dfd_ko_cfg_regval_conv_lst_add(&dfd_lib_cfg_power_name_conv_lst, val, str, index1, index2); + } + return; +} + +int dfd_ko_cfg_get_led_status_decode2_by_regval(int regval, int index1, int *value) +{ + int rv; + + if (value == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_ko_cfg_get_index2_by_intval(&dfd_lib_cfg_led_status_decode_conv_lst, regval, + index1, value); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get led status decode by regval[0x%x] index1[%d] fail\n", + regval, index1); + return -DFD_RV_INVALID_VALUE; + } + + return 0; +} + +int dfd_ko_cfg_get_fan_direction_by_name(char *fan_name, int *fan_direction) +{ + int rv; + int index1, index2; + + if ((fan_name == NULL) || (fan_direction == NULL)){ + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_ko_cfg_get_index_by_strval(&dfd_lib_cfg_fan_name_conv_dir_lst, fan_name, &index1, &index2); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get fan direction by name[%s] fail\n", fan_name); + return -DFD_RV_NODE_FAIL; + } + + *fan_direction = index1; + + return 0; +} + +int dfd_ko_cfg_get_power_type_by_name(char *power_name, int *power_type) +{ + int rv; + int index1, index2; + + if ((power_name == NULL) || (power_type == NULL)){ + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -1; + } + + rv = dfd_ko_cfg_get_index_by_strval(&dfd_lib_cfg_power_name_conv_lst, power_name, &index1, &index2); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get power type by name[%s] fail\n", power_name); + return -1; + } + + *power_type = index1; + + return 0; +} + +static int dfd_ko_cfg_get_value_from_char(char *value_str, int32_t *value, int line_num) +{ + int value_tmp = 0; + + if (strlen(value_str) == 0) { + DBG_DEBUG(DBG_WARN, "line%d: value str is empty\n", line_num); + *value = DFD_CFG_EMPTY_VALUE; + return 0; + } + + if ((strlen(value_str) > 2) && (value_str[0] == '0') + && (value_str[1] == 'x' || value_str[1] == 'X')) { + value_tmp = (int32_t)simple_strtol(value_str, NULL, 16); + } else { + value_tmp = (int32_t)simple_strtol(value_str, NULL, 10); + } + + *value = value_tmp; + return 0; +} + +static int dfd_ko_cfg_analyse_index(char *index_str, int *index1, int *index2, int line_num) +{ + int rv; + char *index1_begin_char, *index2_begin_char; + + if (index_str[0] != '_') { + DBG_DEBUG(DBG_ERROR, "line%d: no '-' between name and index1\n", line_num); + return -1; + } + + index1_begin_char = index_str; + rv = dfd_ko_cfg_get_value_from_char(++index1_begin_char, index1, line_num); + if (rv < 0) { + return -1; + } + + if (index2 == NULL) { + return 0; + } + + index2_begin_char = strchr(index1_begin_char, '_'); + if (index2_begin_char == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: no '-' between index1 and index2\n", line_num); + return -1; + } else { + rv = dfd_ko_cfg_get_value_from_char(++index2_begin_char, index2, line_num); + if (rv < 0) { + return -1; + } + } + + return 0; +} + +static int dfd_ko_cfg_check_array_index(index_range_t *index_range, int *index1, int *index2, + int line_num) +{ + if ((*index1 < 0) || (*index1 > index_range->index1_max)) { + DBG_DEBUG(DBG_ERROR, "line%d: index1[%d] invalid, max=%d\n", line_num, *index1, + index_range->index1_max); + return -1; + } + + if (index2 == NULL) { + return 0; + } + + if ((*index2 < 0) || (*index2 > index_range->index2_max)) { + DBG_DEBUG(DBG_ERROR, "line%d: index2[%d] invalid, max=%d\n", line_num, *index2, + index_range->index2_max); + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_index(char *index_str, index_range_t *index_range, int *index1, + int *index2, int line_num) +{ + int rv; + + if (index_range->index2_max == INDEX_NOT_EXIST) { + index2 = NULL; + } + + rv = dfd_ko_cfg_analyse_index(index_str, index1, index2, line_num); + if (rv < 0) { + return -1; + } + + rv = dfd_ko_cfg_check_array_index(index_range, index1, index2, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_add_int_item(int key, int value, int line_num) +{ + int rv; + int *int_cfg; + + int_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (int_cfg == NULL) { + int_cfg = (int *)kmalloc(sizeof(int), GFP_KERNEL); + if (int_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc int fail\n", line_num); + return -1; + } + + *int_cfg = value; + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, int_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add int item[%d] success, key=0x%08x\n", + line_num, value, key); + } else { + kfree(int_cfg); + int_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add int item[%d] fail, key=0x%08x rv=%d \n", + line_num, value, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_WARN, "line%d: replace int item[%d->%d], key=0x%08x\n", + line_num, *int_cfg, value, key); + *int_cfg = value; + } + + return 0; +} + +static int dfd_ko_cfg_analyse_int_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int value, key; + char *arg_name_tmp; + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + rv = dfd_ko_cfg_get_value_from_char(arg_value, &value, line_num); + if (rv < 0) { + return -1; + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_int_item(key, value, line_num); + if (rv < 0) { + return -1; + } + + dfd_ko_cfg_convert_list_build(cfg_item_id, value, NULL, index1, index2); + return 0; +} + +static int dfd_ko_cfg_add_str_item(int key, char *str, int line_num) +{ + int rv; + char *str_cfg; + + str_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (str_cfg == NULL) { + str_cfg = (char *)kmalloc(DFD_CFG_STR_MAX_LEN, GFP_KERNEL); + if (str_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc str[%lu] fail\n", line_num, strlen(str)); + return -1; + } + memset(str_cfg, 0, DFD_CFG_STR_MAX_LEN); + strncpy(str_cfg, str, DFD_CFG_STR_MAX_LEN - 1); + + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, str_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add string item[%s] success, key=0x%08x\n", + line_num, str_cfg, key); + } else { + kfree(str_cfg); + str_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add string item[%s] fail, key=0x%08x rv=%d \n", + line_num, str_cfg, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_WARN, "line%d: replace string item[%s->%s], key=0x%08x\n", + line_num, str_cfg, str, key); + memset(str_cfg, 0, DFD_CFG_STR_MAX_LEN); + strncpy(str_cfg, str, DFD_CFG_STR_MAX_LEN - 1); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_str_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int btree_key; + char *arg_name_tmp; + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + if (strlen(arg_value) >= DFD_CFG_STR_MAX_LEN) { + DBG_DEBUG(DBG_ERROR, "line%d: string item[%s] is too long \n", line_num, arg_value); + return -1; + } + + btree_key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_str_item(btree_key, arg_value, line_num); + if (rv < 0) { + return -1; + } + + dfd_ko_cfg_convert_list_build(cfg_item_id, 0, arg_value, index1, index2); + return 0; +} + +static int dfd_ko_cfg_get_i2c_dev_member(char *member_str, dfd_i2c_dev_mem_t *member, int line_num) +{ + dfd_i2c_dev_mem_t mem_index; + + for (mem_index = DFD_I2C_DEV_MEM_BUS; mem_index < DFD_I2C_DEV_MEM_END; mem_index++) { + if (memcmp(member_str, g_dfd_i2c_dev_mem_str[mem_index], + strlen(g_dfd_i2c_dev_mem_str[mem_index])) == 0) { + *member = mem_index; + return 0; + } + } + + DBG_DEBUG(DBG_ERROR, "line%d: i2c dev member[%s] invalid\n", line_num, member_str); + return -1; +} + +static void dfd_ko_cfg_set_i2c_dev_mem_value(dfd_i2c_dev_t *i2c_dev, dfd_i2c_dev_mem_t member, + int value) +{ + switch (member) { + case DFD_I2C_DEV_MEM_BUS: + i2c_dev->bus = value; + break; + case DFD_I2C_DEV_MEM_ADDR: + i2c_dev->addr = value; + break; + default: + break; + } +} + +static int dfd_ko_cfg_add_i2c_dev_item(int key, dfd_i2c_dev_mem_t member, int value, int line_num) +{ + int rv; + dfd_i2c_dev_t *i2c_dev_cfg; + + i2c_dev_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (i2c_dev_cfg == NULL) { + i2c_dev_cfg = (dfd_i2c_dev_t *)kmalloc(sizeof(dfd_i2c_dev_t), GFP_KERNEL); + if (i2c_dev_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc i2c_dev fail\n", line_num); + return -1; + } + memset(i2c_dev_cfg, 0, sizeof(dfd_i2c_dev_t)); + + dfd_ko_cfg_set_i2c_dev_mem_value(i2c_dev_cfg, member, value); + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, i2c_dev_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add i2c_dev item[%s=%d] success, key=0x%08x\n", + line_num, g_dfd_i2c_dev_mem_str[member], value, key); + } else { + kfree(i2c_dev_cfg); + i2c_dev_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add i2c_dev item[%s=%d] fail, key=0x%08x rv=%d\n", + line_num, g_dfd_i2c_dev_mem_str[member], value, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_VERBOSE, "line%d: replace i2c_dev item[%s=%d], key=0x%08x\n", line_num, + g_dfd_i2c_dev_mem_str[member], value, key); + dfd_ko_cfg_set_i2c_dev_mem_value(i2c_dev_cfg, member, value); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_i2c_dev_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int value, key; + char *arg_name_tmp; + dfd_i2c_dev_mem_t member; + + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_i2c_dev_member(arg_name_tmp, &member, line_num); + if (rv < 0) { + return -1; + } + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp += strlen(g_dfd_i2c_dev_mem_str[member]); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + rv = dfd_ko_cfg_get_value_from_char(arg_value, &value, line_num); + if (rv < 0) { + return -1; + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_i2c_dev_item(key, member, value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_get_enum_value_by_str(char *enum_val_str[], int enum_val_end, char *buf) +{ + int i; + int enum_val; + + enum_val = DFD_CFG_INVALID_VALUE; + for (i = 0; i < enum_val_end; i++) { + if (memcmp(buf, enum_val_str[i], strlen(enum_val_str[i])) == 0) { + enum_val = i; + break; + } + } + + return enum_val; +} + +static int dfd_ko_cfg_get_info_ctrl_member(char *member_str, info_ctrl_mem_t *member, int line_num) +{ + info_ctrl_mem_t mem_index; + + for (mem_index = INFO_CTRL_MEM_MODE; mem_index < INFO_CTRL_MEM_END; mem_index++) { + if (memcmp(member_str, g_info_ctrl_mem_str[mem_index], + strlen(g_info_ctrl_mem_str[mem_index])) == 0) { + *member = mem_index; + return 0; + } + } + + DBG_DEBUG(DBG_ERROR, "line%d: info ctrl member[%s] invalid\n", line_num, member_str); + return -1; +} + +static void dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_t *info_ctrl, info_ctrl_mem_t member, + char *buf_val, int line_num) +{ + switch (member) { + case INFO_CTRL_MEM_MODE: + info_ctrl->mode = dfd_ko_cfg_get_enum_value_by_str(g_info_ctrl_mode_str, + INFO_CTRL_MODE_END, buf_val); + break; + case INFO_CTRL_MEM_INT_CONS: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_cons), line_num); + break; + case INFO_CTRL_MEM_SRC: + info_ctrl->src = dfd_ko_cfg_get_enum_value_by_str(g_info_src_str, INFO_SRC_END, buf_val); + break; + case INFO_CTRL_MEM_FRMT: + info_ctrl->frmt = dfd_ko_cfg_get_enum_value_by_str(g_info_frmt_str, INFO_FRMT_END, buf_val); + break; + case INFO_CTRL_MEM_POLA: + info_ctrl->pola = dfd_ko_cfg_get_enum_value_by_str(g_info_pola_str, INFO_POLA_END, buf_val); + break; + case INFO_CTRL_MEM_FPATH: + memset(info_ctrl->fpath, 0, sizeof(info_ctrl->fpath)); + strncpy(info_ctrl->fpath, buf_val, sizeof(info_ctrl->fpath) - 1); + break; + case INFO_CTRL_MEM_ADDR: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->addr), line_num); + break; + case INFO_CTRL_MEM_LEN: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->len), line_num); + break; + case INFO_CTRL_MEM_BIT_OFFSET: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->bit_offset), line_num); + break; + case INFO_CTRL_MEM_STR_CONS: + memset(info_ctrl->str_cons, 0, sizeof(info_ctrl->str_cons)); + strncpy(info_ctrl->str_cons, buf_val, sizeof(info_ctrl->str_cons) - 1); + break; + case INFO_CTRL_MEM_INT_EXTRA1: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_extra1), line_num); + break; + case INFO_CTRL_MEM_INT_EXTRA2: + dfd_ko_cfg_get_value_from_char(buf_val, &(info_ctrl->int_extra2), line_num); + break; + default: + break; + } +} + +static int dfd_ko_cfg_add_info_ctrl_item(int key, info_ctrl_mem_t member, char *buf_val, + int line_num) +{ + int rv; + info_ctrl_t *info_ctrl_cfg; + + info_ctrl_cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (info_ctrl_cfg == NULL) { + info_ctrl_cfg = (info_ctrl_t *)kmalloc(sizeof(info_ctrl_t), GFP_KERNEL); + if (info_ctrl_cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "line%d: kmalloc info_ctrl fail\n", line_num); + return -1; + } + memset(info_ctrl_cfg, 0, sizeof(info_ctrl_t)); + + dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_cfg, member, buf_val, line_num); + rv = lnode_insert_node(&dfd_ko_cfg_list_root, key, info_ctrl_cfg); + if (rv == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: add info_ctrl item[%s=%s] success, key=0x%08x\n", + line_num, g_info_ctrl_mem_str[member], buf_val, key); + } else { + kfree(info_ctrl_cfg); + info_ctrl_cfg = NULL; + DBG_DEBUG(DBG_ERROR, "line%d: add info_ctrl item[%s=%s] fail, key=0x%08x rv=%d\n", + line_num, g_info_ctrl_mem_str[member], buf_val, key, rv); + return -1; + } + } else { + DBG_DEBUG(DBG_VERBOSE, "line%d: replace info_ctrl item[%s=%s], key=0x%08x\n", + line_num, g_info_ctrl_mem_str[member], buf_val, key); + dfd_ko_cfg_set_info_ctrl_mem_value(info_ctrl_cfg, member, buf_val, line_num); + } + + return 0; +} + +static int dfd_ko_cfg_analyse_info_ctrl_item(dfd_cfg_item_id_t cfg_item_id, char *arg_name, + char *arg_value, char *cfg_pre, index_range_t *index_range, int line_num) +{ + int rv; + int index1 = 0, index2 = 0; + int key; + char *arg_name_tmp; + info_ctrl_mem_t member; + + arg_name_tmp = arg_name + strlen(cfg_pre); + rv = dfd_ko_cfg_get_info_ctrl_member(arg_name_tmp, &member, line_num); + if (rv < 0) { + return -1; + } + + if (index_range->index1_max != INDEX_NOT_EXIST) { + arg_name_tmp += strlen(g_info_ctrl_mem_str[member]); + rv = dfd_ko_cfg_get_index(arg_name_tmp, index_range, &index1, &index2, line_num); + if (rv < 0) { + return -1; + } + } + + key = DFD_CFG_KEY(cfg_item_id, index1, index2); + rv = dfd_ko_cfg_add_info_ctrl_item(key, member, arg_value, line_num); + if (rv < 0) { + return -1; + } + + return 0; +} + +static int dfd_ko_cfg_analyse_config(char *arg_name, char*arg_value, int line_num) +{ + int i, rv = 0; + int cfg_item_num; + + cfg_item_num = sizeof(dfd_cfg_item_name) / sizeof(dfd_cfg_item_name[0]); + for (i = 0; i < cfg_item_num; i++) { + if (memcmp(arg_name, dfd_cfg_item_name[i], strlen(dfd_cfg_item_name[i])) == 0){ + if (DFD_CFG_ITEM_IS_INT(i)) { + rv = dfd_ko_cfg_analyse_int_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_STRING(i)) { + rv = dfd_ko_cfg_analyse_str_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_I2C_DEV(i)) { + rv = dfd_ko_cfg_analyse_i2c_dev_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else if (DFD_CFG_ITEM_IS_INFO_CTRL(i)) { + rv = dfd_ko_cfg_analyse_info_ctrl_item(i, arg_name, arg_value, dfd_cfg_item_name[i], + &(dfd_cfg_item_index_range[i]), line_num); + } else { + rv = -1; + } + break; + } + } + + return rv; +} + +static int dfd_ko_cfg_cut_config_line(char *config_line, char *arg_name, char *arg_value) +{ + int i, j = 0, k = 0; + int len, name_value_flag = 0; + + len = strlen(config_line); + for (i = 0; i < len; i++) { + if (config_line[i] == '=') { + name_value_flag = 1; + continue; + } + + if (name_value_flag == 0) { + arg_name[j++] = config_line[i]; + } else { + arg_value[k++] = config_line[i]; + } + } + + if (name_value_flag == 0) { + return -1; + } else { + return 0; + } +} + +static int dfd_ko_cfg_analyse_config_line(char *config_line, int line_num) +{ + int rv; + char arg_name[DFD_CFG_NAME_MAX_LEN] = {0}; + char arg_value[DFD_CFG_VALUE_MAX_LEN] = {0}; + + dfd_ko_cfg_del_space_lf_cr(config_line); + + if (strlen(config_line) == 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: space line\n", line_num); + return 0; + } + + if (config_line[0] == '#') { + DBG_DEBUG(DBG_VERBOSE, "line%d: comment line[%s]\n", line_num, config_line); + return 0; + } + + rv = dfd_ko_cfg_cut_config_line(config_line, arg_name, arg_value); + if (rv < 0) { + DBG_DEBUG(DBG_VERBOSE, "line%d: [%s]no '=' between name and value\n", + line_num, config_line); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "line%d: config_line[%s] name[%s] value[%s]\n", + line_num, config_line, arg_name, arg_value); + return dfd_ko_cfg_analyse_config(arg_name, arg_value, line_num); +} + +static int dfd_ko_cfg_analyse_config_file(char *fpath) +{ + int rv; + int line_num = 1; + kfile_ctrl_t kfile_ctrl; + char config_line[DFD_CFG_CMDLINE_MAX_LEN] = {0}; + + rv = kfile_open(fpath, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", fpath, rv); + return -1; + } + + while(kfile_gets(config_line, sizeof(config_line), &kfile_ctrl) > 0){ + rv = dfd_ko_cfg_analyse_config_line(config_line, line_num++); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "!!!!file[%s] config line[%d %s] analyse fail\n", + fpath, line_num - 1, config_line); + break; + } + + (void)memset(config_line, 0, sizeof(config_line)); + + } + kfile_close(&kfile_ctrl); + + return rv; +} + +void *dfd_ko_cfg_get_item(int key) +{ + return lnode_find_node(&dfd_ko_cfg_list_root, key); +} + +static void dfd_ko_cfg_print_item(int key, const void *cfg) +{ + int item_id; + dfd_i2c_dev_t *i2c_dev; + info_ctrl_t *info_ctrl; + + if (cfg == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return; + } + printk(KERN_INFO "**************************\n"); + printk(KERN_INFO "key=0x%08x\n", key); + + item_id = DFD_CFG_ITEM_ID(key); + if (DFD_CFG_ITEM_IS_INT(item_id)) { + printk(KERN_INFO "int=%d\n", *((int *)cfg)); + } else if (DFD_CFG_ITEM_IS_I2C_DEV(item_id)) { + i2c_dev = (dfd_i2c_dev_t *)cfg; + printk(KERN_INFO ".bus=0x%02x\n", i2c_dev->bus); + printk(KERN_INFO ".addr=0x%02x\n", i2c_dev->addr); + } else if (DFD_CFG_ITEM_IS_INFO_CTRL(item_id)) { + info_ctrl = (info_ctrl_t *)cfg; + printk(KERN_INFO ".mode=%s\n", g_info_ctrl_mode_str[info_ctrl->mode]); + printk(KERN_INFO ".int_cons=%d\n", info_ctrl->int_cons); + printk(KERN_INFO ".src=%s\n", g_info_src_str[info_ctrl->src]); + printk(KERN_INFO ".frmt=%s\n", g_info_frmt_str[info_ctrl->frmt]); + printk(KERN_INFO ".pola=%s\n", g_info_pola_str[info_ctrl->pola]); + printk(KERN_INFO ".fpath=%s\n", info_ctrl->fpath); + printk(KERN_INFO ".addr=0x%02x\n", info_ctrl->addr); + printk(KERN_INFO ".len=%d\n", info_ctrl->len); + printk(KERN_INFO ".bit_offset=%d\n", info_ctrl->bit_offset); + } else { + printk(KERN_INFO "item[%d] error!\n", item_id); + } +} + +void dfd_ko_cfg_show_item(int key) +{ + void *cfg; + + cfg = lnode_find_node(&dfd_ko_cfg_list_root, key); + if (cfg == 0) { + printk(KERN_INFO "item[0x%08x] not exist\n", key); + return; + } + + dfd_ko_cfg_print_item(key, cfg); +} + +static int dfd_get_my_dev_type_by_file(void) +{ + struct file *fp; + loff_t pos; + int card_type; + char buf[DFD_PID_BUF_LEN]; + int ret; + + fp= filp_open(DFD_PUB_CARDTYPE_FILE, O_RDONLY, 0); + if (IS_ERR(fp)) { + DBG_DEBUG(DBG_VERBOSE, "open file fail!\n"); + return -1; + } + + memset(buf, 0, DFD_PID_BUF_LEN); + pos = 0; + ret = kernel_read(fp, buf, DFD_PRODUCT_ID_LENGTH + 1, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_VERBOSE, "kernel_read failed, path=%s, addr=0, size=%d, ret=%d\n", + DFD_PUB_CARDTYPE_FILE, DFD_PRODUCT_ID_LENGTH + 1, ret); + filp_close(fp, NULL); + return -1; + } + + card_type = simple_strtoul(buf, NULL, 10); + DBG_DEBUG(DBG_VERBOSE, "card_type 0x%x.\n", card_type); + + filp_close(fp, NULL); + return card_type; +} + +static int drv_get_my_dev_type(void) +{ + static int type = -1; + + if (type > 0) { + return type; + } + type = dfd_get_my_dev_type_by_file(); + DBG_DEBUG(DBG_VERBOSE, "ko board type %d\n", type); + return type; +} + +static int dfd_ko_cfg_init(void) +{ + int rv; + int card_type; + char file_name[32] = {0}; + char fpath[128] = {0}; + kfile_ctrl_t kfile_ctrl; + + rv = lnode_init_root(&dfd_ko_cfg_list_root); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "init list root fail, rv=%d\n", rv); + return -1; + } + + card_type = drv_get_my_dev_type(); + if (card_type < 0) { + DBG_DEBUG(DBG_ERROR, "get my dev type fail, rv=%d\n", card_type); + return -1; + } + + snprintf(fpath, sizeof(fpath), "%s0x%x", DFD_KO_FILE_NAME_DIR, card_type); + rv = kfile_open(fpath, &kfile_ctrl); + if (rv != KFILE_RV_OK) { + DBG_DEBUG(DBG_ERROR, "open config file[%s] fail, rv=%d\n", fpath, rv); + return -1; + } + + while (kfile_gets(file_name, sizeof(file_name), &kfile_ctrl) > 0) { + dfd_ko_cfg_del_space_lf_cr(file_name); + snprintf(fpath, sizeof(fpath), "%s%s.cfg", DFD_KO_CFG_FILE_DIR, file_name); + DBG_DEBUG(DBG_VERBOSE, ">>>>start parsing config file[%s]\n", fpath); + rv = dfd_ko_cfg_analyse_config_file(fpath); + if (rv < 0) { + break; + } + } + kfile_close(&kfile_ctrl); + return 0; +} + +int32_t dfd_dev_cfg_init(void) +{ + return dfd_ko_cfg_init(); +} + +void dfd_dev_cfg_exit(void) +{ + lnode_free_list(&dfd_ko_cfg_list_root); + val_convert_node_lst_free(&dfd_lib_cfg_led_status_decode_conv_lst); + val_convert_node_lst_free(&dfd_lib_cfg_fan_name_conv_dir_lst); + val_convert_node_lst_free(&dfd_lib_cfg_power_name_conv_lst); + return; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_adapter.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_adapter.c new file mode 100644 index 000000000000..32a44ad7a1f6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_adapter.c @@ -0,0 +1,415 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg_adapter.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "rg_module.h" +#include "dfd_cfg_file.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" + +char *g_dfd_i2c_dev_mem_str[DFD_I2C_DEV_MEM_END] = { + ".bus", + ".addr", +}; + +static dfd_i2c_dev_t* dfd_ko_get_cpld_i2c_dev(int sub_slot, int cpld_id) +{ + int key; + dfd_i2c_dev_t *i2c_dev; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_I2C_DEV, sub_slot, cpld_id); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld[%d] i2c dev config fail, key=0x%08x\n", cpld_id, key); + return NULL; + } + + return i2c_dev; +} + +static int32_t dfd_ko_i2c_smbus_transfer(int read_write, int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int rv; + struct i2c_adapter *i2c_adap; + union i2c_smbus_data data; + + i2c_adap = i2c_get_adapter(bus); + if (i2c_adap == NULL) { + DBG_DEBUG(DBG_ERROR, "get i2c bus[%d] adapter fail\n", bus); + return -DFD_RV_DEV_FAIL; + } + + if (read_write == I2C_SMBUS_WRITE) { + data.byte = *buf; + } else { + data.byte = 0; + } + rv = i2c_smbus_xfer(i2c_adap, addr, 0, read_write, offset, I2C_SMBUS_BYTE_DATA, &data); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "i2c dev[bus=%d addr=0x%x offset=0x%x size=%d rw=%d] transfer fail, rv=%d\n", + bus, addr, offset, size, read_write, rv); + rv = -DFD_RV_DEV_FAIL; + } else { + DBG_DEBUG(DBG_VERBOSE, "i2c dev[bus=%d addr=0x%x offset=0x%x size=%d rw=%d] transfer success\n", + bus, addr, offset, size, read_write); + rv = DFD_RV_OK; + } + + if (read_write == I2C_SMBUS_READ) { + if (rv == DFD_RV_OK) { + *buf = data.byte; + } else { + *buf = 0; + } + } + + i2c_put_adapter(i2c_adap); + return rv; +} + +static int32_t dfd_ko_i2c_read_data(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + for (i = 0; i < DFD_KO_CPLD_I2C_RETRY_TIMES; i++) { + rv = dfd_ko_i2c_smbus_transfer(I2C_SMBUS_READ, bus, addr, offset, buf, size); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "[%d]cpld read[offset=0x%x] fail, rv %d\n", i, addr, rv); + msleep(DFD_KO_CPLD_I2C_RETRY_SLEEP); + } else { + DBG_DEBUG(DBG_VERBOSE, "[%d]cpld read[offset=0x%x] success, value=0x%x\n", + i, addr, *buf); + break; + } + } + return rv; +} + +static int32_t dfd_ko_i2c_write_data(int bus, int addr, int offset, uint8_t data, uint32_t size) +{ + int i, rv; + for (i = 0; i < DFD_KO_CPLD_I2C_RETRY_TIMES; i++) { + rv = dfd_ko_i2c_smbus_transfer(I2C_SMBUS_WRITE, bus, addr, offset, &data, size); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "[%d]cpld write[offset=0x%x] fail, rv=%d\n", i, addr, rv); + msleep(DFD_KO_CPLD_I2C_RETRY_SLEEP); + } else { + DBG_DEBUG(DBG_VERBOSE, "[%d]cpld write[offset=0x%x, data=%d] success\n", i, addr, data); + break; + } + } + + return rv; +} + +static int32_t dfd_ko_cpld_i2c_read(int32_t addr, uint8_t *buf) +{ + int rv; + int sub_slot, cpld_id, cpld_addr; + dfd_i2c_dev_t *i2c_dev; + + if (buf == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_INDEX_INVALID; + } + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + cpld_addr = DFD_KO_CPLD_GET_INDEX(addr); + + i2c_dev = dfd_ko_get_cpld_i2c_dev(sub_slot, cpld_id); + if (i2c_dev == NULL) { + return -DFD_RV_DEV_NOTSUPPORT; + } + rv = dfd_ko_i2c_read_data(i2c_dev->bus, i2c_dev->addr, cpld_addr, buf, sizeof(uint8_t)); + + return rv; +} + +static int32_t dfd_ko_cpld_i2c_write(int32_t addr, uint8_t data) +{ + int rv; + int sub_slot, cpld_id, cpld_addr; + dfd_i2c_dev_t *i2c_dev; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + cpld_addr = DFD_KO_CPLD_GET_INDEX(addr); + + i2c_dev = dfd_ko_get_cpld_i2c_dev(sub_slot, cpld_id); + if (i2c_dev == NULL) { + return -DFD_RV_DEV_NOTSUPPORT; + } + + rv = dfd_ko_i2c_write_data(i2c_dev->bus, i2c_dev->addr, cpld_addr, data, sizeof(uint8_t)); + + return rv; +} + +static int32_t dfd_ko_cpld_io_read(int32_t addr, uint8_t *buf) +{ + int cpld_id, sub_slot, offset; + int key; + int *tmp; + uint16_t io_port; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + offset = DFD_KO_CPLD_GET_INDEX(addr); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_LPC_DEV, sub_slot, cpld_id); + tmp = dfd_ko_cfg_get_item(key); + if (tmp == NULL) { + DBG_DEBUG(DBG_ERROR,"get cpld io base config fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + io_port = (u16)(*tmp) + offset; + *buf = inb(io_port); + DBG_DEBUG(DBG_VERBOSE, "read cpld io port addr 0x%x, data 0x%x\n", io_port, *buf); + + return DFD_RV_OK; + +} + +static int32_t dfd_ko_cpld_io_write(int32_t addr, uint8_t data) +{ + int cpld_id, sub_slot, offset; + int key; + int *tmp; + uint16_t io_port; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + offset = DFD_KO_CPLD_GET_INDEX(addr); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_LPC_DEV, sub_slot, cpld_id); + tmp = dfd_ko_cfg_get_item(key); + if (tmp == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld io base config fail, key=0x%08x\n", key); + return -1; + } + + io_port = (u16)(*tmp) + offset; + DBG_DEBUG(DBG_VERBOSE, "write cpld io port addr 0x%x, data 0x%x\n", io_port, data); + outb(data, (u16)io_port); + + return DFD_RV_OK; +} + +static int dfd_cfg_get_cpld_mode(int sub_slot, int cpld_id, int *mode) +{ + int key; + char *name; + + if (mode == NULL) { + DBG_DEBUG(DBG_ERROR, "input arguments error\n"); + return -DFD_RV_TYPE_ERR; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_MODE, sub_slot, cpld_id); + name = dfd_ko_cfg_get_item(key); + if (name == NULL) { + DBG_DEBUG(DBG_ERROR, "get cpld[%d] mode info ctrl fail, key=0x%08x\n", cpld_id, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_DEBUG(DBG_VERBOSE, "cpld_id %d mode_name %s.\n", cpld_id, name); + if (!strncmp(name, DFD_KO_CPLD_MODE_I2C_STRING, strlen(DFD_KO_CPLD_MODE_I2C_STRING))) { + *mode = DFD_CPLD_MODE_I2C; + } else if (!strncmp(name, DFD_KO_CPLD_MODE_LPC_STRING, strlen(DFD_KO_CPLD_MODE_LPC_STRING))) { + *mode = DFD_CPLD_MODE_LPC; + } else { + *mode = DFD_CPLD_MODE_I2C; + } + + DBG_DEBUG(DBG_VERBOSE, "cpld_id %d mode %d.\n", cpld_id, *mode); + return 0; +} + +int32_t dfd_ko_cpld_read(int32_t addr, uint8_t *buf) +{ + int ret; + int sub_slot, cpld_id; + int cpld_mode; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + ret = dfd_cfg_get_cpld_mode(sub_slot, cpld_id, &cpld_mode); + if (ret) { + DBG_DEBUG(DBG_WARN, "drv_get_cpld_mode sub_slot %d cpldid %d faile, set default i2c mode.\n", sub_slot, cpld_id); + cpld_mode = DFD_CPLD_MODE_I2C; + } + + if (cpld_mode == DFD_CPLD_MODE_I2C) { + ret = dfd_ko_cpld_i2c_read(addr, buf); + } else if (cpld_mode == DFD_CPLD_MODE_LPC) { + ret = dfd_ko_cpld_io_read(addr, buf); + } else { + DBG_DEBUG(DBG_ERROR, "cpld_mode %d invalid.\n", cpld_mode); + ret = -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_DEBUG(DBG_VERBOSE, "addr 0x%x val 0x%x ret %d\n", addr, *buf, ret); + return ret; +} + +int32_t dfd_ko_cpld_write(int32_t addr, uint8_t val) +{ + int ret; + int sub_slot, cpld_id, cpld_mode; + + sub_slot = DFD_KO_CPLD_GET_SLOT(addr); + cpld_id = DFD_KO_CPLD_GET_ID(addr); + + ret = dfd_cfg_get_cpld_mode(sub_slot, cpld_id, &cpld_mode); + if (ret) { + DBG_DEBUG(DBG_ERROR, "drv_get_cpld_mode sub_slot %d cpldid %d faile, set default local_bus mode.\n", sub_slot, cpld_id); + cpld_mode = DFD_CPLD_MODE_I2C; + } + + if (cpld_mode == DFD_CPLD_MODE_I2C) { + ret = dfd_ko_cpld_i2c_write(addr, val); + } else if (cpld_mode == DFD_CPLD_MODE_LPC) { + ret = dfd_ko_cpld_io_write(addr, val); + } else { + DBG_DEBUG(DBG_ERROR, "cpld_mode %d invalid.\n", cpld_mode); + ret = -DFD_RV_MODE_INVALID; + } + + DBG_DEBUG(DBG_VERBOSE, "addr 0x%x val 0x%x ret %d\n", addr, val, ret); + return ret; +} + +static int32_t dfd_ko_i2c_read_tmp(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + + for (i = 0; i < size; i++) { + rv = dfd_ko_i2c_read_data(bus, addr, offset, &buf[i], sizeof(uint8_t)); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_read_data[bus=%d addr=0x%x offset=0x%x]fail, rv=%d\n", + bus, addr, offset, rv); + return rv; + } + offset++; + } + + return size; +} + +int32_t dfd_ko_i2c_write(int bus, int addr, int offset, uint8_t *buf, uint32_t size) +{ + int i, rv; + + for (i = 0; i < size; i++) { + rv = dfd_ko_i2c_write_data(bus, addr, offset, buf[i], sizeof(uint8_t)); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_write[bus=%d addr=0x%x offset=0x%x]fail, rv=%d\n", + bus, addr, offset, rv); + return rv; + } + offset++; + } + + return size; + +} + +int32_t dfd_ko_read_file(char *fpath, int32_t addr, uint8_t *val, int32_t read_bytes) +{ + int32_t ret; + struct file *filp; + loff_t pos; + + if ((fpath == NULL) || (val == NULL) || (addr < 0) || (read_bytes < 0)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, addr=%d read_bytes=%d\n", addr, read_bytes); + return -DFD_RV_INDEX_INVALID; + } + + filp = filp_open(fpath, O_RDONLY, 0); + if (IS_ERR(filp)){ + DBG_DEBUG(DBG_ERROR, "open file[%s] fail\n", fpath); + return -DFD_RV_DEV_FAIL; + } + pos = addr; + ret = kernel_read(filp, val, read_bytes, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_ERROR, "kernel_read failed, path=%s, addr=%d, size=%d, ret=%d\n", fpath, addr, read_bytes, ret); + ret = -DFD_RV_DEV_FAIL; + } + filp_close(filp, NULL); + return ret; +} + +int32_t dfd_ko_i2c_read(int bus, int addr, int offset, uint8_t *buf, uint32_t size, const char *sysfs_name) +{ + int rv; + char sysfs_path[DFD_SYSFS_PATH_MAX_LEN]; + + if (buf == NULL) { + DBG_DEBUG(DBG_ERROR, "params error, buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + + if (sysfs_name == NULL) { + DBG_DEBUG(DBG_VERBOSE, "using i2c_smbus_xfer, bus:%d, addr:0x%x, offset:0x%x, read size:%d.\n", + bus, addr, offset, size); + rv = dfd_ko_i2c_read_tmp(bus, addr, offset, buf, size); + } else { + memset(sysfs_path, 0, sizeof(sysfs_path)); + snprintf(sysfs_path, sizeof(sysfs_path), "/sys/bus/i2c/devices/%d-%04x/%s", + bus, addr, sysfs_name); + DBG_DEBUG(DBG_VERBOSE, "using sysfs, sysfs_path:%s, offset:0x%x, read size:%d.\n", + sysfs_path, offset, size); + rv = dfd_ko_read_file(sysfs_path, offset, buf, size); + } + + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dfd_ko_i2c_read failed.\n"); + } else { + DBG_DEBUG(DBG_VERBOSE, "dfd_ko_i2c_read success.\n"); + } + + return rv; +} + +int32_t dfd_ko_write_file(char *fpath, int32_t addr, uint8_t *val, int32_t write_bytes) +{ + int32_t ret; + struct file *filp; + loff_t pos; + + if ((fpath == NULL) || (val == NULL) || (addr < 0) || (write_bytes <= 0)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, addr=%d write_bytes=%d\n", addr, write_bytes); + return -DFD_RV_INDEX_INVALID; + } + + filp = filp_open(fpath, O_WRONLY, 0); + if (IS_ERR(filp)) { + DBG_DEBUG(DBG_ERROR, "open file[%s] fail\n", fpath); + return -DFD_RV_DEV_FAIL; + } + pos = addr; + ret = kernel_write(filp, val, write_bytes, &pos); + if (ret < 0) { + DBG_DEBUG(DBG_ERROR,"kernel_write failed, path=%s, addr=%d, size=%d, ret=%d\n", fpath, addr, write_bytes, ret); + ret = -DFD_RV_DEV_FAIL; + } + + filp_close(filp, NULL); + return ret; +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_file.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_file.c new file mode 100644 index 000000000000..4f1333dc06a9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_file.c @@ -0,0 +1,203 @@ +/* + * Copyright(C) 2001-2015s Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg_file.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + * History + * [Version] [Author] [Date] [Description] + * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dfd_cfg_file.h" +#include "rg_module.h" + +struct getdents_callback { + struct dir_context ctx; + const char *obj_name; + char *match_name; + int dir_len; + int found; +}; + +int kfile_open(char *fname, kfile_ctrl_t *kfile_ctrl) +{ + int ret; + struct file *filp; + loff_t pos; + + if ((fname == NULL) || (kfile_ctrl == NULL)) { + return KFILE_RV_INPUT_ERR; + } + + filp = filp_open(fname, O_RDONLY, 0); + if (IS_ERR(filp)){ + return KFILE_RV_OPEN_FAIL; + } + + kfile_ctrl->size = filp->f_inode->i_size; + + kfile_ctrl->buf = kmalloc(kfile_ctrl->size, GFP_KERNEL); + if (kfile_ctrl->buf == NULL) { + ret = KFILE_RV_MALLOC_FAIL; + goto close_fp; + } + memset(kfile_ctrl->buf, 0, kfile_ctrl->size); + pos = 0; + ret = kernel_read(filp, kfile_ctrl->buf, kfile_ctrl->size, &pos); + if (ret < 0) { + ret = KFILE_RV_RD_FAIL; + goto free_buf; + } + + kfile_ctrl->pos = 0; + + ret = KFILE_RV_OK; + goto close_fp; + +free_buf: + kfree(kfile_ctrl->buf); + kfile_ctrl->buf = NULL; + +close_fp: + filp_close(filp, NULL); + return ret; +} + +void kfile_close(kfile_ctrl_t *kfile_ctrl) +{ + if (kfile_ctrl == NULL) { + return; + } + + kfile_ctrl->size = 0; + kfile_ctrl->pos = 0; + if (kfile_ctrl->buf) { + kfree(kfile_ctrl->buf); + kfile_ctrl->buf = NULL; + } +} + +int kfile_gets(char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl) +{ + int i; + int has_cr = 0; + + if ((buf == NULL) || (buf_size <= 0) || (kfile_ctrl == NULL) || (kfile_ctrl->buf == NULL) + || (kfile_ctrl->size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + memset(buf, 0, buf_size); + for (i = 0; i < buf_size; i++) { + if (kfile_ctrl->pos >= kfile_ctrl->size) { + break; + } + + if (has_cr) { + break; + } + + if (IS_CR(kfile_ctrl->buf[kfile_ctrl->pos])) { + has_cr = 1; + } + + buf[i] = kfile_ctrl->buf[kfile_ctrl->pos]; + kfile_ctrl->pos++; + } + + return i; +} + +int kfile_read(int32_t addr, char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl) +{ + int i; + + if ((buf == NULL) || (buf_size <= 0) || (kfile_ctrl == NULL) || (kfile_ctrl->buf == NULL) + || (kfile_ctrl->size <= 0)) { + return KFILE_RV_INPUT_ERR; + } + + if ((addr < 0) || (addr >= kfile_ctrl->size)) { + return KFILE_RV_ADDR_ERR; + } + + memset(buf, 0, buf_size); + + kfile_ctrl->pos = addr; + for (i = 0; i < buf_size; i++) { + if (kfile_ctrl->pos >= kfile_ctrl->size) { + break; + } + buf[i] = kfile_ctrl->buf[kfile_ctrl->pos]; + kfile_ctrl->pos++; + } + + return i; +} + +static int kfile_filldir_one(struct dir_context *ctx, const char * name, int len, + loff_t pos, u64 ino, unsigned int d_type) +{ + struct getdents_callback *buf ; + int result; + buf = container_of(ctx, struct getdents_callback, ctx); + result = 0; + if (strncmp(buf->obj_name, name, strlen(buf->obj_name)) == 0) { + if (buf->dir_len < len) { + DBG_DEBUG(DBG_ERROR, "match ok. dir name:%s, but buf_len %d small than dir len %d.\n", + name, buf->dir_len, len); + buf->found = 0; + return -1; + } + memset(buf->match_name, 0 , buf->dir_len); + memcpy(buf->match_name, name, len); + buf->found = 1; + result = -1; + } + return result; +} + +int kfile_iterate_dir(const char *dir_path, const char *obj_name, char *match_name, int len) +{ + int ret; + struct file *dir; + struct getdents_callback buffer = { + .ctx.actor = kfile_filldir_one, + }; + + if(!dir_path || !obj_name || !match_name) { + DBG_DEBUG(DBG_ERROR, "params error. \n"); + return KFILE_RV_INPUT_ERR; + } + buffer.obj_name = obj_name; + buffer.match_name = match_name; + buffer.dir_len = len; + buffer.found = 0; + dir = filp_open(dir_path, O_RDONLY, 0); + if (IS_ERR(dir)) { + DBG_DEBUG(DBG_ERROR, "filp_open error, dir path:%s\n", dir_path); + return KFILE_RV_OPEN_FAIL; + } + ret = iterate_dir(dir, &buffer.ctx); + if (buffer.found) { + DBG_DEBUG(DBG_VERBOSE, "match ok, dir name:%s\n", match_name); + filp_close(dir, NULL); + return DFD_RV_OK; + } + filp_close(dir, NULL); + return -DFD_RV_NODE_FAIL; +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_info.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_info.c new file mode 100644 index 000000000000..5cde03c5242b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_info.c @@ -0,0 +1,583 @@ +/* + * Copyright(C) 2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg_info.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + */ + +#include +#include +#include + +#include "rg_module.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_file.h" + +#define DFD_HWMON_NAME "hwmon" +#define DFD_GET_CPLD_VOLATGE_CODE_VALUE(value) ((value >> 4)& 0xfff) +#define DFD_GET_CPLD_VOLATGE_REAL_VALUE(code_val, k) ((code_val * 16 * 33 * k) / ((65536 - 5000) * 10)) + +char *g_info_ctrl_mem_str[INFO_CTRL_MEM_END] = { + ".mode", + ".int_cons", + ".src", + ".frmt", + ".pola", + ".fpath", + ".addr", + ".len", + ".bit_offset", + ".str_cons", + ".int_extra1", + ".int_extra2", +}; + +char *g_info_ctrl_mode_str[INFO_CTRL_MODE_END] = { + "none", + "config", + "constant", + "tlv", + "str_constant", +}; + +char *g_info_src_str[INFO_SRC_END] = { + "none", + "cpld", + "fpga", + "other_i2c", + "file", +}; + +char *g_info_frmt_str[INFO_FRMT_END] = { + "none", + "bit", + "byte", + "num_bytes", + "num_str", + "num_buf", + "buf", +}; + +char *g_info_pola_str[INFO_POLA_END] = { + "none", + "positive", + "negative", +}; + +static int dfd_read_info_from_cpld(int32_t addr, int read_bytes, uint8_t *val) +{ + int i, rv; + + for (i = 0; i < read_bytes; i++) { + rv = dfd_ko_cpld_read(addr, &(val[i])); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "read info[addr=0x%x read_bytes=%d] from cpld fail, reading_byte=%d rv=%d\n", + addr, read_bytes, i, rv); + return rv; + } + addr++; + } + + return read_bytes; +} + +static int dfd_write_info_to_cpld(int32_t addr, int write_bytes, uint8_t *val, uint8_t bit_mask) +{ + int rv; + uint8_t val_tmp; + + if (bit_mask != 0xff) { + rv = dfd_ko_cpld_read(addr, &val_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "read original info[addr=0x%x] from cpld fail, rv=%d\n", addr, rv); + return -1; + } + + val_tmp = (val_tmp & (~bit_mask)) | (val[0] & bit_mask); + } else { + val_tmp = val[0]; + } + + rv = dfd_ko_cpld_write(addr, val_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "write info[addr=0x%x val=0x%x] to cpld fail, rv=%d\n", addr, val_tmp, rv); + return -1; + } + + return 0; +} + +static int dfd_read_info(info_src_t src, char *fpath, int32_t addr, int read_bytes, uint8_t *val) +{ + int rv = 0; + + switch (src) { + case INFO_SRC_CPLD: + rv = dfd_read_info_from_cpld(addr, read_bytes, val); + break; + case INFO_SRC_FPGA: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support read info from fpga\n"); + break; + case INFO_SRC_OTHER_I2C: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support read info from other i2c\n"); + break; + case INFO_SRC_FILE: + rv = dfd_ko_read_file(fpath, addr, val, read_bytes); + break; + default: + rv = -1; + DBG_DEBUG(DBG_ERROR, "info src[%d] error\n", src); + break; + } + + return rv; +} + +static int dfd_write_info(info_src_t src, char *fpath, int32_t addr, int write_bytes, uint8_t *val, uint8_t bit_mask) +{ + int rv = 0; + + switch (src) { + case INFO_SRC_CPLD: + rv = dfd_write_info_to_cpld(addr, write_bytes, val, bit_mask); + break; + case INFO_SRC_FPGA: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to fpga\n"); + break; + case INFO_SRC_OTHER_I2C: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to other i2c\n"); + break; + case INFO_SRC_FILE: + rv = -1; + DBG_DEBUG(DBG_ERROR, "not support write info to file\n"); + break; + default: + rv = -1; + DBG_DEBUG(DBG_ERROR, "info src[%d] error\n", src); + break; + } + + return rv; +} + +int dfd_info_get_int(int key, int *ret, info_num_buf_to_value_f pfun) +{ + int i, rv; + int read_bytes, readed_bytes, int_tmp; + uint8_t byte_tmp, val[INFO_INT_MAX_LEN + 1] = {0}; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || (ret == NULL)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode == INFO_CTRL_MODE_CONS) { + *ret = info_ctrl->int_cons; + return DFD_RV_OK; + } else if (info_ctrl->mode == INFO_CTRL_MODE_TLV) { + return INFO_CTRL_MODE_TLV; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + if (!INFO_BIT_OFFSET_VALID(info_ctrl->bit_offset)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit_offsest[%d] invalid\n", + key, info_ctrl->bit_offset); + return -DFD_RV_TYPE_ERR; + } + + read_bytes = 1; + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt) || IS_INFO_FRMT_NUM_STR(info_ctrl->frmt) + || IS_INFO_FRMT_NUM_BUF(info_ctrl->frmt)) { + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + read_bytes = info_ctrl->len; + } else { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] info format[%d] error\n", key, info_ctrl->frmt); + return -DFD_RV_TYPE_ERR; + } + + readed_bytes = dfd_read_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, read_bytes, &(val[0])); + if (readed_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read int info[key=0x%08x src=%s frmt=%s fpath=%s addr=0x%x read_bytes=%d] fail, rv=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, read_bytes, readed_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + if (info_ctrl->pola == INFO_POLA_NEGA) { + val[0] = ~val[0]; + } + + byte_tmp = (val[0] >> info_ctrl->bit_offset) & (~(0xff << info_ctrl->len)); + + if (pfun) { + rv = pfun(&byte_tmp, sizeof(byte_tmp), &int_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit process fail, rv=%d\n", key, rv); + return rv; + } + } else { + int_tmp = (int)byte_tmp; + } + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt)) { + int_tmp = 0; + for (i = 0; i < info_ctrl->len; i++) { + if (info_ctrl->pola == INFO_POLA_NEGA) { + int_tmp |= val[info_ctrl->len - i - 1]; + } else { + int_tmp |= val[i]; + } + if (i != (info_ctrl->len - 1)) { + int_tmp <<= 8; + } + } + } else if (IS_INFO_FRMT_NUM_STR(info_ctrl->frmt)) { + val[readed_bytes] = '\0'; + int_tmp = simple_strtol((char *)(&(val[0])), NULL, 10); + } else { + if (pfun == NULL) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] number buf process function is null\n", key); + return -DFD_RV_INDEX_INVALID; + } + rv = pfun(val, readed_bytes, &int_tmp); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] number buf process fail, rv=%d\n", key, rv); + return rv; + } + } + + *ret = int_tmp; + DBG_DEBUG(DBG_VERBOSE, "read int info[key=0x%08x src=%s frmt=%s pola=%s fpath=%s addr=0x%x len=%d bit_offset=%d] success, ret=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], g_info_pola_str[info_ctrl->pola], + info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, info_ctrl->bit_offset, *ret); + return DFD_RV_OK; +} + +int dfd_info_get_buf(int key, uint8_t *buf, int buf_len, info_buf_to_buf_f pfun) +{ + int rv; + int read_bytes, buf_real_len; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || (buf == NULL)) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode != INFO_CTRL_MODE_CFG) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] mode[%d] invalid\n", key, info_ctrl->mode); + return -DFD_RV_TYPE_ERR; + } + + if (!IS_INFO_FRMT_BUF(info_ctrl->frmt) || !INFO_BUF_LEN_VALAID(info_ctrl->len) + || (buf_len <= info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] format=%d or len=%d invlaid, buf_len=%d\n", + key, info_ctrl->frmt, info_ctrl->len, buf_len); + return -DFD_RV_TYPE_ERR; + } + + read_bytes = dfd_read_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, buf_tmp); + if (read_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read buf info[key=0x%08x src=%s frmt=%s fpath=%s addr=0x%x len=%d] fail, rv=%d\n", + key, g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, info_ctrl->len, read_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] buf process fail, rv=%d\n", key, rv); + return -DFD_RV_DEV_FAIL; + } + } else { + buf_real_len = read_bytes; + memcpy(buf, buf_tmp, read_bytes); + } + + return buf_real_len; +} + +static int dfd_2key_info_get_buf(info_ctrl_t *info_ctrl, uint8_t *buf, int buf_len, info_hwmon_buf_f pfun) +{ + int rv; + int read_bytes, buf_real_len; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + char fpath[INFO_FPATH_MAX_LEN]; + int coefficient, addend; + + if (!IS_INFO_FRMT_BUF(info_ctrl->frmt) || !INFO_BUF_LEN_VALAID(info_ctrl->len) + || (buf_len <= info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "key_path info ctrl format=%d or len=%d invlaid, buf_len=%d\n", + info_ctrl->frmt, info_ctrl->len, buf_len); + return -DFD_RV_TYPE_ERR; + } + + memset(buf_tmp, 0 , sizeof(buf_tmp)); + rv = kfile_iterate_dir(info_ctrl->fpath, DFD_HWMON_NAME, buf_tmp, INFO_BUF_MAX_LEN); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "dir patch:%s, can find name %s dir \n", + info_ctrl->fpath, DFD_HWMON_NAME); + return -DFD_RV_NO_NODE; + } + memset(fpath, 0 , sizeof(fpath)); + snprintf(fpath, sizeof(fpath), "%s%s/%s", + info_ctrl->fpath, buf_tmp, info_ctrl->str_cons); + DBG_DEBUG(DBG_VERBOSE, "match ok path: %s\n", fpath); + + memset(buf_tmp, 0, sizeof(buf_tmp)); + read_bytes = dfd_read_info(info_ctrl->src, fpath, info_ctrl->addr, info_ctrl->len, buf_tmp); + if (read_bytes <= 0) { + DBG_DEBUG(DBG_ERROR, "read buf info[src: %s frmt: %s fpath: %s addr: 0x%x len: %d] fail, rv=%d\n", + g_info_src_str[info_ctrl->src], g_info_src_str[info_ctrl->frmt], fpath, + info_ctrl->addr, info_ctrl->len, read_bytes); + return -DFD_RV_DEV_FAIL; + } + + if (pfun) { + buf_real_len = buf_len; + coefficient = info_ctrl->int_extra1; + addend = info_ctrl->int_extra2; + if (coefficient != 0) { + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len, info_ctrl, coefficient, addend); + } else { + rv = pfun(buf_tmp, read_bytes, buf, &buf_real_len, info_ctrl, 1, addend); + } + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "info ctrl buf process fail, rv=%d\n", rv); + return -DFD_RV_DEV_FAIL; + } + } else { + buf_real_len = read_bytes; + memcpy(buf, buf_tmp, buf_real_len); + } + return buf_real_len; +} + +int dfd_info_set_int(int key, int val) +{ + int rv; + int write_bytes; + uint8_t byte_tmp, bit_mask; + info_ctrl_t *info_ctrl; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key))) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key=0x%08x\n", key); + return -DFD_RV_INDEX_INVALID; + } + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + if (info_ctrl->mode != INFO_CTRL_MODE_CFG) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] mode[%d] warnning\n", key, info_ctrl->mode); + return -DFD_RV_TYPE_ERR; + } + + if (IS_INFO_FRMT_BIT(info_ctrl->frmt)) { + if (!INFO_BIT_OFFSET_VALID(info_ctrl->bit_offset)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] bit_offsest[%d] invalid\n", + key, info_ctrl->bit_offset); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + + byte_tmp = (uint8_t)(val & 0xff); + byte_tmp <<= info_ctrl->bit_offset; + if (info_ctrl->pola == INFO_POLA_NEGA) { + byte_tmp = ~byte_tmp; + } + + bit_mask = (~(0xff << info_ctrl->len)) << info_ctrl->bit_offset; + } else if (IS_INFO_FRMT_BYTE(info_ctrl->frmt)) { + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + + write_bytes = 1; + byte_tmp = (uint8_t)(val & 0xff); + bit_mask = 0xff; + } else if (IS_INFO_FRMT_NUM_STR(info_ctrl->frmt)) { + DBG_DEBUG(DBG_ERROR, "not support str int set\n"); + return -1; + } else if (IS_INFO_FRMT_NUM_BUF(info_ctrl->frmt)) { + if (!INFO_INT_LEN_VALAID(info_ctrl->len)) { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] len[%d] invalid\n", key, info_ctrl->len); + return -DFD_RV_TYPE_ERR; + } + write_bytes = 1; + byte_tmp = (uint8_t)(val & 0xff); + bit_mask = 0xff; + } else { + DBG_DEBUG(DBG_ERROR, "info ctrl[key=0x%08x] format[%d] error\n", key, info_ctrl->frmt); + return -DFD_RV_TYPE_ERR; + } + + rv = dfd_write_info(info_ctrl->src, info_ctrl->fpath, info_ctrl->addr, write_bytes, + &byte_tmp, bit_mask); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "write int info[src=%s frmt=%s fpath=%s addr=0x%x len=%d val=%d] fail, rv=%d\n", + g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], info_ctrl->fpath, + info_ctrl->addr, info_ctrl->len, val, rv); + return -DFD_RV_DEV_FAIL; + } + DBG_DEBUG(DBG_VERBOSE, "write int info[src=%s frmt=%s pola=%s fpath=%s addr=0x%x len=%d bit_offset=%d val=%d] success\n", + g_info_src_str[info_ctrl->src], g_info_frmt_str[info_ctrl->frmt], g_info_pola_str[info_ctrl->pola], + info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, info_ctrl->bit_offset, val); + return DFD_RV_OK; +} + +static int dfd_info_get_cpld_voltage(int key, int *value) +{ + int rv, addr_tmp; + int vol_ref_tmp, vol_ref; + int vol_curr_tmp, vol_curr; + info_ctrl_t *info_ctrl; + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_WARN, "get info ctrl fail, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + rv = dfd_info_get_int(key, &vol_curr_tmp, NULL); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld current voltage error, addr:0x%x, rv =%d\n", info_ctrl->addr, rv); + return rv; + } + vol_curr_tmp = DFD_GET_CPLD_VOLATGE_CODE_VALUE(vol_curr_tmp); + if (info_ctrl->addr == info_ctrl->int_extra1) { + vol_curr = DFD_GET_CPLD_VOLATGE_REAL_VALUE(vol_curr_tmp, info_ctrl->int_extra2); + } else { + addr_tmp = info_ctrl->addr; + info_ctrl->addr = info_ctrl->int_extra1; + rv = dfd_info_get_int(key, &vol_ref_tmp, NULL); + info_ctrl->addr = addr_tmp; + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld reference voltage error, addr:0x%x rv:%d\n", info_ctrl->addr, rv); + return rv; + } + vol_ref = DFD_GET_CPLD_VOLATGE_CODE_VALUE(vol_ref_tmp); + vol_curr = (vol_curr_tmp * info_ctrl->int_extra2) / vol_ref; + } + *value = vol_curr; + return DFD_RV_OK; +} + +static int dfd_info_get_sensor_value(int key, uint8_t *buf, int buf_len, info_hwmon_buf_f pfun) +{ + int rv, buf_real_len; + int value; + uint8_t buf_tmp[INFO_BUF_MAX_LEN]; + info_ctrl_t *info_ctrl; + + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_DEBUG(DBG_VERBOSE, "can't find dfd config, key: 0x%08x\n", key); + return snprintf(buf, buf_len, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + if ((DFD_CFG_ITEM_ID(key) == DFD_CFG_ITEM_HWMON_IN) && (info_ctrl->src == INFO_SRC_CPLD)) { + rv = dfd_info_get_cpld_voltage(key, &value); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "get cpld voltage failed.key=0x%08x, rv:%d\n", key, rv); + return -DFD_RV_DEV_FAIL; + } + DBG_DEBUG(DBG_VERBOSE, "get cpld voltage ok, value:%d\n", value); + memset(buf_tmp, 0 ,sizeof(buf_tmp)); + snprintf(buf_tmp, sizeof(buf_tmp), "%d\n", value); + buf_real_len = strlen(buf_tmp); + if (buf_len <= buf_real_len) { + DBG_DEBUG(DBG_ERROR, "length not enough.buf_len:%d,need length:%d\n", buf_len, buf_real_len); + return -DFD_RV_DEV_FAIL; + } + if (pfun) { + buf_real_len = buf_len; + rv = pfun(buf_tmp, strlen(buf_tmp), buf, &buf_real_len, info_ctrl, 1, 0); + if (rv < 0) { + DBG_DEBUG(DBG_ERROR, "deal date error.org value:%s, buf_len:%d, rv=%d\n", + buf_tmp, buf_len, rv); + return -DFD_RV_DEV_FAIL; + } + } else { + memcpy(buf, buf_tmp, buf_real_len); + } + return buf_real_len; + } + DBG_DEBUG(DBG_ERROR, "not support mode. key: 0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; +} + +int dfd_info_get_sensor(uint32_t key, char *buf, int buf_len, info_hwmon_buf_f pfun) +{ + info_ctrl_t *key_info_ctrl; + int rv; + + if (!DFD_CFG_ITEM_IS_INFO_CTRL(DFD_CFG_ITEM_ID(key)) || + (buf == NULL) || buf_len <= 0) { + DBG_DEBUG(DBG_ERROR, "input arguments error, key: 0x%08x, buf_len: %d\n", + key, buf_len); + return -DFD_RV_INVALID_VALUE; + } + memset(buf, 0, buf_len); + key_info_ctrl = dfd_ko_cfg_get_item(key); + if (key_info_ctrl == NULL) { + DBG_DEBUG(DBG_VERBOSE, "can't find dfd config, key: 0x%08x\n", key); + return snprintf(buf, buf_len, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + if (key_info_ctrl->mode == INFO_CTRL_MODE_SRT_CONS) { + snprintf(buf, buf_len, "%s\n", key_info_ctrl->str_cons); + DBG_DEBUG(DBG_VERBOSE, "get sensor value through string config, key: 0x%08x, value: %s\n", key, buf); + return strlen(buf); + } + if (key_info_ctrl->mode == INFO_CTRL_MODE_CONS) { + snprintf(buf, buf_len, "%d\n", key_info_ctrl->int_cons); + DBG_DEBUG(DBG_VERBOSE, "get sensor value through int config, key: 0x%08x, value: %d\n", key, key_info_ctrl->int_cons); + return strlen(buf); + } + + if (key_info_ctrl->mode == INFO_CTRL_MODE_CFG && key_info_ctrl->src == INFO_SRC_FILE) { + DBG_DEBUG(DBG_VERBOSE, "get sensor value through hwmon, key: 0x%08x\n", key); + rv = dfd_2key_info_get_buf(key_info_ctrl, buf, buf_len, pfun); + if (rv < 0) { + DBG_DEBUG(DBG_VERBOSE, "get sensor value through hwmon failed, key: 0x%08x, rv: %d\n", key, rv); + } + return rv; + } + rv = dfd_info_get_sensor_value(key, buf, buf_len, pfun); + if ( rv < 0) { + DBG_DEBUG(DBG_ERROR, "get sensor value failed, key: 0x%08x, rv: %d\n", key, rv); + } + return rv; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_listnode.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_listnode.c new file mode 100644 index 000000000000..0983ed3ec70c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_cfg_listnode.c @@ -0,0 +1,95 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_cfg_listnode.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + * History + * [Version] [Author] [Date] [Description] + * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + * + */ + +#include +#include + +#include "dfd_cfg_listnode.h" + +void *lnode_find_node(lnode_root_t *root, int key) +{ + lnode_node_t *lnode; + + if (root == NULL){ + return NULL; + } + + list_for_each_entry(lnode, &(root->root), lst) { + if (lnode->key == key) { + return lnode->data; + } + } + + return NULL; +} + +int lnode_insert_node(lnode_root_t *root, int key, void *data) +{ + lnode_node_t *lnode; + void *data_tmp; + + if ((root == NULL) || (data == NULL)) { + return LNODE_RV_INPUT_ERR; + } + + data_tmp = lnode_find_node(root, key); + if (data_tmp != NULL) { + return LNODE_RV_NODE_EXIST; + } + + lnode = kmalloc(sizeof(lnode_node_t), GFP_KERNEL); + if (lnode == NULL) { + return LNODE_RV_NOMEM; + } + + lnode->key = key; + lnode->data = data; + list_add_tail(&(lnode->lst), &(root->root)); + + return LNODE_RV_OK; +} + +int lnode_init_root(lnode_root_t *root) +{ + if (root == NULL) { + return LNODE_RV_INPUT_ERR; + } + + INIT_LIST_HEAD(&(root->root)); + + return LNODE_RV_OK; +} + +void lnode_free_list(lnode_root_t *root) +{ + lnode_node_t *lnode, *lnode_next; + + if (root == NULL){ + return ; + } + + list_for_each_entry_safe(lnode, lnode_next, &(root->root), lst) { + if ( lnode->data ) { + kfree(lnode->data); + lnode->data = NULL; + lnode->key = 0; + } + list_del(&lnode->lst); + kfree(lnode); + lnode = NULL; + } + + return ; + +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_frueeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_frueeprom.c new file mode 100644 index 000000000000..8a25b5b6d94b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_frueeprom.c @@ -0,0 +1,498 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * dfd_frueeprom.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ +#include +#include +#include +#include + +#include "dfd_frueeprom.h" +#include "dfd_cfg_adapter.h" +#include "rg_module.h" + +int g_dfd_fru_dbg_level = 0; +module_param(g_dfd_fru_dbg_level, int, S_IRUGO | S_IWUSR); + +/** + * Takes the pointer to stream of bytes and length + * and returns the 8 bit checksum + * This algo is per IPMI V2.0 spec + */ +static unsigned char ipmi_calculate_crc(const unsigned char *data, size_t len) +{ + char crc = 0; + size_t byte = 0; + + for (byte = 0; byte < len; byte++) + { + crc += *data++; + } + + return(-crc); +} + +/* Validates the data for crc and mandatory fields */ +static int ipmi_verify_fru_data(const uint8_t *data, const size_t len) +{ + uint8_t checksum = 0; + int rc = -DFD_RV_TYPE_ERR; + + /* Validate for first byte to always have a value of [1] */ + if (data[0] != IPMI_FRU_HDR_BYTE_ZERO) + { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid entry:[%d] in byte-0\n",data[0]); + return rc; + } else { + DBG_FRU_DEBUG(DBG_VERBOSE, "SUCCESS: Validated [0x%X] in entry_1 of fru_data\n",data[0]); + } + + /* See if the calculated CRC matches with the embedded one. + * CRC to be calculated on all except the last one that is CRC itself.*/ + checksum = ipmi_calculate_crc(data, len - 1); + if (checksum != data[len-1]) + { + DBG_FRU_DEBUG(DBG_ERROR, "Checksum mismatch." + " Calculated:[0x%X], Embedded:[0x%X]\n", + checksum, data[len - 1]); + return rc; + } else { + DBG_FRU_DEBUG(DBG_VERBOSE, "SUCCESS: Checksum matches:[0x%X]\n",checksum); + } + + return 0; +} + +/* private method to parse type/length */ +static int ipmi_parse_type_length (const void *areabuf, + unsigned int areabuflen, + unsigned int current_area_offset, + uint8_t *number_of_data_bytes, + ipmi_fru_field_t *field) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + uint8_t type_length; + uint8_t type_code; + + type_length = areabufptr[current_area_offset]; + + /* ipmi workaround + * + * dell p weredge r610 + * + * my reading of the fru spec is that all non-custom fields are + * required to be listed by the vendor. however, on this + * motherboard, some areas list this, indicating that there is + * no more data to be parsed. so now, for "required" fields, i + * check to see if the type-length field is a sentinel before + * calling this function. + */ + + type_code = (type_length & IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK) >> IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT; + (*number_of_data_bytes) = type_length & IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK; + + /* special case: this shouldn't be a length of 0x01 (see type/length + * byte format in fru information storage definition). + */ + DBG_FRU_DEBUG(DBG_VERBOSE, "areabuflen:%d, current_area_offset:0x%x, type_code:0x%x, number_of_data_bytes:%d\n", + areabuflen, current_area_offset, type_code, *number_of_data_bytes ); + if ((current_area_offset + 1 + (*number_of_data_bytes)) > areabuflen) { + DBG_FRU_DEBUG(DBG_ERROR, "buf length error. current_area_offset:0x%x, need length:%d, total length:0x%x\n", + current_area_offset, *number_of_data_bytes, areabuflen ); + return (-1); + } + + if (field) { + memset (field->type_length_field, '\0', IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX); + memcpy (field->type_length_field, &areabufptr[current_area_offset + 1], *number_of_data_bytes); + DBG_FRU_DEBUG(DBG_VERBOSE, "fru parse ok. value:%s\n", field->type_length_field); + field->type_length_field_length = *number_of_data_bytes; + } + + return (0); +} + +static int ipmi_fru_product_info_area(const void *areabuf, + unsigned int areabuflen, ipmi_product_info_t *ipmi_product_info) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + unsigned int area_offset = 2; + uint8_t number_of_data_bytes; + int rv; + ipmi_fru_field_t **ipmi_fru_field_point; + int ipmi_fru_field_len, i; + + if (!areabuf || !areabuflen || !ipmi_product_info) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid Parameter.\n"); + return -DFD_RV_INVALID_VALUE; + } + + /* Verify the crc and size */ + rv = ipmi_verify_fru_data(areabuf, areabuflen); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate fru product info data\n"); + return rv; + } + + ipmi_fru_field_len = (sizeof(ipmi_product_info_t) - sizeof(uint8_t *)) /(sizeof(ipmi_fru_field_t *)); + + if (ipmi_product_info->language_code) { + (*ipmi_product_info->language_code) = areabufptr[area_offset]; + } + area_offset++; + ipmi_fru_field_point = (ipmi_fru_field_t **)((uint8_t *)ipmi_product_info + sizeof(uint8_t *)); + for (i = 0; i < ipmi_fru_field_len; i++) { + if (*ipmi_fru_field_point) { + memset(*ipmi_fru_field_point, '\0', sizeof(ipmi_fru_field_t)); + } + + if (((areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) && (i >= IPMI_FRU_PRODUCT_AREA_MIN_LEN)) + || (area_offset == areabuflen - 1)) { + rv = 0; + break; + } + + rv = ipmi_parse_type_length(areabufptr, areabuflen, area_offset, &number_of_data_bytes, *ipmi_fru_field_point); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "[%d] _parse_type_length area_offset[%d] rv=%d \n", i, area_offset, rv); + break; + } + + area_offset += 1; /* type/length byte */ + area_offset += number_of_data_bytes; + ipmi_fru_field_point++; + } + + return (rv); +} + +static int ipmi_fru_board_info_area(const void *areabuf, + unsigned int areabuflen, ipmi_board_info_t *ipmi_board_info) +{ + const uint8_t *areabufptr = (const uint8_t*) areabuf; + unsigned int area_offset = 2; + uint8_t number_of_data_bytes; + int rv; + ipmi_fru_field_t **ipmi_fru_field_point; + int ipmi_fru_field_len, i; + + if (!areabuf || !areabuflen || !ipmi_board_info) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid Parameter.\n"); + return -DFD_RV_INVALID_VALUE; + } + + /* Verify the crc and size */ + rv = ipmi_verify_fru_data(areabuf, areabuflen); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate fru product info data\n"); + return rv; + } + + ipmi_fru_field_len = (sizeof(ipmi_board_info_t) - sizeof(uint8_t *) - sizeof(uint8_t *)) /(sizeof(ipmi_fru_field_t *)); + + if (ipmi_board_info->language_code) { + (*ipmi_board_info->language_code) = areabufptr[area_offset]; + } + area_offset++; + + if (ipmi_board_info->mfg_time) { + memcpy(ipmi_board_info->mfg_time, &areabufptr[area_offset], IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH); + } + area_offset += IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH; + ipmi_fru_field_point = (ipmi_fru_field_t **)((uint8_t *)ipmi_board_info + sizeof(uint8_t *) + sizeof(uint8_t *)); + for (i = 0; i < ipmi_fru_field_len; i++) { + if (*ipmi_fru_field_point) { + memset(*ipmi_fru_field_point, '\0', sizeof(ipmi_fru_field_t)); + } + + if (((areabufptr[area_offset] == IPMI_FRU_SENTINEL_VALUE) && (i >= IPMI_FRU_BOARD_AREA_MIN_LEN)) + || (area_offset == areabuflen - 1)) { + rv = 0; + break; + } + + rv = ipmi_parse_type_length(areabufptr, areabuflen, area_offset, &number_of_data_bytes, *ipmi_fru_field_point); + if (rv < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "[%d] _parse_type_length area_offset[%d] rv=%d \n", i, area_offset, rv); + break; + } + + area_offset += 1; /* type/length byte */ + area_offset += number_of_data_bytes; + ipmi_fru_field_point++; + } + + return (rv); +} + +/** + * Validates the fru data per ipmi common header constructs. + * Returns with updated common_hdr and also file_size + */ +static int ipmi_validate_common_hdr(const uint8_t *fru_data, const size_t data_len) +{ + int rc = -1; + + uint8_t common_hdr[sizeof(fru_common_header_t)] = {0}; + if (data_len >= sizeof(common_hdr)) + { + memcpy(common_hdr, fru_data, sizeof(common_hdr)); + } + else + { + DBG_FRU_DEBUG(DBG_ERROR, "Incomplete fru data file. Size:[%zd]\n", data_len); + return rc; + } + + /* Verify the crc and size */ + rc = ipmi_verify_fru_data(common_hdr, sizeof(common_hdr)); + if (rc < 0) + { + DBG_FRU_DEBUG(DBG_ERROR, "Failed to validate common header\n"); + return rc; + } + + return 0; +} + +static int dfd_get_frue2prom_info(int bus, int dev_addr, fru_common_header_t *info, const char *sysfs_name) +{ + int ret; + uint8_t fru_common_header_info[sizeof(fru_common_header_t)]; + + if (info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, 0, (uint8_t *)info, sizeof(fru_common_header_t), sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom head info error(bus: %d, addr: 0x%02x).\n", bus, dev_addr); + return ret; + } + + memcpy(fru_common_header_info, (uint8_t *)info, sizeof(fru_common_header_t)); + + if (ipmi_validate_common_hdr(fru_common_header_info, sizeof(fru_common_header_t)) != 0) { + return -DFD_RV_TYPE_ERR; + } + + return DFD_RV_OK; +} + +static int dfd_set_fru_product_info(ipmi_product_info_t *ipmi_product_info, ipmi_fru_field_t *vpd_info, int type) +{ + int ret; + ret = DFD_RV_OK; + if (ipmi_product_info == NULL || vpd_info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset((uint8_t *)ipmi_product_info, 0, sizeof(ipmi_product_info_t)); + switch(type) { + case DFD_DEV_INFO_TYPE_SN: + ipmi_product_info->product_serial_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_NAME: + ipmi_product_info->product_name = vpd_info; + break; + case DFD_DEV_INFO_TYPE_DEV_TYPE: + ipmi_product_info->product_type_fields = vpd_info; + break; + case DFD_DEV_INFO_TYPE_HW_INFO: + ipmi_product_info->product_version = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NAME: + ipmi_product_info->product_part_model_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NUMBER: + ipmi_product_info->product_part_model_number = vpd_info; + break; + default: + ret = -1; + break; + } + + return ret; +} + +static int dfd_set_fru_board_info(ipmi_board_info_t *ipmi_board_info, ipmi_fru_field_t *vpd_info, int type) +{ + int ret; + ret = DFD_RV_OK; + if (ipmi_board_info == NULL || vpd_info == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + memset((uint8_t *)ipmi_board_info, 0, sizeof(ipmi_board_info_t)); + switch(type) { + case DFD_DEV_INFO_TYPE_SN: + ipmi_board_info->board_serial_number = vpd_info; + break; + case DFD_DEV_INFO_TYPE_NAME: + ipmi_board_info->board_product_name = vpd_info; + break; + case DFD_DEV_INFO_TYPE_HW_INFO: + ipmi_board_info->board_custom_fields = vpd_info; + break; + case DFD_DEV_INFO_TYPE_PART_NUMBER: + ipmi_board_info->board_part_number = vpd_info; + break; + default: + ret = -1; + break; + } + + return ret; +} + +int dfd_get_fru_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len, const char *sysfs_name) +{ + fru_common_header_t info; + uint8_t *fru_data; + int ret; + uint8_t fru_len; + ipmi_product_info_t ipmi_product_info; + ipmi_fru_field_t vpd_info; + int product_offset; + int fru_len_tmp; + + if (buf == NULL || buf_len <= 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + DBG_FRU_DEBUG(DBG_VERBOSE, "Read fru eeprom (bus: %d, addr: 0x%02x, type:%d, buf: %p, len: %d).\n", + bus, dev_addr, type, buf, buf_len); + + ret = dfd_get_frue2prom_info(bus, dev_addr, &info, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom info head error(bus: %d, addr: 0x%02x, buf: %p, len: %d).\n", + bus, dev_addr, buf, buf_len); + return ret; + } + + product_offset = info.product_offset * IPMI_EIGHT_BYTES; + ret = dfd_ko_i2c_read(bus, dev_addr, product_offset + 1, &fru_len, 1, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "read eeprom info product_offset(bus: %d, addr: 0x%02x, product offset:%d).\n", + bus, dev_addr, info.product_offset); + return -DFD_RV_DEV_FAIL; + } + + fru_len_tmp = fru_len * IPMI_EIGHT_BYTES; + fru_data = (uint8_t *)kmalloc(sizeof(uint8_t) * fru_len_tmp, GFP_KERNEL); + if (fru_data == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Allocate buffer(len:%d) error!\n", fru_len_tmp); + return -DFD_RV_NO_MEMORY; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, product_offset, fru_data, fru_len_tmp, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Get FRU data error.\n"); + kfree(fru_data); + return ret; + } + + memset((uint8_t *)&vpd_info, 0, sizeof(ipmi_fru_field_t)); + ret = dfd_set_fru_product_info(&ipmi_product_info, &vpd_info, type); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Not support to get info: %d.\n", type); + kfree(fru_data); + return ret; + } + + ret = ipmi_fru_product_info_area(fru_data, fru_len_tmp, &ipmi_product_info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "analysis FRU product info error.\n"); + kfree(fru_data); + return ret; + } + + kfree(fru_data); + + buf_len = buf_len < vpd_info.type_length_field_length ? buf_len : vpd_info.type_length_field_length; + memcpy(buf, (uint8_t *)&vpd_info, buf_len); + + return DFD_RV_OK; +} + +int dfd_get_fru_board_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len, const char *sysfs_name) +{ + fru_common_header_t info; + uint8_t *fru_data; + int ret; + uint8_t fru_len; + ipmi_board_info_t ipmi_board_info; + ipmi_fru_field_t vpd_info; + int board_offset; + int fru_len_tmp; + + if (buf == NULL || buf_len <= 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Invalid parameter!\n"); + return -DFD_RV_INVALID_VALUE; + } + + DBG_FRU_DEBUG(DBG_VERBOSE, "Read fru eeprom (bus: %d, addr: 0x%02x, type:%d, buf: %p, len: %d).\n", + bus, dev_addr, type, buf, buf_len); + + ret = dfd_get_frue2prom_info(bus, dev_addr, &info, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Read eeprom info head error(bus: %d, addr: 0x%02x, buf: %p, len: %d).\n", + bus, dev_addr, buf, buf_len); + return ret; + } + + board_offset = info.board_offset * IPMI_EIGHT_BYTES; + ret = dfd_ko_i2c_read(bus, dev_addr, board_offset + 1, &fru_len, 1, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "read eeprom info product_offset(bus: %d, addr: 0x%02x, product offset:%d).\n", + bus, dev_addr, info.board_offset); + return -DFD_RV_DEV_FAIL; + } + + fru_len_tmp = fru_len * IPMI_EIGHT_BYTES; + fru_data = (uint8_t *)kmalloc(sizeof(uint8_t) * fru_len_tmp, GFP_KERNEL); + if (fru_data == NULL) { + DBG_FRU_DEBUG(DBG_ERROR, "Allocate buffer(len:%d) error!\n", fru_len_tmp); + return -DFD_RV_NO_MEMORY; + } + + ret = dfd_ko_i2c_read(bus, dev_addr, board_offset, fru_data, fru_len_tmp, sysfs_name); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Get FRU data error.\n"); + kfree(fru_data); + return ret; + } + + memset((uint8_t *)&vpd_info, 0, sizeof(ipmi_fru_field_t)); + ret = dfd_set_fru_board_info(&ipmi_board_info, &vpd_info, type); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "Not support to get info: %d.\n", type); + kfree(fru_data); + return ret; + } + + ret = ipmi_fru_board_info_area(fru_data, fru_len_tmp, &ipmi_board_info); + if (ret < 0) { + DBG_FRU_DEBUG(DBG_ERROR, "analysis FRU product info error.\n"); + kfree(fru_data); + return ret; + } + + kfree(fru_data); + + buf_len = buf_len < vpd_info.type_length_field_length ? buf_len : vpd_info.type_length_field_length; + memcpy(buf, (uint8_t *)&vpd_info, buf_len); + + return DFD_RV_OK; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_tlveeprom.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_tlveeprom.c new file mode 100644 index 000000000000..712e2ef13d40 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/cfg/dfd_tlveeprom.c @@ -0,0 +1,443 @@ +/* + * Copyright (C) 2003-2014 FreeIPMI Core Team + * + * 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 3 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, see . + * + */ +/*****************************************************************************\ + * Copyright (C) 2007-2014 Lawrence Livermore National Security, LLC. + * Copyright (C) 2007 The Regents of the University of California. + * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). + * Written by Albert Chu + * UCRL-CODE-232183 + * + * This file is part of Ipmi-fru, a tool used for retrieving + * motherboard field replaceable unit (FRU) information. For details, + * see http://www.llnl.gov/linux/. + * + * Ipmi-fru 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 3 of the License, or (at your + * option) any later version. + * + * Ipmi-fru 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 Ipmi-fru. If not, see . +\*****************************************************************************/ +#include + +#include "dfd_tlveeprom.h" +#include "rg_module.h" + +#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) + +/* using in is_valid_tlvinfo_header */ +static uint32_t g_eeprom_size; + +/* + * 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 , "ONIE 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"}, +}; + +#define TLV_CODE_NUM (sizeof(tlv_code_list) / sizeof(tlv_code_list[0])) + +const unsigned long g_crc_table[] = { + 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 long crc, const unsigned char *buf, unsigned len) +{ + unsigned i; + if (len < 1) + return 0xffffffff; + + for (i = 0; i != len; ++i) + { + crc = g_crc_table[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); + } + + crc = crc ^ 0xffffffff; + + return crc; +} + +/* + * 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)); +} + +/* + * 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 = g_eeprom_size; + 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. + */ +static void decode_tlv_value(tlvinfo_tlv_t *tlv, tlv_decode_value_t *decode_value) +{ + int i; + char *value; + uint32_t length; + + value = (char *)decode_value->value; + + 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; + length = tlv->length; + break; + case TLV_CODE_MAC_BASE: + length = sprintf(value, "%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: + length = sprintf(value, "%u", tlv->value[0]); + break; + case TLV_CODE_MAC_SIZE: + length = sprintf(value, "%u", (tlv->value[0] << 8) | tlv->value[1]); + break; + case TLV_CODE_VENDOR_EXT: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s %02X", value, tlv->value[i]); + } + break; + case TLV_CODE_CRC_32: + length = sprintf(value, "0x%02X%02X%02X%02X", tlv->value[0], + tlv->value[1], tlv->value[2], tlv->value[3]); + break; + default: + value[0] = 0; + length = 0; + for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); i++) { + length += sprintf(value, "%s 0x%02X", value, tlv->value[i]); + } + break; + } + + decode_value->length = length; +} + +/* + * 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(uint8_t *eeprom) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_crc; + unsigned int calc_crc; + unsigned int stored_crc; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + /* 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(0xffffffffL, (const unsigned char *)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]); + + return (calc_crc == stored_crc); +} + +/* + * 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. + */ +static bool tlvinfo_find_tlv(uint8_t *eeprom, uint8_t tcode, int *eeprom_index) +{ + tlvinfo_header_t *eeprom_hdr; + tlvinfo_tlv_t *eeprom_tlv; + int eeprom_end; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + + /* 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. + */ +static bool tlvinfo_decode_tlv(uint8_t *eeprom, uint8_t tcode, tlv_decode_value_t *decode_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, decode_value); + return true; + } + + return false; +} + +/* + * parse_tlv_eeprom + * + * parse the EEPROM into memory, if it hasn't already been read. + */ +int parse_tlv_eeprom(uint8_t *eeprom, uint32_t size) +{ + unsigned int i; + bool ret; + tlvinfo_header_t *eeprom_hdr; + tlv_decode_value_t decode_value; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + g_eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv crc.\n"); + return -1; + } + + for (i = 0; i < TLV_CODE_NUM; i++) { + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = tlvinfo_decode_tlv(eeprom, tlv_code_list[i].m_code, &decode_value); + if (!ret) { + DBG_DEBUG(DBG_ERROR, "No found type: %s\n", tlv_code_list[i].m_name); + continue; + } + + DBG_DEBUG(DBG_VERBOSE, "i: %d,Found type: %s tlv[%d]:%s\n", i, tlv_code_list[i].m_name, tlv_code_list[i].m_code, + decode_value.value); + for (j = 0; j < decode_value.length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", decode_value.value[j]); + } + DBG_DEBUG(DBG_VERBOSE, "\n\n"); + } + return 0; +} +static int dfd_parse_tlv_eeprom(uint8_t *eeprom, uint32_t size, uint8_t main_type, tlv_decode_value_t *decode_value) +{ + bool ret; + tlvinfo_header_t *eeprom_hdr; + int j; + + eeprom_hdr = (tlvinfo_header_t *) eeprom; + g_eeprom_size = size; /* eeprom real size */ + + if (!is_valid_tlvinfo_header(eeprom_hdr)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv header.\n"); + return -1; + } + + if (!is_checksum_valid(eeprom)) { + DBG_DEBUG(DBG_ERROR, "Failed to check tlv crc.\n"); + return -1; + } + + ret = tlvinfo_decode_tlv(eeprom, main_type, decode_value); + if (!ret) { + DBG_DEBUG(DBG_ERROR, "No found type: %d\n", main_type); + return -1; + } + + DBG_DEBUG(DBG_VERBOSE, "Found type: %d, value: %s\n", main_type,decode_value->value); + for (j = 0; j < decode_value->length; j++) { + if ((j % 16) == 0) { + DBG_DEBUG(DBG_VERBOSE, "\n"); + } + DBG_DEBUG(DBG_VERBOSE, "%02x ", decode_value->value[j]); + } + DBG_DEBUG(DBG_VERBOSE, "\n\n"); + + return 0; +} + +int dfd_tlvinfo_get_e2prom_info(uint8_t *eeprom, uint32_t size, dfd_tlv_type_t *tlv_type, uint8_t* buf, uint32_t *buf_len) +{ + tlv_decode_value_t decode_value; + int ret; + + if (eeprom == NULL || tlv_type == NULL || buf == NULL) { + DBG_DEBUG(DBG_ERROR, "Input para invalid.\n"); + return -1; + } + + memset((void *)&decode_value, 0, sizeof(tlv_decode_value_t)); + ret = dfd_parse_tlv_eeprom(eeprom, size, tlv_type->main_type, &decode_value); + if (ret) { + DBG_DEBUG(DBG_ERROR, "dfd_parse_tlv_eeprom failed ret %d.\n", ret); + return ret; + } + + if (*buf_len >= decode_value.length) { + memcpy(buf, decode_value.value, decode_value.length); + *buf_len = decode_value.length; + return 0; + } + DBG_DEBUG(DBG_ERROR, "buf_len %d small than info_len %d.\n", *buf_len, decode_value.length); + return -1; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-CPLD.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-CPLD.cfg new file mode 100755 index 000000000000..9c8f282d444e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-CPLD.cfg @@ -0,0 +1,143 @@ +other_i2c_dev.bus_0_0=1 +other_i2c_dev.addr_0_0=0x56 + +eeprom_path_0_0=/sys/bus/i2c/devices/1-0056/eeprom + +eeprom_size_0_0=256 + +watchdog_id_0=0 + +watchdog_name_0_0=identity +watchdog_name_0_1=state +watchdog_name_0_2=timeleft +watchdog_name_0_3=timeout + +cpld_i2c_dev.bus_0_2=2 +cpld_i2c_dev.addr_0_2=0x1d +cpld_i2c_dev.bus_0_3=2 +cpld_i2c_dev.addr_0_3=0x2d +cpld_i2c_dev.bus_0_4=4 +cpld_i2c_dev.addr_0_4=0x3d + +cpld_lpc_dev_0_0=0x700 +cpld_lpc_dev_0_1=0x900 + +mode_cpld_0_0=lpc +mode_cpld_0_1=lpc +mode_cpld_0_2=i2c +mode_cpld_0_3=i2c +mode_cpld_0_4=i2c + +dev_num_0_8=5 + +cpld_name_0_0=CPU_CPLD +cpld_name_0_1=BASE_CPLD +cpld_name_0_2=MAC_CPLDA +cpld_name_0_3=MAC_CPLDB +cpld_name_0_4=FAN_CPLD + +cpld_type_0_0=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_1=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_2=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_3=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_4=LATTICE/LCMXO3LF-2100C-5BG256C + +cpld_version.mode_0_0=config +cpld_version.int_cons_0_0= +cpld_version.src_0_0=cpld +cpld_version.frmt_0_0=num_bytes +cpld_version.pola_0_0= +cpld_version.fpath_0_0= +cpld_version.addr_0_0=0x00000000 +cpld_version.len_0_0=4 +cpld_version.bit_offset_0_0= + +cpld_version.mode_0_1=config +cpld_version.int_cons_0_1= +cpld_version.src_0_1=cpld +cpld_version.frmt_0_1=num_bytes +cpld_version.pola_0_1= +cpld_version.fpath_0_1= +cpld_version.addr_0_1=0x00010000 +cpld_version.len_0_1=4 +cpld_version.bit_offset_0_1= + +cpld_version.mode_0_2=config +cpld_version.int_cons_0_2= +cpld_version.src_0_2=cpld +cpld_version.frmt_0_2=num_bytes +cpld_version.pola_0_2= +cpld_version.fpath_0_2= +cpld_version.addr_0_2=0x00020000 +cpld_version.len_0_2=4 +cpld_version.bit_offset_0_2= + +cpld_version.mode_0_3=config +cpld_version.int_cons_0_3= +cpld_version.src_0_3=cpld +cpld_version.frmt_0_3=num_bytes +cpld_version.pola_0_3= +cpld_version.fpath_0_3= +cpld_version.addr_0_3=0x00030000 +cpld_version.len_0_3=4 +cpld_version.bit_offset_0_3= + +cpld_version.mode_0_4=config +cpld_version.int_cons_0_4= +cpld_version.src_0_4=cpld +cpld_version.frmt_0_4=num_bytes +cpld_version.pola_0_4= +cpld_version.fpath_0_4= +cpld_version.addr_0_4=0x00040000 +cpld_version.len_0_4=4 +cpld_version.bit_offset_0_4= + +cpld_test_reg.mode_0_0=config +cpld_test_reg.int_cons_0_0= +cpld_test_reg.src_0_0=cpld +cpld_test_reg.frmt_0_0=byte +cpld_test_reg.pola_0_0= +cpld_test_reg.fpath_0_0= +cpld_test_reg.addr_0_0=0x00000005 +cpld_test_reg.len_0_0=1 +cpld_test_reg.bit_offset_0_0= + +cpld_test_reg.mode_0_1=config +cpld_test_reg.int_cons_0_1= +cpld_test_reg.src_0_1=cpld +cpld_test_reg.frmt_0_1=byte +cpld_test_reg.pola_0_1= +cpld_test_reg.fpath_0_1= +cpld_test_reg.addr_0_1=0x000100aa +cpld_test_reg.len_0_1=1 +cpld_test_reg.bit_offset_0_1= + +cpld_test_reg.mode_0_2=config +cpld_test_reg.int_cons_0_2= +cpld_test_reg.src_0_2=cpld +cpld_test_reg.frmt_0_2=byte +cpld_test_reg.pola_0_2= +cpld_test_reg.fpath_0_2= +cpld_test_reg.addr_0_2=0x000200aa +cpld_test_reg.len_0_2=1 +cpld_test_reg.bit_offset_0_2= + +cpld_test_reg.mode_0_3=config +cpld_test_reg.int_cons_0_3= +cpld_test_reg.src_0_3=cpld +cpld_test_reg.frmt_0_3=byte +cpld_test_reg.pola_0_3= +cpld_test_reg.fpath_0_3= +cpld_test_reg.addr_0_3=0x000300aa +cpld_test_reg.len_0_3=1 +cpld_test_reg.bit_offset_0_3= + +cpld_test_reg.mode_0_4=config +cpld_test_reg.int_cons_0_4= +cpld_test_reg.src_0_4=cpld +cpld_test_reg.frmt_0_4=byte +cpld_test_reg.pola_0_4= +cpld_test_reg.fpath_0_4= +cpld_test_reg.addr_0_4=0x000400aa +cpld_test_reg.len_0_4=1 +cpld_test_reg.bit_offset_0_4= diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FAN.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FAN.cfg new file mode 100755 index 000000000000..7017f26e52d0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FAN.cfg @@ -0,0 +1,386 @@ +other_i2c_dev.bus_1_1=35 +other_i2c_dev.addr_1_1=0x50 +other_i2c_dev.bus_1_2=34 +other_i2c_dev.addr_1_2=0x50 +other_i2c_dev.bus_1_3=33 +other_i2c_dev.addr_1_3=0x50 +other_i2c_dev.bus_1_4=32 +other_i2c_dev.addr_1_4=0x50 +other_i2c_dev.bus_1_5=31 +other_i2c_dev.addr_1_5=0x50 +other_i2c_dev.bus_1_6=30 +other_i2c_dev.addr_1_6=0x50 + +# fan number +dev_num_1_0=6 + +# fan motor number +dev_num_1_5=2 + +fan_e2_mode=fru + +fan_sysfs_name=eeprom + +fan_direction_0_1=FAN24K4056-F +fan_direction_1_1=FAN24K4056-R + +dev_present_status.mode_1_1=config +dev_present_status.src_1_1=cpld +dev_present_status.frmt_1_1=bit +dev_present_status.pola_1_1=negative +dev_present_status.addr_1_1=0x00040037 +dev_present_status.len_1_1=1 +dev_present_status.bit_offset_1_1=5 + +dev_present_status.mode_1_2=config +dev_present_status.src_1_2=cpld +dev_present_status.frmt_1_2=bit +dev_present_status.pola_1_2=negative +dev_present_status.addr_1_2=0x00040037 +dev_present_status.len_1_2=1 +dev_present_status.bit_offset_1_2=4 + +dev_present_status.mode_1_3=config +dev_present_status.src_1_3=cpld +dev_present_status.frmt_1_3=bit +dev_present_status.pola_1_3=negative +dev_present_status.addr_1_3=0x00040037 +dev_present_status.len_1_3=1 +dev_present_status.bit_offset_1_3=3 + +dev_present_status.mode_1_4=config +dev_present_status.src_1_4=cpld +dev_present_status.frmt_1_4=bit +dev_present_status.pola_1_4=negative +dev_present_status.addr_1_4=0x00040037 +dev_present_status.len_1_4=1 +dev_present_status.bit_offset_1_4=2 + +dev_present_status.mode_1_5=config +dev_present_status.src_1_5=cpld +dev_present_status.frmt_1_5=bit +dev_present_status.pola_1_5=negative +dev_present_status.addr_1_5=0x00040037 +dev_present_status.len_1_5=1 +dev_present_status.bit_offset_1_5=1 + +dev_present_status.mode_1_6=config +dev_present_status.src_1_6=cpld +dev_present_status.frmt_1_6=bit +dev_present_status.pola_1_6=negative +dev_present_status.addr_1_6=0x00040037 +dev_present_status.len_1_6=1 +dev_present_status.bit_offset_1_6=0 + +fan_roll_status.mode_1_1=config +fan_roll_status.int_cons_1_1= +fan_roll_status.src_1_1=cpld +fan_roll_status.frmt_1_1=bit +fan_roll_status.pola_1_1=positive +fan_roll_status.fpath_1_1= +fan_roll_status.addr_1_1=0x00040038 +fan_roll_status.len_1_1=1 +fan_roll_status.bit_offset_1_1=5 + +fan_roll_status.mode_1_2=config +fan_roll_status.int_cons_1_2= +fan_roll_status.src_1_2=cpld +fan_roll_status.frmt_1_2=bit +fan_roll_status.pola_1_2=positive +fan_roll_status.fpath_1_2= +fan_roll_status.addr_1_2=0x00040039 +fan_roll_status.len_1_2=1 +fan_roll_status.bit_offset_1_2=5 + +fan_roll_status.mode_2_1=config +fan_roll_status.int_cons_2_1= +fan_roll_status.src_2_1=cpld +fan_roll_status.frmt_2_1=bit +fan_roll_status.pola_2_1=positive +fan_roll_status.fpath_2_1= +fan_roll_status.addr_2_1=0x00040038 +fan_roll_status.len_2_1=1 +fan_roll_status.bit_offset_2_1=4 + +fan_roll_status.mode_2_2=config +fan_roll_status.int_cons_2_2= +fan_roll_status.src_2_2=cpld +fan_roll_status.frmt_2_2=bit +fan_roll_status.pola_2_2=positive +fan_roll_status.fpath_2_2= +fan_roll_status.addr_2_2=0x00040039 +fan_roll_status.len_2_2=1 +fan_roll_status.bit_offset_2_2=4 + +fan_roll_status.mode_3_1=config +fan_roll_status.int_cons_3_1= +fan_roll_status.src_3_1=cpld +fan_roll_status.frmt_3_1=bit +fan_roll_status.pola_3_1=positive +fan_roll_status.fpath_3_1= +fan_roll_status.addr_3_1=0x00040038 +fan_roll_status.len_3_1=1 +fan_roll_status.bit_offset_3_1=3 + +fan_roll_status.mode_3_2=config +fan_roll_status.int_cons_3_2= +fan_roll_status.src_3_2=cpld +fan_roll_status.frmt_3_2=bit +fan_roll_status.pola_3_2=positive +fan_roll_status.fpath_3_2= +fan_roll_status.addr_3_2=0x00040039 +fan_roll_status.len_3_2=1 +fan_roll_status.bit_offset_3_2=3 + +fan_roll_status.mode_4_1=config +fan_roll_status.int_cons_4_1= +fan_roll_status.src_4_1=cpld +fan_roll_status.frmt_4_1=bit +fan_roll_status.pola_4_1=positive +fan_roll_status.fpath_4_1= +fan_roll_status.addr_4_1=0x00040038 +fan_roll_status.len_4_1=1 +fan_roll_status.bit_offset_4_1=2 + +fan_roll_status.mode_4_2=config +fan_roll_status.int_cons_4_2= +fan_roll_status.src_4_2=cpld +fan_roll_status.frmt_4_2=bit +fan_roll_status.pola_4_2=positive +fan_roll_status.fpath_4_2= +fan_roll_status.addr_4_2=0x00040039 +fan_roll_status.len_4_2=1 +fan_roll_status.bit_offset_4_2=2 + +fan_roll_status.mode_5_1=config +fan_roll_status.int_cons_5_1= +fan_roll_status.src_5_1=cpld +fan_roll_status.frmt_5_1=bit +fan_roll_status.pola_5_1=positive +fan_roll_status.fpath_5_1= +fan_roll_status.addr_5_1=0x00040038 +fan_roll_status.len_5_1=1 +fan_roll_status.bit_offset_5_1=1 + +fan_roll_status.mode_5_2=config +fan_roll_status.int_cons_5_2= +fan_roll_status.src_5_2=cpld +fan_roll_status.frmt_5_2=bit +fan_roll_status.pola_5_2=positive +fan_roll_status.fpath_5_2= +fan_roll_status.addr_5_2=0x00040039 +fan_roll_status.len_5_2=1 +fan_roll_status.bit_offset_5_2=1 + +fan_roll_status.mode_6_1=config +fan_roll_status.int_cons_6_1= +fan_roll_status.src_6_1=cpld +fan_roll_status.frmt_6_1=bit +fan_roll_status.pola_6_1=positive +fan_roll_status.fpath_6_1= +fan_roll_status.addr_6_1=0x00040038 +fan_roll_status.len_6_1=1 +fan_roll_status.bit_offset_6_1=0 + +fan_roll_status.mode_6_2=config +fan_roll_status.int_cons_6_2= +fan_roll_status.src_6_2=cpld +fan_roll_status.frmt_6_2=bit +fan_roll_status.pola_6_2=positive +fan_roll_status.fpath_6_2= +fan_roll_status.addr_6_2=0x00040039 +fan_roll_status.len_6_2=1 +fan_roll_status.bit_offset_6_2=0 + +fan_speed.mode_1_1=config +fan_speed.int_cons_1_1= +fan_speed.src_1_1=cpld +fan_speed.frmt_1_1=num_bytes +fan_speed.pola_1_1=negative +fan_speed.fpath_1_1= +fan_speed.addr_1_1=0x00040070 +fan_speed.len_1_1=2 +fan_speed.bit_offset_1_1= + +fan_speed.mode_1_2=config +fan_speed.int_cons_1_2= +fan_speed.src_1_2=cpld +fan_speed.frmt_1_2=num_bytes +fan_speed.pola_1_2=negative +fan_speed.fpath_1_2= +fan_speed.addr_1_2=0x0004007c +fan_speed.len_1_2=2 +fan_speed.bit_offset_1_2= + +fan_speed.mode_2_1=config +fan_speed.int_cons_2_1= +fan_speed.src_2_1=cpld +fan_speed.frmt_2_1=num_bytes +fan_speed.pola_2_1=negative +fan_speed.fpath_2_1= +fan_speed.addr_2_1=0x0004006e +fan_speed.len_2_1=2 +fan_speed.bit_offset_2_1= + +fan_speed.mode_2_2=config +fan_speed.int_cons_2_2= +fan_speed.src_2_2=cpld +fan_speed.frmt_2_2=num_bytes +fan_speed.pola_2_2=negative +fan_speed.fpath_2_2= +fan_speed.addr_2_2=0x0004007a +fan_speed.len_2_2=2 +fan_speed.bit_offset_2_2= + +fan_speed.mode_3_1=config +fan_speed.int_cons_3_1= +fan_speed.src_3_1=cpld +fan_speed.frmt_3_1=num_bytes +fan_speed.pola_3_1=negative +fan_speed.fpath_3_1= +fan_speed.addr_3_1=0x0004006c +fan_speed.len_3_1=2 +fan_speed.bit_offset_3_1= + +fan_speed.mode_3_2=config +fan_speed.int_cons_3_2= +fan_speed.src_3_2=cpld +fan_speed.frmt_3_2=num_bytes +fan_speed.pola_3_2=negative +fan_speed.fpath_3_2= +fan_speed.addr_3_2=0x00040078 +fan_speed.len_3_2=2 +fan_speed.bit_offset_3_2= + +fan_speed.mode_4_1=config +fan_speed.int_cons_4_1= +fan_speed.src_4_1=cpld +fan_speed.frmt_4_1=num_bytes +fan_speed.pola_4_1=negative +fan_speed.fpath_4_1= +fan_speed.addr_4_1=0x0004006a +fan_speed.len_4_1=2 +fan_speed.bit_offset_4_1= + +fan_speed.mode_4_2=config +fan_speed.int_cons_4_2= +fan_speed.src_4_2=cpld +fan_speed.frmt_4_2=num_bytes +fan_speed.pola_4_2=negative +fan_speed.fpath_4_2= +fan_speed.addr_4_2=0x00040076 +fan_speed.len_4_2=2 +fan_speed.bit_offset_4_2= + +fan_speed.mode_5_1=config +fan_speed.int_cons_5_1= +fan_speed.src_5_1=cpld +fan_speed.frmt_5_1=num_bytes +fan_speed.pola_5_1=negative +fan_speed.fpath_5_1= +fan_speed.addr_5_1=0x00040068 +fan_speed.len_5_1=2 +fan_speed.bit_offset_5_1= + +fan_speed.mode_5_2=config +fan_speed.int_cons_5_2= +fan_speed.src_5_2=cpld +fan_speed.frmt_5_2=num_bytes +fan_speed.pola_5_2=negative +fan_speed.fpath_5_2= +fan_speed.addr_5_2=0x00040074 +fan_speed.len_5_2=2 +fan_speed.bit_offset_5_2= + +fan_speed.mode_6_1=config +fan_speed.int_cons_6_1= +fan_speed.src_6_1=cpld +fan_speed.frmt_6_1=num_bytes +fan_speed.pola_6_1=negative +fan_speed.fpath_6_1= +fan_speed.addr_6_1=0x00040066 +fan_speed.len_6_1=2 +fan_speed.bit_offset_6_1= + +fan_speed.mode_6_2=config +fan_speed.int_cons_6_2= +fan_speed.src_6_2=cpld +fan_speed.frmt_6_2=num_bytes +fan_speed.pola_6_2=negative +fan_speed.fpath_6_2= +fan_speed.addr_6_2=0x00040072 +fan_speed.len_6_2=2 +fan_speed.bit_offset_6_2= + +fan_ratio.mode_1=config +fan_ratio.int_cons_1= +fan_ratio.src_1=cpld +fan_ratio.frmt_1=byte +fan_ratio.pola_1= +fan_ratio.fpath_1= +fan_ratio.addr_1=0x00040065 +fan_ratio.len_1=1 +fan_ratio.bit_offset_1= + +fan_ratio.mode_2=config +fan_ratio.int_cons_2= +fan_ratio.src_2=cpld +fan_ratio.frmt_2=byte +fan_ratio.pola_2= +fan_ratio.fpath_2= +fan_ratio.addr_2=0x00040064 +fan_ratio.len_2=1 +fan_ratio.bit_offset_2= + +fan_ratio.mode_3=config +fan_ratio.int_cons_3= +fan_ratio.src_3=cpld +fan_ratio.frmt_3=byte +fan_ratio.pola_3= +fan_ratio.fpath_3= +fan_ratio.addr_3=0x00040063 +fan_ratio.len_3=1 +fan_ratio.bit_offset_3= + +fan_ratio.mode_4=config +fan_ratio.int_cons_4= +fan_ratio.src_4=cpld +fan_ratio.frmt_4=byte +fan_ratio.pola_4= +fan_ratio.fpath_4= +fan_ratio.addr_4=0x00040062 +fan_ratio.len_4=1 +fan_ratio.bit_offset_4= + +fan_ratio.mode_5=config +fan_ratio.int_cons_5= +fan_ratio.src_5=cpld +fan_ratio.frmt_5=byte +fan_ratio.pola_5= +fan_ratio.fpath_5= +fan_ratio.addr_5=0x00040061 +fan_ratio.len_5=1 +fan_ratio.bit_offset_5= + +fan_ratio.mode_6=config +fan_ratio.int_cons_6= +fan_ratio.src_6=cpld +fan_ratio.frmt_6=byte +fan_ratio.pola_6= +fan_ratio.fpath_6= +fan_ratio.addr_6=0x00040060 +fan_ratio.len_6=1 +fan_ratio.bit_offset_6= + +# display fan name number +dev_num_1_7=2 + +fan_type_num_1=2 +fan_type_num_2=1 + +fan_name_1_1=FAN24K4056-F +fan_name_1_2=FAN24K4056S-F +fan_name_2_1=FAN24K4056S-R + +decode_fan_name_1=FAN24K4056-F +decode_fan_name_2=FAN24K4056-R \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FPGA.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FPGA.cfg new file mode 100755 index 000000000000..b6d1887ef327 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-FPGA.cfg @@ -0,0 +1,41 @@ +# FPGA number +dev_num_0_9=1 + +fpga_name_0_0=MAC_FPGA + + +fpga_version.mode_0_0=config +fpga_version.int_cons_0_0= +fpga_version.src_0_0=file +fpga_version.frmt_0_0=num_bytes +fpga_version.pola_0_0=negative +fpga_version.fpath_0_0=/dev/fpga0 +fpga_version.addr_0_0=0x0 +fpga_version.len_0_0=4 +fpga_version.bit_offset_0_0= + + +fpga_test_reg.mode_0_0=config +fpga_test_reg.int_cons_0_0= +fpga_test_reg.src_0_0=file +fpga_test_reg.frmt_0_0=num_bytes +fpga_test_reg.pola_0_0=negative +fpga_test_reg.fpath_0_0=/dev/fpga0 +fpga_test_reg.addr_0_0=0x08 +fpga_test_reg.len_0_0=4 +fpga_test_reg.bit_offset_0_0= + + +fpga_model_reg.mode_0_0=config +fpga_model_reg.int_cons_0_0= +fpga_model_reg.src_0_0=file +fpga_model_reg.frmt_0_0=num_bytes +fpga_model_reg.pola_0_0=negative +fpga_model_reg.fpath_0_0=/dev/fpga0 +fpga_model_reg.addr_0_0=0xd8 +fpga_model_reg.len_0_0=4 +fpga_model_reg.bit_offset_0_0= + + +fpga_model_decode_0x0=XC7A100T-2FGG484C +fpga_model_decode_0x200=XC7A200T-2FBG484I diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-LED.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-LED.cfg new file mode 100755 index 000000000000..b365acd11ba5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-LED.cfg @@ -0,0 +1,89 @@ +led_status.mode_0_0=config +led_status.src_0_0=cpld +led_status.frmt_0_0=bit +led_status.addr_0_0=0x00030040 +led_status.len_0_0=3 + +led_status_decode_0_0=0 +led_status_decode_0_1=7 +led_status_decode_0_2=3 +led_status_decode_0_3=5 +led_status_decode_0_4=1 +led_status_decode_0_5=6 +led_status_decode_0_6=2 +led_status_decode_0_7=0 + +led_status.mode_4_0=config +led_status.src_4_0=cpld +led_status.frmt_4_0=bit +led_status.addr_4_0=0x00030042 +led_status.len_4_0=3 + +led_status_decode_4_0=0 +led_status_decode_4_1=7 +led_status_decode_4_2=3 +led_status_decode_4_3=5 +led_status_decode_4_4=1 +led_status_decode_4_5=6 +led_status_decode_4_6=2 +led_status_decode_4_7=0 + +led_status.mode_6_0=config +led_status.src_6_0=cpld +led_status.frmt_6_0=bit +led_status.addr_6_0=0x00030043 +led_status.len_6_0=3 + +led_status_decode_6_0=0 +led_status_decode_6_1=7 +led_status_decode_6_2=3 +led_status_decode_6_3=5 +led_status_decode_6_4=1 +led_status_decode_6_5=6 +led_status_decode_6_6=2 +led_status_decode_6_7=0 + +led_status.mode_10_1=config +led_status.src_10_1=cpld +led_status.frmt_10_1=bit +led_status.addr_10_1=0x00040041 +led_status.len_10_1=3 + +led_status.mode_10_2=config +led_status.src_10_2=cpld +led_status.frmt_10_2=bit +led_status.addr_10_2=0x00040040 +led_status.len_10_2=3 + +led_status.mode_10_3=config +led_status.src_10_3=cpld +led_status.frmt_10_3=bit +led_status.addr_10_3=0x0004003f +led_status.len_10_3=3 + +led_status.mode_10_4=config +led_status.src_10_4=cpld +led_status.frmt_10_4=bit +led_status.addr_10_4=0x0004003e +led_status.len_10_4=3 + +led_status.mode_10_5=config +led_status.src_10_5=cpld +led_status.frmt_10_5=bit +led_status.addr_10_5=0x0004003d +led_status.len_10_5=3 + +led_status.mode_10_6=config +led_status.src_10_6=cpld +led_status.frmt_10_6=bit +led_status.addr_10_6=0x0004003c +led_status.len_10_6=3 + +led_status_decode_10_0=0 +led_status_decode_10_1=7 +led_status_decode_10_2=3 +led_status_decode_10_3=5 +led_status_decode_10_4=1 +led_status_decode_10_5=6 +led_status_decode_10_6=2 +led_status_decode_10_7=0 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-PSU.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-PSU.cfg new file mode 100755 index 000000000000..be125d484f18 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-PSU.cfg @@ -0,0 +1,325 @@ +# psu number +dev_num_2_0=2 + +# psu temp number +dev_num_2_1=3 + +other_i2c_dev.bus_2_1=41 +other_i2c_dev.addr_2_1=0x50 +other_i2c_dev.bus_2_2=42 +other_i2c_dev.addr_2_2=0x50 + +psu_pmbus_id_1_11=0x29005880 +psu_pmbus_id_2_11=0x2a005880 + +psu_status.mode_1_0=config +psu_status.src_1_0=cpld +psu_status.frmt_1_0=bit +psu_status.pola_1_0=negative +psu_status.addr_1_0=0x00020034 +psu_status.len_1_0=1 +psu_status.bit_offset_1_0=0 + +psu_status.mode_1_1=config +psu_status.src_1_1=cpld +psu_status.frmt_1_1=bit +psu_status.pola_1_1=positive +psu_status.addr_1_1=0x00020034 +psu_status.len_1_1=1 +psu_status.bit_offset_1_1=1 + +psu_status.mode_1_2=config +psu_status.src_1_2=cpld +psu_status.frmt_1_2=bit +psu_status.pola_1_2=positive +psu_status.addr_1_2=0x00020034 +psu_status.len_1_2=1 +psu_status.bit_offset_1_2=2 + +psu_status.mode_2_0=config +psu_status.src_2_0=cpld +psu_status.frmt_2_0=bit +psu_status.pola_2_0=negative +psu_status.addr_2_0=0x00020034 +psu_status.len_2_0=1 +psu_status.bit_offset_2_0=4 + +psu_status.mode_2_1=config +psu_status.src_2_1=cpld +psu_status.frmt_2_1=bit +psu_status.pola_2_1=positive +psu_status.addr_2_1=0x00020034 +psu_status.len_2_1=1 +psu_status.bit_offset_2_1=5 + +psu_status.mode_2_2=config +psu_status.src_2_2=cpld +psu_status.frmt_2_2=bit +psu_status.pola_2_2=positive +psu_status.addr_2_2=0x00020034 +psu_status.len_2_2=1 +psu_status.bit_offset_2_2=6 + +# 0:None 1:in_vol 2:in_curr 3:in_power 4:out_vol 5:out_curr 6:out_power 7:fan +# psu1 in_vol +hwmon_psu.mode_1_1=config +hwmon_psu.int_cons_1_1=0 +hwmon_psu.src_1_1=file +hwmon_psu.frmt_1_1=buf +hwmon_psu.fpath_1_1=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_1=0 +hwmon_psu.len_1_1=8 +hwmon_psu.bit_offset_1_1= +hwmon_psu.str_cons_1_1=in1_input + +# psu1 in_curr +hwmon_psu.mode_1_2=config +hwmon_psu.int_cons_1_2=0 +hwmon_psu.src_1_2=file +hwmon_psu.frmt_1_2=buf +hwmon_psu.fpath_1_2=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_2=0 +hwmon_psu.len_1_2=8 +hwmon_psu.bit_offset_1_2= +hwmon_psu.str_cons_1_2=curr1_input + +# psu1 in_power +hwmon_psu.mode_1_3=config +hwmon_psu.int_cons_1_3=0 +hwmon_psu.src_1_3=file +hwmon_psu.frmt_1_3=buf +hwmon_psu.fpath_1_3=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_3=0 +hwmon_psu.len_1_3=16 +hwmon_psu.bit_offset_1_3= +hwmon_psu.str_cons_1_3=power1_input + +# psu1 out_vol +hwmon_psu.mode_1_4=config +hwmon_psu.int_cons_1_4=0 +hwmon_psu.src_1_4=file +hwmon_psu.frmt_1_4=buf +hwmon_psu.fpath_1_4=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_4=0 +hwmon_psu.len_1_4=8 +hwmon_psu.bit_offset_1_4= +hwmon_psu.str_cons_1_4=in2_input + +# psu1 out_curr +hwmon_psu.mode_1_5=config +hwmon_psu.int_cons_1_5=0 +hwmon_psu.src_1_5=file +hwmon_psu.frmt_1_5=buf +hwmon_psu.fpath_1_5=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_5=0 +hwmon_psu.len_1_5=8 +hwmon_psu.bit_offset_1_5= +hwmon_psu.str_cons_1_5=curr2_input + +# psu1 out_power +hwmon_psu.mode_1_6=config +hwmon_psu.int_cons_1_6=0 +hwmon_psu.src_1_6=file +hwmon_psu.frmt_1_6=buf +hwmon_psu.fpath_1_6=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_6=0 +hwmon_psu.len_1_6=16 +hwmon_psu.bit_offset_1_6= +hwmon_psu.str_cons_1_6=power2_input + +# psu1 fan +hwmon_psu.mode_1_7=config +hwmon_psu.int_cons_1_7= +hwmon_psu.src_1_7=file +hwmon_psu.frmt_1_7=buf +hwmon_psu.fpath_1_7=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_psu.addr_1_7=0 +hwmon_psu.len_1_7=8 +hwmon_psu.bit_offset_1_7= +hwmon_psu.str_cons_1_7=fan1_input + +# psu2 in_vol +hwmon_psu.mode_2_1=config +hwmon_psu.int_cons_2_1=0 +hwmon_psu.src_2_1=file +hwmon_psu.frmt_2_1=buf +hwmon_psu.fpath_2_1=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_1=0 +hwmon_psu.len_2_1=8 +hwmon_psu.bit_offset_2_1= +hwmon_psu.str_cons_2_1=in1_input + +# psu2 in_curr +hwmon_psu.mode_2_2=config +hwmon_psu.int_cons_2_2=0 +hwmon_psu.src_2_2=file +hwmon_psu.frmt_2_2=buf +hwmon_psu.fpath_2_2=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_2=0 +hwmon_psu.len_2_2=8 +hwmon_psu.bit_offset_2_2= +hwmon_psu.str_cons_2_2=curr1_input + +# psu2 in_power +hwmon_psu.mode_2_3=config +hwmon_psu.int_cons_2_3=0 +hwmon_psu.src_2_3=file +hwmon_psu.frmt_2_3=buf +hwmon_psu.fpath_2_3=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_3=0 +hwmon_psu.len_2_3=16 +hwmon_psu.bit_offset_2_3= +hwmon_psu.str_cons_2_3=power1_input + +# psu2 out_vol +hwmon_psu.mode_2_4=config +hwmon_psu.int_cons_2_4=0 +hwmon_psu.src_2_4=file +hwmon_psu.frmt_2_4=buf +hwmon_psu.fpath_2_4=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_4=0 +hwmon_psu.len_2_4=8 +hwmon_psu.bit_offset_2_4= +hwmon_psu.str_cons_2_4=in2_input + +# psu2 out_curr +hwmon_psu.mode_2_5=config +hwmon_psu.int_cons_2_5=0 +hwmon_psu.src_2_5=file +hwmon_psu.frmt_2_5=buf +hwmon_psu.fpath_2_5=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_5=0 +hwmon_psu.len_2_5=8 +hwmon_psu.bit_offset_2_5= +hwmon_psu.str_cons_2_5=curr2_input + +# psu2 out_power +hwmon_psu.mode_2_6=config +hwmon_psu.int_cons_2_6=0 +hwmon_psu.src_2_6=file +hwmon_psu.frmt_2_6=buf +hwmon_psu.fpath_2_6=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_6=0 +hwmon_psu.len_2_6=16 +hwmon_psu.bit_offset_2_6= +hwmon_psu.str_cons_2_6=power2_input + +# psu2 fan +hwmon_psu.mode_2_7=config +hwmon_psu.int_cons_2_7= +hwmon_psu.src_2_7=file +hwmon_psu.frmt_2_7=buf +hwmon_psu.fpath_2_7=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_psu.addr_2_7=0 +hwmon_psu.len_2_7=8 +hwmon_psu.bit_offset_2_7= +hwmon_psu.str_cons_2_7=fan1_input + +# 2:type 3:max 4:max_hyst 5:min 6:crit + +# psu1 temp1 input +hwmon_temp.mode_0x0101_0x20=config +hwmon_temp.int_cons_0x0101_0x20=0 +hwmon_temp.src_0x0101_0x20=file +hwmon_temp.frmt_0x0101_0x20=buf +hwmon_temp.fpath_0x0101_0x20=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_temp.addr_0x0101_0x20=0 +hwmon_temp.len_0x0101_0x20=8 +hwmon_temp.bit_offset_0x0101_0x20= +hwmon_temp.str_cons_0x0101_0x20=temp1_input + +# psu1 temp1 alias +hwmon_temp.mode_0x0101_0x21=str_constant +hwmon_temp.str_cons_0x0101_0x21=temp1 + +# psu1 temp2 input +hwmon_temp.mode_0x0102_0x20=config +hwmon_temp.int_cons_0x0102_0x20=0 +hwmon_temp.src_0x0102_0x20=file +hwmon_temp.frmt_0x0102_0x20=buf +hwmon_temp.fpath_0x0102_0x20=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_temp.addr_0x0102_0x20=0 +hwmon_temp.len_0x0102_0x20=8 +hwmon_temp.bit_offset_0x0102_0x20= +hwmon_temp.str_cons_0x0102_0x20=temp2_input + +# psu1 temp2 alias +hwmon_temp.mode_0x0102_0x21=str_constant +hwmon_temp.str_cons_0x0102_0x21=temp2 + +# psu1 temp3 input +hwmon_temp.mode_0x0103_0x20=config +hwmon_temp.int_cons_0x0103_0x20=0 +hwmon_temp.src_0x0103_0x20=file +hwmon_temp.frmt_0x0103_0x20=buf +hwmon_temp.fpath_0x0103_0x20=/sys/bus/i2c/devices/41-0058/hwmon/ +hwmon_temp.addr_0x0103_0x20=0 +hwmon_temp.len_0x0103_0x20=8 +hwmon_temp.bit_offset_0x0103_0x20= +hwmon_temp.str_cons_0x0103_0x20=temp3_input + +# psu1 temp3 alias +hwmon_temp.mode_0x0103_0x21=str_constant +hwmon_temp.str_cons_0x0103_0x21=temp3 + +# psu2 temp1 input +hwmon_temp.mode_0x0201_0x20=config +hwmon_temp.int_cons_0x0201_0x20=0 +hwmon_temp.src_0x0201_0x20=file +hwmon_temp.frmt_0x0201_0x20=buf +hwmon_temp.fpath_0x0201_0x20=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_temp.addr_0x0201_0x20=0 +hwmon_temp.len_0x0201_0x20=8 +hwmon_temp.bit_offset_0x0201_0x20= +hwmon_temp.str_cons_0x0201_0x20=temp1_input + +# psu2 temp1 alias +hwmon_temp.mode_0x0201_0x21=str_constant +hwmon_temp.str_cons_0x0201_0x21=temp1 + +# psu2 temp2 input +hwmon_temp.mode_0x0202_0x20=config +hwmon_temp.int_cons_0x0202_0x20=0 +hwmon_temp.src_0x0202_0x20=file +hwmon_temp.frmt_0x0202_0x20=buf +hwmon_temp.fpath_0x0202_0x20=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_temp.addr_0x0202_0x20=0 +hwmon_temp.len_0x0202_0x20=8 +hwmon_temp.bit_offset_0x0202_0x20= +hwmon_temp.str_cons_0x0202_0x20=temp2_input + +# psu2 temp2 alias +hwmon_temp.mode_0x0202_0x21=str_constant +hwmon_temp.str_cons_0x0202_0x21=temp2 + +# psu2 temp3 input +hwmon_temp.mode_0x0203_0x20=config +hwmon_temp.int_cons_0x0203_0x20=0 +hwmon_temp.src_0x0203_0x20=file +hwmon_temp.frmt_0x0203_0x20=buf +hwmon_temp.fpath_0x0203_0x20=/sys/bus/i2c/devices/42-0058/hwmon/ +hwmon_temp.addr_0x0203_0x20=0 +hwmon_temp.len_0x0203_0x20=8 +hwmon_temp.bit_offset_0x0203_0x20= +hwmon_temp.str_cons_0x0203_0x20=temp3_input + +# psu2 temp3 alias +hwmon_temp.mode_0x0203_0x21=str_constant +hwmon_temp.str_cons_0x0203_0x21=temp3 + +# display psu name number +dev_num_2_6=2 + +power_name_1_1=DPS-1300AB-6 +power_name_1_2=GW-CRPS1300D +power_name_2_1=DPS-1300AB-11 +power_name_2_2=CRPS1300D3R + +decode_power_name_1=PSA1300CRPS-F +decode_power_name_2=PSA1300CRPS-R + +power_rate_supply_1=1300000000 +power_rate_supply_2=1300000000 + +decode_power_fan_dir_1=0 +decode_power_fan_dir_2=1 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SENSOR.cfg new file mode 100755 index 000000000000..24028725ced6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SENSOR.cfg @@ -0,0 +1,1348 @@ +# temp sensor number +dev_num_0_1=21 + +# voltage sensor number +dev_num_0_2=30 + +# current sensor number +dev_num_0_3=7 + +# sensor temp1 input +hwmon_temp.mode_0x0001_0x00=config +hwmon_temp.int_cons_0x0001_0x00=0 +hwmon_temp.src_0x0001_0x00=file +hwmon_temp.frmt_0x0001_0x00=buf +hwmon_temp.fpath_0x0001_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x00=0 +hwmon_temp.len_0x0001_0x00=8 +hwmon_temp.bit_offset_0x0001_0x00= +hwmon_temp.str_cons_0x0001_0x00=temp1_input + +# sensor temp1 alias +hwmon_temp.mode_0x0001_0x01=config +hwmon_temp.int_cons_0x0001_0x01= +hwmon_temp.src_0x0001_0x01=file +hwmon_temp.frmt_0x0001_0x01=buf +hwmon_temp.fpath_0x0001_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x01=0 +hwmon_temp.len_0x0001_0x01=16 +hwmon_temp.bit_offset_0x0001_0x01= +hwmon_temp.str_cons_0x0001_0x01=temp1_label + +hwmon_temp.mode_0x0001_0x02=str_constant +hwmon_temp.str_cons_0x0001_0x02=cpu + +# sensor temp1 max +hwmon_temp.mode_0x0001_0x03=config +hwmon_temp.int_cons_0x0001_0x03=0 +hwmon_temp.src_0x0001_0x03=file +hwmon_temp.frmt_0x0001_0x03=buf +hwmon_temp.fpath_0x0001_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x03=0 +hwmon_temp.len_0x0001_0x03=8 +hwmon_temp.bit_offset_0x0001_0x03= +hwmon_temp.str_cons_0x0001_0x03=temp1_max + + +# sensor temp2 input +hwmon_temp.mode_0x0002_0x00=config +hwmon_temp.int_cons_0x0002_0x00=0 +hwmon_temp.src_0x0002_0x00=file +hwmon_temp.frmt_0x0002_0x00=buf +hwmon_temp.fpath_0x0002_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x00=0 +hwmon_temp.len_0x0002_0x00=8 +hwmon_temp.bit_offset_0x0002_0x00= +hwmon_temp.str_cons_0x0002_0x00=temp2_input + +# sensor temp2 alias +hwmon_temp.mode_0x0002_0x01=config +hwmon_temp.int_cons_0x0002_0x01= +hwmon_temp.src_0x0002_0x01=file +hwmon_temp.frmt_0x0002_0x01=buf +hwmon_temp.fpath_0x0002_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x01=0 +hwmon_temp.len_0x0002_0x01=16 +hwmon_temp.bit_offset_0x0002_0x01= +hwmon_temp.str_cons_0x0002_0x01=temp2_label + +hwmon_temp.mode_0x0002_0x02=str_constant +hwmon_temp.str_cons_0x0002_0x02=cpu + +# sensor temp2 max +hwmon_temp.mode_0x0002_0x03=config +hwmon_temp.int_cons_0x0002_0x03=0 +hwmon_temp.src_0x0002_0x03=file +hwmon_temp.frmt_0x0002_0x03=buf +hwmon_temp.fpath_0x0002_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x03=0 +hwmon_temp.len_0x0002_0x03=8 +hwmon_temp.bit_offset_0x0002_0x03= +hwmon_temp.str_cons_0x0002_0x03=temp2_max + + +# sensor temp3 input +hwmon_temp.mode_0x0003_0x00=config +hwmon_temp.int_cons_0x0003_0x00=0 +hwmon_temp.src_0x0003_0x00=file +hwmon_temp.frmt_0x0003_0x00=buf +hwmon_temp.fpath_0x0003_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x00=0 +hwmon_temp.len_0x0003_0x00=8 +hwmon_temp.bit_offset_0x0003_0x00= +hwmon_temp.str_cons_0x0003_0x00=temp3_input + +# sensor temp3 alias +hwmon_temp.mode_0x0003_0x01=config +hwmon_temp.int_cons_0x0003_0x01= +hwmon_temp.src_0x0003_0x01=file +hwmon_temp.frmt_0x0003_0x01=buf +hwmon_temp.fpath_0x0003_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x01=0 +hwmon_temp.len_0x0003_0x01=16 +hwmon_temp.bit_offset_0x0003_0x01= +hwmon_temp.str_cons_0x0003_0x01=temp3_label + +hwmon_temp.mode_0x0003_0x02=str_constant +hwmon_temp.str_cons_0x0003_0x02=cpu + +# sensor temp3 max +hwmon_temp.mode_0x0003_0x03=config +hwmon_temp.int_cons_0x0003_0x03=0 +hwmon_temp.src_0x0003_0x03=file +hwmon_temp.frmt_0x0003_0x03=buf +hwmon_temp.fpath_0x0003_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x03=0 +hwmon_temp.len_0x0003_0x03=8 +hwmon_temp.bit_offset_0x0003_0x03= +hwmon_temp.str_cons_0x0003_0x03=temp3_max + + +# sensor temp4 input +hwmon_temp.mode_0x0004_0x00=config +hwmon_temp.int_cons_0x0004_0x00=0 +hwmon_temp.src_0x0004_0x00=file +hwmon_temp.frmt_0x0004_0x00=buf +hwmon_temp.fpath_0x0004_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x00=0 +hwmon_temp.len_0x0004_0x00=8 +hwmon_temp.bit_offset_0x0004_0x00= +hwmon_temp.str_cons_0x0004_0x00=temp4_input + +# sensor temp4 alias +hwmon_temp.mode_0x0004_0x01=config +hwmon_temp.int_cons_0x0004_0x01= +hwmon_temp.src_0x0004_0x01=file +hwmon_temp.frmt_0x0004_0x01=buf +hwmon_temp.fpath_0x0004_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x01=0 +hwmon_temp.len_0x0004_0x01=16 +hwmon_temp.bit_offset_0x0004_0x01= +hwmon_temp.str_cons_0x0004_0x01=temp4_label + +hwmon_temp.mode_0x0004_0x02=str_constant +hwmon_temp.str_cons_0x0004_0x02=cpu + +# sensor temp4 max +hwmon_temp.mode_0x0004_0x03=config +hwmon_temp.int_cons_0x0004_0x03=0 +hwmon_temp.src_0x0004_0x03=file +hwmon_temp.frmt_0x0004_0x03=buf +hwmon_temp.fpath_0x0004_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x03=0 +hwmon_temp.len_0x0004_0x03=8 +hwmon_temp.bit_offset_0x0004_0x03= +hwmon_temp.str_cons_0x0004_0x03=temp4_max + + +# sensor temp5 input +hwmon_temp.mode_0x0005_0x00=config +hwmon_temp.int_cons_0x0005_0x00=0 +hwmon_temp.src_0x0005_0x00=file +hwmon_temp.frmt_0x0005_0x00=buf +hwmon_temp.fpath_0x0005_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x00=0 +hwmon_temp.len_0x0005_0x00=8 +hwmon_temp.bit_offset_0x0005_0x00= +hwmon_temp.str_cons_0x0005_0x00=temp5_input + +# sensor temp5 alias +hwmon_temp.mode_0x0005_0x01=config +hwmon_temp.int_cons_0x0005_0x01= +hwmon_temp.src_0x0005_0x01=file +hwmon_temp.frmt_0x0005_0x01=buf +hwmon_temp.fpath_0x0005_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x01=0 +hwmon_temp.len_0x0005_0x01=16 +hwmon_temp.bit_offset_0x0005_0x01= +hwmon_temp.str_cons_0x0005_0x01=temp5_label + +hwmon_temp.mode_0x0005_0x02=str_constant +hwmon_temp.str_cons_0x0005_0x02=cpu + +# sensor temp5 max +hwmon_temp.mode_0x0005_0x03=config +hwmon_temp.int_cons_0x0005_0x03=0 +hwmon_temp.src_0x0005_0x03=file +hwmon_temp.frmt_0x0005_0x03=buf +hwmon_temp.fpath_0x0005_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x03=0 +hwmon_temp.len_0x0005_0x03=8 +hwmon_temp.bit_offset_0x0005_0x03= +hwmon_temp.str_cons_0x0005_0x03=temp5_max + +# sensor temp6 input +hwmon_temp.mode_0x0006_0x00=config +hwmon_temp.int_cons_0x0006_0x00=3 +hwmon_temp.src_0x0006_0x00=file +hwmon_temp.frmt_0x0006_0x00=buf +hwmon_temp.fpath_0x0006_0x00=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x00=0 +hwmon_temp.len_0x0006_0x00=8 +hwmon_temp.bit_offset_0x0006_0x00=0 +hwmon_temp.str_cons_0x0006_0x00=temp1_input +hwmon_temp.int_extra1_0x0006_0x00=1000 +hwmon_temp.int_extra2_0x0006_0x00=-3000 + +# sensor temp6 alias +hwmon_temp.mode_0x0006_0x01=str_constant +hwmon_temp.str_cons_0x0006_0x01=air_inlet_TL + +# sensor temp6 type +hwmon_temp.mode_0x0006_0x02=str_constant +hwmon_temp.str_cons_0x0006_0x02=lm75 + +# sensor temp6 max +hwmon_temp.mode_0x0006_0x03=config +hwmon_temp.int_cons_0x0006_0x03=0 +hwmon_temp.src_0x0006_0x03=file +hwmon_temp.frmt_0x0006_0x03=buf +hwmon_temp.fpath_0x0006_0x03=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x03=0 +hwmon_temp.len_0x0006_0x03=8 +hwmon_temp.bit_offset_0x0006_0x03= +hwmon_temp.str_cons_0x0006_0x03=temp1_max + +# sensor temp6 max_hyst +hwmon_temp.mode_0x0006_0x04=config +hwmon_temp.int_cons_0x0006_0x04=0 +hwmon_temp.src_0x0006_0x04=file +hwmon_temp.frmt_0x0006_0x04=buf +hwmon_temp.fpath_0x0006_0x04=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x04=0 +hwmon_temp.len_0x0006_0x04=8 +hwmon_temp.bit_offset_0x0006_0x04= +hwmon_temp.str_cons_0x0006_0x04=temp1_max_hyst + + +# sensor temp7 input +hwmon_temp.mode_0x0007_0x00=config +hwmon_temp.int_cons_0x0007_0x00=0 +hwmon_temp.src_0x0007_0x00=file +hwmon_temp.frmt_0x0007_0x00=buf +hwmon_temp.fpath_0x0007_0x00=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x00=0 +hwmon_temp.len_0x0007_0x00=8 +hwmon_temp.bit_offset_0x0007_0x00= +hwmon_temp.str_cons_0x0007_0x00=temp1_input + +# sensor temp7 alias +hwmon_temp.mode_0x0007_0x01=str_constant +hwmon_temp.str_cons_0x0007_0x01=air_inlet_BL + +# sensor temp7 type +hwmon_temp.mode_0x0007_0x02=str_constant +hwmon_temp.str_cons_0x0007_0x02=lm75 + +# sensor temp7 max +hwmon_temp.mode_0x0007_0x03=config +hwmon_temp.int_cons_0x0007_0x03=0 +hwmon_temp.src_0x0007_0x03=file +hwmon_temp.frmt_0x0007_0x03=buf +hwmon_temp.fpath_0x0007_0x03=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x03=0 +hwmon_temp.len_0x0007_0x03=8 +hwmon_temp.bit_offset_0x0007_0x03= +hwmon_temp.str_cons_0x0007_0x03=temp1_max + +# sensor temp7 max_hyst +hwmon_temp.mode_0x0007_0x04=config +hwmon_temp.int_cons_0x0007_0x04=0 +hwmon_temp.src_0x0007_0x04=file +hwmon_temp.frmt_0x0007_0x04=buf +hwmon_temp.fpath_0x0007_0x04=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x04=0 +hwmon_temp.len_0x0007_0x04=8 +hwmon_temp.bit_offset_0x0007_0x04= +hwmon_temp.str_cons_0x0007_0x04=temp1_max_hyst + + +# sensor temp8 input +hwmon_temp.mode_0x0008_0x00=config +hwmon_temp.int_cons_0x0008_0x00=0 +hwmon_temp.src_0x0008_0x00=file +hwmon_temp.frmt_0x0008_0x00=buf +hwmon_temp.fpath_0x0008_0x00=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x00=0 +hwmon_temp.len_0x0008_0x00=8 +hwmon_temp.bit_offset_0x0008_0x00= +hwmon_temp.str_cons_0x0008_0x00=temp1_input + +# sensor temp8 alias +hwmon_temp.mode_0x0008_0x01=str_constant +hwmon_temp.str_cons_0x0008_0x01=air_outlet_L + +# sensor temp8 type +hwmon_temp.mode_0x0008_0x02=str_constant +hwmon_temp.str_cons_0x0008_0x02=lm75 + +# sensor temp8 max +hwmon_temp.mode_0x0008_0x03=config +hwmon_temp.int_cons_0x0008_0x03=0 +hwmon_temp.src_0x0008_0x03=file +hwmon_temp.frmt_0x0008_0x03=buf +hwmon_temp.fpath_0x0008_0x03=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x03=0 +hwmon_temp.len_0x0008_0x03=8 +hwmon_temp.bit_offset_0x0008_0x03= +hwmon_temp.str_cons_0x0008_0x03=temp1_max + +# sensor temp8 max_hyst +hwmon_temp.mode_0x0008_0x04=config +hwmon_temp.int_cons_0x0008_0x04=0 +hwmon_temp.src_0x0008_0x04=file +hwmon_temp.frmt_0x0008_0x04=buf +hwmon_temp.fpath_0x0008_0x04=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x04=0 +hwmon_temp.len_0x0008_0x04=8 +hwmon_temp.bit_offset_0x0008_0x04= +hwmon_temp.str_cons_0x0008_0x04=temp1_max_hyst + + +# sensor temp9 input +hwmon_temp.mode_0x0009_0x00=config +hwmon_temp.int_cons_0x0009_0x00=0 +hwmon_temp.src_0x0009_0x00=file +hwmon_temp.frmt_0x0009_0x00=buf +hwmon_temp.fpath_0x0009_0x00=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x00=0 +hwmon_temp.len_0x0009_0x00=8 +hwmon_temp.bit_offset_0x0009_0x00= +hwmon_temp.str_cons_0x0009_0x00=temp1_input + +# sensor temp9 alias +hwmon_temp.mode_0x0009_0x01=str_constant +hwmon_temp.str_cons_0x0009_0x01=air_outlet_R + +# sensor temp9 type +hwmon_temp.mode_0x0009_0x02=str_constant +hwmon_temp.str_cons_0x0009_0x02=lm75 + +# sensor temp9 max +hwmon_temp.mode_0x0009_0x03=config +hwmon_temp.int_cons_0x0009_0x03=0 +hwmon_temp.src_0x0009_0x03=file +hwmon_temp.frmt_0x0009_0x03=buf +hwmon_temp.fpath_0x0009_0x03=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x03=0 +hwmon_temp.len_0x0009_0x03=8 +hwmon_temp.bit_offset_0x0009_0x03= +hwmon_temp.str_cons_0x0009_0x03=temp1_max + +# sensor temp9 max_hyst +hwmon_temp.mode_0x0009_0x04=config +hwmon_temp.int_cons_0x0009_0x04=0 +hwmon_temp.src_0x0009_0x04=file +hwmon_temp.frmt_0x0009_0x04=buf +hwmon_temp.fpath_0x0009_0x04=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x04=0 +hwmon_temp.len_0x0009_0x04=8 +hwmon_temp.bit_offset_0x0009_0x04= +hwmon_temp.str_cons_0x0009_0x04=temp1_max_hyst + + +# sensor temp10 input +hwmon_temp.mode_0x000a_0x00=config +hwmon_temp.int_cons_0x000a_0x00=0 +hwmon_temp.src_0x000a_0x00=file +hwmon_temp.frmt_0x000a_0x00=buf +hwmon_temp.fpath_0x000a_0x00=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x00=0 +hwmon_temp.len_0x000a_0x00=8 +hwmon_temp.bit_offset_0x000a_0x00= +hwmon_temp.str_cons_0x000a_0x00=temp1_input + +# sensor temp10 alias +hwmon_temp.mode_0x000a_0x01=str_constant +hwmon_temp.str_cons_0x000a_0x01=air_hotlet + +# sensor temp10 type +hwmon_temp.mode_0x000a_0x02=str_constant +hwmon_temp.str_cons_0x000a_0x02=lm75 + +# sensor temp10 max +hwmon_temp.mode_0x000a_0x03=config +hwmon_temp.int_cons_0x000a_0x03=0 +hwmon_temp.src_0x000a_0x03=file +hwmon_temp.frmt_0x000a_0x03=buf +hwmon_temp.fpath_0x000a_0x03=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x03=0 +hwmon_temp.len_0x000a_0x03=8 +hwmon_temp.bit_offset_0x000a_0x03= +hwmon_temp.str_cons_0x000a_0x03=temp1_max + +# sensor temp10 max_hyst +hwmon_temp.mode_0x000a_0x04=config +hwmon_temp.int_cons_0x000a_0x04=0 +hwmon_temp.src_0x000a_0x04=file +hwmon_temp.frmt_0x000a_0x04=buf +hwmon_temp.fpath_0x000a_0x04=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x04=0 +hwmon_temp.len_0x000a_0x04=8 +hwmon_temp.bit_offset_0x000a_0x04= +hwmon_temp.str_cons_0x000a_0x04=temp1_max_hyst + + +# sensor temp11 input +hwmon_temp.mode_0x000b_0x00=config +hwmon_temp.int_cons_0x000b_0x00=0 +hwmon_temp.src_0x000b_0x00=file +hwmon_temp.frmt_0x000b_0x00=buf +hwmon_temp.fpath_0x000b_0x00=/sys/bus/i2c/devices/39-004c/hwmon/ +hwmon_temp.addr_0x000b_0x00=0 +hwmon_temp.len_0x000b_0x00=8 +hwmon_temp.bit_offset_0x000b_0x00= +hwmon_temp.str_cons_0x000b_0x00=temp2_input + +# sensor temp11 alias +hwmon_temp.mode_0x000b_0x01=str_constant +hwmon_temp.str_cons_0x000b_0x01=MAC_PACKAGE0 + +# sensor temp11 type +hwmon_temp.mode_0x000b_0x02=str_constant +hwmon_temp.str_cons_0x000b_0x02=tmp411 + +# sensor temp11 max +hwmon_temp.mode_0x000b_0x03=config +hwmon_temp.int_cons_0x000b_0x03=0 +hwmon_temp.src_0x000b_0x03=file +hwmon_temp.frmt_0x000b_0x03=buf +hwmon_temp.fpath_0x000b_0x03=/sys/bus/i2c/devices/39-004c/hwmon/ +hwmon_temp.addr_0x000b_0x03=0 +hwmon_temp.len_0x000b_0x03=8 +hwmon_temp.bit_offset_0x000b_0x03= +hwmon_temp.str_cons_0x000b_0x03=temp2_max + +# sensor temp12 input +hwmon_temp.mode_0x000c_0x00=config +hwmon_temp.int_cons_0x000c_0x00=0 +hwmon_temp.src_0x000c_0x00=file +hwmon_temp.frmt_0x000c_0x00=buf +hwmon_temp.fpath_0x000c_0x00=/sys/bus/i2c/devices/40-004c/hwmon/ +hwmon_temp.addr_0x000c_0x00=0 +hwmon_temp.len_0x000c_0x00=8 +hwmon_temp.bit_offset_0x000c_0x00= +hwmon_temp.str_cons_0x000c_0x00=temp2_input + +# sensor temp12 alias +hwmon_temp.mode_0x000c_0x01=str_constant +hwmon_temp.str_cons_0x000c_0x01=MAC_PACKAGE1 + +# sensor temp12 type +hwmon_temp.mode_0x000c_0x02=str_constant +hwmon_temp.str_cons_0x000c_0x02=tmp411 + +# sensor temp12 max +hwmon_temp.mode_0x000c_0x03=config +hwmon_temp.int_cons_0x000c_0x03=0 +hwmon_temp.src_0x000c_0x03=file +hwmon_temp.frmt_0x000c_0x03=buf +hwmon_temp.fpath_0x000c_0x03=/sys/bus/i2c/devices/40-004c/hwmon/ +hwmon_temp.addr_0x000c_0x03=0 +hwmon_temp.len_0x000c_0x03=8 +hwmon_temp.bit_offset_0x000c_0x03= +hwmon_temp.str_cons_0x000c_0x03=temp2_max + +# sensor temp13 input +hwmon_temp.mode_0x000d_0x00=config +hwmon_temp.int_cons_0x000d_0x00=0 +hwmon_temp.src_0x000d_0x00=file +hwmon_temp.frmt_0x000d_0x00=buf +hwmon_temp.fpath_0x000d_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000d_0x00=0 +hwmon_temp.len_0x000d_0x00=16 +hwmon_temp.bit_offset_0x000d_0x00= +hwmon_temp.str_cons_0x000d_0x00=temp1_input + +# sensor temp13 alias +hwmon_temp.mode_0x000d_0x01=str_constant +hwmon_temp.str_cons_0x000d_0x01=MAC_DIE_0 + +# sensor temp13 type +hwmon_temp.mode_0x000d_0x02=str_constant +hwmon_temp.str_cons_0x000d_0x02=mac_bsc + + +# sensor temp14 input +hwmon_temp.mode_0x000e_0x00=config +hwmon_temp.int_cons_0x000e_0x00=0 +hwmon_temp.src_0x000e_0x00=file +hwmon_temp.frmt_0x000e_0x00=buf +hwmon_temp.fpath_0x000e_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000e_0x00=0 +hwmon_temp.len_0x000e_0x00=16 +hwmon_temp.bit_offset_0x000e_0x00= +hwmon_temp.str_cons_0x000e_0x00=temp2_input + +# sensor temp14 alias +hwmon_temp.mode_0x000e_0x01=str_constant +hwmon_temp.str_cons_0x000e_0x01=MAC_DIE_1 + +# sensor temp14 type +hwmon_temp.mode_0x000e_0x02=str_constant +hwmon_temp.str_cons_0x000e_0x02=mac_bsc + + +# sensor temp15 input +hwmon_temp.mode_0x000f_0x00=config +hwmon_temp.int_cons_0x000f_0x00=0 +hwmon_temp.src_0x000f_0x00=file +hwmon_temp.frmt_0x000f_0x00=buf +hwmon_temp.fpath_0x000f_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000f_0x00=0 +hwmon_temp.len_0x000f_0x00=16 +hwmon_temp.bit_offset_0x000f_0x00= +hwmon_temp.str_cons_0x000f_0x00=temp3_input + +# sensor temp15 alias +hwmon_temp.mode_0x000f_0x01=str_constant +hwmon_temp.str_cons_0x000f_0x01=MAC_DIE_2 + +# sensor temp15 type +hwmon_temp.mode_0x000f_0x02=str_constant +hwmon_temp.str_cons_0x000f_0x02=mac_bsc + + +# sensor temp16 input +hwmon_temp.mode_0x0010_0x00=config +hwmon_temp.int_cons_0x0010_0x00=0 +hwmon_temp.src_0x0010_0x00=file +hwmon_temp.frmt_0x0010_0x00=buf +hwmon_temp.fpath_0x0010_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0010_0x00=0 +hwmon_temp.len_0x0010_0x00=16 +hwmon_temp.bit_offset_0x0010_0x00= +hwmon_temp.str_cons_0x0010_0x00=temp4_input + +# sensor temp16 alias +hwmon_temp.mode_0x0010_0x01=str_constant +hwmon_temp.str_cons_0x0010_0x01=MAC_DIE_3 + +# sensor temp16 type +hwmon_temp.mode_0x0010_0x02=str_constant +hwmon_temp.str_cons_0x0010_0x02=mac_bsc + + +# sensor temp17 input +hwmon_temp.mode_0x0011_0x00=config +hwmon_temp.int_cons_0x0011_0x00=0 +hwmon_temp.src_0x0011_0x00=file +hwmon_temp.frmt_0x0011_0x00=buf +hwmon_temp.fpath_0x0011_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0011_0x00=0 +hwmon_temp.len_0x0011_0x00=16 +hwmon_temp.bit_offset_0x0011_0x00= +hwmon_temp.str_cons_0x0011_0x00=temp5_input + +# sensor temp17 alias +hwmon_temp.mode_0x0011_0x01=str_constant +hwmon_temp.str_cons_0x0011_0x01=MAC_DIE_4 + +# sensor temp17 type +hwmon_temp.mode_0x0011_0x02=str_constant +hwmon_temp.str_cons_0x0011_0x02=mac_bsc + + +# sensor temp18 input +hwmon_temp.mode_0x0012_0x00=config +hwmon_temp.int_cons_0x0012_0x00=0 +hwmon_temp.src_0x0012_0x00=file +hwmon_temp.frmt_0x0012_0x00=buf +hwmon_temp.fpath_0x0012_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0012_0x00=0 +hwmon_temp.len_0x0012_0x00=16 +hwmon_temp.bit_offset_0x0012_0x00= +hwmon_temp.str_cons_0x0012_0x00=temp6_input + +# sensor temp18 alias +hwmon_temp.mode_0x0012_0x01=str_constant +hwmon_temp.str_cons_0x0012_0x01=MAC_DIE_5 + +# sensor temp18 type +hwmon_temp.mode_0x0012_0x02=str_constant +hwmon_temp.str_cons_0x0012_0x02=mac_bsc + + +# sensor temp19 input +hwmon_temp.mode_0x0013_0x00=config +hwmon_temp.int_cons_0x0013_0x00=0 +hwmon_temp.src_0x0013_0x00=file +hwmon_temp.frmt_0x0013_0x00=buf +hwmon_temp.fpath_0x0013_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0013_0x00=0 +hwmon_temp.len_0x0013_0x00=16 +hwmon_temp.bit_offset_0x0013_0x00= +hwmon_temp.str_cons_0x0013_0x00=temp7_input + +# sensor temp19 alias +hwmon_temp.mode_0x0013_0x01=str_constant +hwmon_temp.str_cons_0x0013_0x01=MAC_DIE_6 + +# sensor temp19 type +hwmon_temp.mode_0x0013_0x02=str_constant +hwmon_temp.str_cons_0x0013_0x02=mac_bsc + + +# sensor temp20 input +hwmon_temp.mode_0x0014_0x00=config +hwmon_temp.int_cons_0x0014_0x00=0 +hwmon_temp.src_0x0014_0x00=file +hwmon_temp.frmt_0x0014_0x00=buf +hwmon_temp.fpath_0x0014_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0014_0x00=0 +hwmon_temp.len_0x0014_0x00=16 +hwmon_temp.bit_offset_0x0014_0x00= +hwmon_temp.str_cons_0x0014_0x00=temp8_input + +# sensor temp20 alias +hwmon_temp.mode_0x0014_0x01=str_constant +hwmon_temp.str_cons_0x0014_0x01=MAC_DIE_7 + +# sensor temp20 type +hwmon_temp.mode_0x0014_0x02=str_constant +hwmon_temp.str_cons_0x0014_0x02=mac_bsc + + +# sensor temp21 input +hwmon_temp.mode_0x0015_0x00=config +hwmon_temp.int_cons_0x0015_0x00=0 +hwmon_temp.src_0x0015_0x00=file +hwmon_temp.frmt_0x0015_0x00=buf +hwmon_temp.fpath_0x0015_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0015_0x00=0 +hwmon_temp.len_0x0015_0x00=16 +hwmon_temp.bit_offset_0x0015_0x00= +hwmon_temp.str_cons_0x0015_0x00=temp9_input + +# sensor temp21 alias +hwmon_temp.mode_0x0015_0x01=str_constant +hwmon_temp.str_cons_0x0015_0x01=MAC_DIE_8 + +# sensor temp21 type +hwmon_temp.mode_0x0015_0x02=str_constant +hwmon_temp.str_cons_0x0015_0x02=mac_bsc + + +# 2:type 3:max 4:max_hyst 5:min 6:crit +# in1 +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=0 +hwmon_in.src_0x0001_0x00=file +hwmon_in.frmt_0x0001_0x00=buf +hwmon_in.fpath_0x0001_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0001_0x00=0 +hwmon_in.len_0x0001_0x00=8 +hwmon_in.bit_offset_0x0001_0x00= +hwmon_in.str_cons_0x0001_0x00=in1_input +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_BOARD_VDD5V_CLK_MCU +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=ucd90160 +hwmon_in.mode_0x0001_0x03=constant +hwmon_in.int_cons_0x0001_0x03=5345 +hwmon_in.mode_0x0001_0x05=constant +hwmon_in.int_cons_0x0001_0x05=4840 +# in2 +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=0 +hwmon_in.src_0x0002_0x00=file +hwmon_in.frmt_0x0002_0x00=buf +hwmon_in.fpath_0x0002_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0002_0x00=0 +hwmon_in.len_0x0002_0x00=8 +hwmon_in.bit_offset_0x0002_0x00= +hwmon_in.str_cons_0x0002_0x00=in2_input +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_BOARD_VDD3.3_CLK +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=ucd90160 +hwmon_in.mode_0x0002_0x03=constant +hwmon_in.int_cons_0x0002_0x03=3560 +hwmon_in.mode_0x0002_0x05=constant +hwmon_in.int_cons_0x0002_0x05=3220 +# in3 +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=0 +hwmon_in.src_0x0003_0x00=file +hwmon_in.frmt_0x0003_0x00=buf +hwmon_in.fpath_0x0003_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0003_0x00=0 +hwmon_in.len_0x0003_0x00=8 +hwmon_in.bit_offset_0x0003_0x00= +hwmon_in.str_cons_0x0003_0x00=in3_input +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_BOARD_VDD1.0V +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=ucd90160 +hwmon_in.mode_0x0003_0x03=constant +hwmon_in.int_cons_0x0003_0x03=1049 +hwmon_in.mode_0x0003_0x05=constant +hwmon_in.int_cons_0x0003_0x05=950 +# in4 +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=0 +hwmon_in.src_0x0004_0x00=file +hwmon_in.frmt_0x0004_0x00=buf +hwmon_in.fpath_0x0004_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0004_0x00=0 +hwmon_in.len_0x0004_0x00=8 +hwmon_in.bit_offset_0x0004_0x00= +hwmon_in.str_cons_0x0004_0x00=in4_input +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_BOARD_VDD1.8V +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=ucd90160 +hwmon_in.mode_0x0004_0x03=constant +hwmon_in.int_cons_0x0004_0x03=1903 +hwmon_in.mode_0x0004_0x05=constant +hwmon_in.int_cons_0x0004_0x05=1720 +# in5 +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=0 +hwmon_in.src_0x0005_0x00=file +hwmon_in.frmt_0x0005_0x00=buf +hwmon_in.fpath_0x0005_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0005_0x00=0 +hwmon_in.len_0x0005_0x00=8 +hwmon_in.bit_offset_0x0005_0x00= +hwmon_in.str_cons_0x0005_0x00=in5_input +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_BOARD_VDD3.3V +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=ucd90160 +hwmon_in.mode_0x0005_0x03=constant +hwmon_in.int_cons_0x0005_0x03=3499 +hwmon_in.mode_0x0005_0x05=constant +hwmon_in.int_cons_0x0005_0x05=3170 +# in6 +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=0 +hwmon_in.src_0x0006_0x00=file +hwmon_in.frmt_0x0006_0x00=buf +hwmon_in.fpath_0x0006_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0006_0x00=0 +hwmon_in.len_0x0006_0x00=8 +hwmon_in.bit_offset_0x0006_0x00= +hwmon_in.str_cons_0x0006_0x00=in6_input +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_BOARD_VDD1.2V +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=ucd90160 +hwmon_in.mode_0x0006_0x03=constant +hwmon_in.int_cons_0x0006_0x03=1272 +hwmon_in.mode_0x0006_0x05=constant +hwmon_in.int_cons_0x0006_0x05=1150 +# in7 +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=0 +hwmon_in.src_0x0007_0x00=file +hwmon_in.frmt_0x0007_0x00=buf +hwmon_in.fpath_0x0007_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0007_0x00=0 +hwmon_in.len_0x0007_0x00=8 +hwmon_in.bit_offset_0x0007_0x00= +hwmon_in.str_cons_0x0007_0x00=in7_input +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_BOARD_VDD_CORE +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=ucd90160 +hwmon_in.mode_0x0007_0x03=constant +hwmon_in.int_cons_0x0007_0x03=950 +hwmon_in.mode_0x0007_0x05=constant +hwmon_in.int_cons_0x0007_0x05=670 +# in8 +hwmon_in.mode_0x0008_0x00=config +hwmon_in.int_cons_0x0008_0x00=0 +hwmon_in.src_0x0008_0x00=file +hwmon_in.frmt_0x0008_0x00=buf +hwmon_in.fpath_0x0008_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0008_0x00=0 +hwmon_in.len_0x0008_0x00=8 +hwmon_in.bit_offset_0x0008_0x00= +hwmon_in.str_cons_0x0008_0x00=in8_input +hwmon_in.mode_0x0008_0x01=str_constant +hwmon_in.str_cons_0x0008_0x01=MAC_BOARD_ANALOG0.75V +hwmon_in.mode_0x0008_0x02=str_constant +hwmon_in.str_cons_0x0008_0x02=ucd90160 +hwmon_in.mode_0x0008_0x03=constant +hwmon_in.int_cons_0x0008_0x03=800 +hwmon_in.mode_0x0008_0x05=constant +hwmon_in.int_cons_0x0008_0x05=700 +# in9 +hwmon_in.mode_0x0009_0x00=config +hwmon_in.int_cons_0x0009_0x00=0 +hwmon_in.src_0x0009_0x00=file +hwmon_in.frmt_0x0009_0x00=buf +hwmon_in.fpath_0x0009_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0009_0x00=0 +hwmon_in.len_0x0009_0x00=8 +hwmon_in.bit_offset_0x0009_0x00= +hwmon_in.str_cons_0x0009_0x00=in9_input +hwmon_in.mode_0x0009_0x01=str_constant +hwmon_in.str_cons_0x0009_0x01=MAC_BOARD_MAC_VDD1.2V +hwmon_in.mode_0x0009_0x02=str_constant +hwmon_in.str_cons_0x0009_0x02=ucd90160 +hwmon_in.mode_0x0009_0x03=constant +hwmon_in.int_cons_0x0009_0x03=1259 +hwmon_in.mode_0x0009_0x05=constant +hwmon_in.int_cons_0x0009_0x05=1140 +# in10 +hwmon_in.mode_0x000a_0x00=config +hwmon_in.int_cons_0x000a_0x00=0 +hwmon_in.src_0x000a_0x00=file +hwmon_in.frmt_0x000a_0x00=buf +hwmon_in.fpath_0x000a_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000a_0x00=0 +hwmon_in.len_0x000a_0x00=8 +hwmon_in.bit_offset_0x000a_0x00= +hwmon_in.str_cons_0x000a_0x00=in10_input +hwmon_in.mode_0x000a_0x01=str_constant +hwmon_in.str_cons_0x000a_0x01=MAC_BOARD_VDDO1.8V +hwmon_in.mode_0x000a_0x02=str_constant +hwmon_in.str_cons_0x000a_0x02=ucd90160 +hwmon_in.mode_0x000a_0x03=constant +hwmon_in.int_cons_0x000a_0x03=1937 +hwmon_in.mode_0x000a_0x05=constant +hwmon_in.int_cons_0x000a_0x05=1750 +# in11 +hwmon_in.mode_0x000b_0x00=config +hwmon_in.int_cons_0x000b_0x00=0 +hwmon_in.src_0x000b_0x00=file +hwmon_in.frmt_0x000b_0x00=buf +hwmon_in.fpath_0x000b_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000b_0x00=0 +hwmon_in.len_0x000b_0x00=8 +hwmon_in.bit_offset_0x000b_0x00= +hwmon_in.str_cons_0x000b_0x00=in11_input +hwmon_in.mode_0x000b_0x01=str_constant +hwmon_in.str_cons_0x000b_0x01=MAC_BOARD_MAC_ANA1.2V +hwmon_in.mode_0x000b_0x02=str_constant +hwmon_in.str_cons_0x000b_0x02=ucd90160 +hwmon_in.mode_0x000b_0x03=constant +hwmon_in.int_cons_0x000b_0x03=1276 +hwmon_in.mode_0x000b_0x05=constant +hwmon_in.int_cons_0x000b_0x05=1150 +# in12 +hwmon_in.mode_0x000c_0x00=config +hwmon_in.int_cons_0x000c_0x00=0 +hwmon_in.src_0x000c_0x00=file +hwmon_in.frmt_0x000c_0x00=buf +hwmon_in.fpath_0x000c_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000c_0x00=0 +hwmon_in.len_0x000c_0x00=8 +hwmon_in.bit_offset_0x000c_0x00= +hwmon_in.str_cons_0x000c_0x00=in12_input +hwmon_in.mode_0x000c_0x01=str_constant +hwmon_in.str_cons_0x000c_0x01=MAC_BOARD_MAC_ANA1.8V +hwmon_in.mode_0x000c_0x02=str_constant +hwmon_in.str_cons_0x000c_0x02=ucd90160 +hwmon_in.mode_0x000c_0x03=constant +hwmon_in.int_cons_0x000c_0x03=1910 +hwmon_in.mode_0x000c_0x05=constant +hwmon_in.int_cons_0x000c_0x05=1730 +# in13 +hwmon_in.mode_0x000d_0x00=config +hwmon_in.int_cons_0x000d_0x00=0 +hwmon_in.src_0x000d_0x00=file +hwmon_in.frmt_0x000d_0x00=buf +hwmon_in.fpath_0x000d_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000d_0x00=0 +hwmon_in.len_0x000d_0x00=8 +hwmon_in.bit_offset_0x000d_0x00= +hwmon_in.str_cons_0x000d_0x00=in13_input +hwmon_in.mode_0x000d_0x01=str_constant +hwmon_in.str_cons_0x000d_0x01=MAC_BOARD_QSFP56_VDD3.3V_A +hwmon_in.mode_0x000d_0x02=str_constant +hwmon_in.str_cons_0x000d_0x02=ucd90160 +hwmon_in.mode_0x000d_0x03=constant +hwmon_in.int_cons_0x000d_0x03=3595 +hwmon_in.mode_0x000d_0x05=constant +hwmon_in.int_cons_0x000d_0x05=3250 +# in14 +hwmon_in.mode_0x000e_0x00=config +hwmon_in.int_cons_0x000e_0x00=0 +hwmon_in.src_0x000e_0x00=file +hwmon_in.frmt_0x000e_0x00=buf +hwmon_in.fpath_0x000e_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000e_0x00=0 +hwmon_in.len_0x000e_0x00=8 +hwmon_in.bit_offset_0x000e_0x00= +hwmon_in.str_cons_0x000e_0x00=in14_input +hwmon_in.mode_0x000e_0x01=str_constant +hwmon_in.str_cons_0x000e_0x01=MAC_BOARD_QSFP56_VDD3.3V_B +hwmon_in.mode_0x000e_0x02=str_constant +hwmon_in.str_cons_0x000e_0x02=ucd90160 +hwmon_in.mode_0x000e_0x03=constant +hwmon_in.int_cons_0x000e_0x03=3601 +hwmon_in.mode_0x000e_0x05=constant +hwmon_in.int_cons_0x000e_0x05=3260 +# in15 +hwmon_in.mode_0x000f_0x00=config +hwmon_in.int_cons_0x000f_0x00=0 +hwmon_in.src_0x000f_0x00=file +hwmon_in.frmt_0x000f_0x00=buf +hwmon_in.fpath_0x000f_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000f_0x00=0 +hwmon_in.len_0x000f_0x00=8 +hwmon_in.bit_offset_0x000f_0x00= +hwmon_in.str_cons_0x000f_0x00=in15_input +hwmon_in.mode_0x000f_0x01=str_constant +hwmon_in.str_cons_0x000f_0x01=MAC_BOARD_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x000f_0x02=str_constant +hwmon_in.str_cons_0x000f_0x02=ucd90160 +hwmon_in.mode_0x000f_0x03=constant +hwmon_in.int_cons_0x000f_0x03=3565 +hwmon_in.mode_0x000f_0x05=constant +hwmon_in.int_cons_0x000f_0x05=3230 +# in16 +hwmon_in.mode_0x0010_0x00=config +hwmon_in.int_cons_0x0010_0x00=0 +hwmon_in.src_0x0010_0x00=file +hwmon_in.frmt_0x0010_0x00=buf +hwmon_in.fpath_0x0010_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0010_0x00=0 +hwmon_in.len_0x0010_0x00=8 +hwmon_in.bit_offset_0x0010_0x00= +hwmon_in.str_cons_0x0010_0x00=in16_input +hwmon_in.mode_0x0010_0x01=str_constant +hwmon_in.str_cons_0x0010_0x01=MAC_BOARD_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0010_0x02=str_constant +hwmon_in.str_cons_0x0010_0x02=ucd90160 +hwmon_in.mode_0x0010_0x03=constant +hwmon_in.int_cons_0x0010_0x03=3564 +hwmon_in.mode_0x0010_0x05=constant +hwmon_in.int_cons_0x0010_0x05=3220 +# in17 +hwmon_in.mode_0x0011_0x00=config +hwmon_in.int_cons_0x0011_0x00=0 +hwmon_in.src_0x0011_0x00=file +hwmon_in.frmt_0x0011_0x00=buf +hwmon_in.fpath_0x0011_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0011_0x00=0 +hwmon_in.len_0x0011_0x00=8 +hwmon_in.bit_offset_0x0011_0x00= +hwmon_in.str_cons_0x0011_0x00=in1_input +hwmon_in.mode_0x0011_0x01=str_constant +hwmon_in.str_cons_0x0011_0x01=CPU_CONNECT_VDD5.0V +hwmon_in.mode_0x0011_0x02=str_constant +hwmon_in.str_cons_0x0011_0x02=ucd90160 +hwmon_in.mode_0x0011_0x03=constant +hwmon_in.int_cons_0x0011_0x03=5429 +hwmon_in.mode_0x0011_0x05=constant +hwmon_in.int_cons_0x0011_0x05=4910 +# in18 +hwmon_in.mode_0x0012_0x00=config +hwmon_in.int_cons_0x0012_0x00=0 +hwmon_in.src_0x0012_0x00=file +hwmon_in.frmt_0x0012_0x00=buf +hwmon_in.fpath_0x0012_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0012_0x00=0 +hwmon_in.len_0x0012_0x00=8 +hwmon_in.bit_offset_0x0012_0x00= +hwmon_in.str_cons_0x0012_0x00=in2_input +hwmon_in.mode_0x0012_0x01=str_constant +hwmon_in.str_cons_0x0012_0x01=CPU_CONNECT_SW_VDD1.2V +hwmon_in.mode_0x0012_0x02=str_constant +hwmon_in.str_cons_0x0012_0x02=ucd90160 +hwmon_in.mode_0x0012_0x03=constant +hwmon_in.int_cons_0x0012_0x03=1284 +hwmon_in.mode_0x0012_0x05=constant +hwmon_in.int_cons_0x0012_0x05=1160 +# in19 +hwmon_in.mode_0x0013_0x00=config +hwmon_in.int_cons_0x0013_0x00=0 +hwmon_in.src_0x0013_0x00=file +hwmon_in.frmt_0x0013_0x00=buf +hwmon_in.fpath_0x0013_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0013_0x00=0 +hwmon_in.len_0x0013_0x00=8 +hwmon_in.bit_offset_0x0013_0x00= +hwmon_in.str_cons_0x0013_0x00=in3_input +hwmon_in.mode_0x0013_0x01=str_constant +hwmon_in.str_cons_0x0013_0x01=CPU_CONNECT_VDD2.5V +hwmon_in.mode_0x0013_0x02=str_constant +hwmon_in.str_cons_0x0013_0x02=ucd90160 +hwmon_in.mode_0x0013_0x03=constant +hwmon_in.int_cons_0x0013_0x03=2620 +hwmon_in.mode_0x0013_0x05=constant +hwmon_in.int_cons_0x0013_0x05=2370 +# in20 +hwmon_in.mode_0x0014_0x00=config +hwmon_in.int_cons_0x0014_0x00=0 +hwmon_in.src_0x0014_0x00=file +hwmon_in.frmt_0x0014_0x00=buf +hwmon_in.fpath_0x0014_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0014_0x00=0 +hwmon_in.len_0x0014_0x00=8 +hwmon_in.bit_offset_0x0014_0x00= +hwmon_in.str_cons_0x0014_0x00=in4_input +hwmon_in.mode_0x0014_0x01=str_constant +hwmon_in.str_cons_0x0014_0x01=CPU_CONNECT_VDD3.3V +hwmon_in.mode_0x0014_0x02=str_constant +hwmon_in.str_cons_0x0014_0x02=ucd90160 +hwmon_in.mode_0x0014_0x03=constant +hwmon_in.int_cons_0x0014_0x03=3437 +hwmon_in.mode_0x0014_0x05=constant +hwmon_in.int_cons_0x0014_0x05=3110 +# in22 +hwmon_in.mode_0x0016_0x00=config +hwmon_in.int_cons_0x0016_0x00=0 +hwmon_in.src_0x0016_0x00=file +hwmon_in.frmt_0x0016_0x00=buf +hwmon_in.fpath_0x0016_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0016_0x00=0 +hwmon_in.len_0x0016_0x00=8 +hwmon_in.bit_offset_0x0016_0x00= +hwmon_in.str_cons_0x0016_0x00=in6_input +hwmon_in.mode_0x0016_0x01=str_constant +hwmon_in.str_cons_0x0016_0x01=CPU_CONNECT_VDD12V +hwmon_in.mode_0x0016_0x02=str_constant +hwmon_in.str_cons_0x0016_0x02=ucd90160 +hwmon_in.mode_0x0016_0x03=constant +hwmon_in.int_cons_0x0016_0x03=12700 +hwmon_in.mode_0x0016_0x05=constant +hwmon_in.int_cons_0x0016_0x05=11300 +# in23 +hwmon_in.mode_0x0017_0x00=config +hwmon_in.int_cons_0x0017_0x00=0 +hwmon_in.src_0x0017_0x00=file +hwmon_in.frmt_0x0017_0x00=buf +hwmon_in.fpath_0x0017_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0017_0x00=0 +hwmon_in.len_0x0017_0x00=8 +hwmon_in.bit_offset_0x0017_0x00= +hwmon_in.str_cons_0x0017_0x00=in7_input +hwmon_in.mode_0x0017_0x01=str_constant +hwmon_in.str_cons_0x0017_0x01=CPU_CONNECT_VDD3.3_STBY +hwmon_in.mode_0x0017_0x02=str_constant +hwmon_in.str_cons_0x0017_0x02=ucd90160 +hwmon_in.mode_0x0017_0x03=constant +hwmon_in.int_cons_0x0017_0x03=3489 +hwmon_in.mode_0x0017_0x05=constant +hwmon_in.int_cons_0x0017_0x05=3160 +# in24 +hwmon_in.mode_0x0018_0x00=config +hwmon_in.int_cons_0x0018_0x00=0 +hwmon_in.src_0x0018_0x00=file +hwmon_in.frmt_0x0018_0x00=buf +hwmon_in.fpath_0x0018_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0018_0x00=0 +hwmon_in.len_0x0018_0x00=8 +hwmon_in.bit_offset_0x0018_0x00= +hwmon_in.str_cons_0x0018_0x00=in8_input +hwmon_in.mode_0x0018_0x01=str_constant +hwmon_in.str_cons_0x0018_0x01=CPU_CONNECT_SSD_VDD3.3V +hwmon_in.mode_0x0018_0x02=str_constant +hwmon_in.str_cons_0x0018_0x02=ucd90160 +hwmon_in.mode_0x0018_0x03=constant +hwmon_in.int_cons_0x0018_0x03=3475 +hwmon_in.mode_0x0018_0x05=constant +hwmon_in.int_cons_0x0018_0x05=3140 +# in25 +hwmon_in.mode_0x0019_0x00=config +hwmon_in.int_cons_0x0019_0x00=0 +hwmon_in.src_0x0019_0x00=file +hwmon_in.frmt_0x0019_0x00=buf +hwmon_in.fpath_0x0019_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_in.addr_0x0019_0x00=0 +hwmon_in.len_0x0019_0x00=8 +hwmon_in.bit_offset_0x0019_0x00= +hwmon_in.str_cons_0x0019_0x00=in3_input +hwmon_in.mode_0x0019_0x01=str_constant +hwmon_in.str_cons_0x0019_0x01=CPU_VCCIN +hwmon_in.mode_0x0019_0x02=str_constant +hwmon_in.str_cons_0x0019_0x02=tps53622 +hwmon_in.mode_0x0019_0x03=constant +hwmon_in.int_cons_0x0019_0x03=1879 +hwmon_in.mode_0x0019_0x05=constant +hwmon_in.int_cons_0x0019_0x05=1700 +# in26 +hwmon_in.mode_0x001a_0x00=config +hwmon_in.int_cons_0x001a_0x00=0 +hwmon_in.src_0x001a_0x00=file +hwmon_in.frmt_0x001a_0x00=buf +hwmon_in.fpath_0x001a_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_in.addr_0x001a_0x00=0 +hwmon_in.len_0x001a_0x00=8 +hwmon_in.bit_offset_0x001a_0x00= +hwmon_in.str_cons_0x001a_0x00=in4_input +hwmon_in.mode_0x001a_0x01=str_constant +hwmon_in.str_cons_0x001a_0x01=CPU_P1V05 +hwmon_in.mode_0x001a_0x02=str_constant +hwmon_in.str_cons_0x001a_0x02=tps53622 +hwmon_in.mode_0x001a_0x03=constant +hwmon_in.int_cons_0x001a_0x03=1103 +hwmon_in.mode_0x001a_0x05=constant +hwmon_in.int_cons_0x001a_0x05=1000 +# in27 +hwmon_in.mode_0x001b_0x00=config +hwmon_in.int_cons_0x001b_0x00=0 +hwmon_in.src_0x001b_0x00=file +hwmon_in.frmt_0x001b_0x00=buf +hwmon_in.fpath_0x001b_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_in.addr_0x001b_0x00=0 +hwmon_in.len_0x001b_0x00=8 +hwmon_in.bit_offset_0x001b_0x00= +hwmon_in.str_cons_0x001b_0x00=in3_input +hwmon_in.mode_0x001b_0x01=str_constant +hwmon_in.str_cons_0x001b_0x01=CPU_P1V2_VDDQ +hwmon_in.mode_0x001b_0x02=str_constant +hwmon_in.str_cons_0x001b_0x02=tps53622 +hwmon_in.mode_0x001b_0x03=constant +hwmon_in.int_cons_0x001b_0x03=1258 +hwmon_in.mode_0x001b_0x05=constant +hwmon_in.int_cons_0x001b_0x05=1140 +# in28 +hwmon_in.mode_0x001c_0x00=config +hwmon_in.int_cons_0x001c_0x00=3 +hwmon_in.src_0x001c_0x00=file +hwmon_in.frmt_0x001c_0x00=buf +hwmon_in.fpath_0x001c_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_in.addr_0x001c_0x00=0 +hwmon_in.len_0x001c_0x00=8 +hwmon_in.bit_offset_0x001c_0x00=0 +hwmon_in.str_cons_0x001c_0x00=in4_input +hwmon_in.int_extra1_0x001c_0x00=1124 +hwmon_in.mode_0x001c_0x01=str_constant +hwmon_in.str_cons_0x001c_0x01=CPU_P2V5_VPP +hwmon_in.mode_0x001c_0x02=str_constant +hwmon_in.str_cons_0x001c_0x02=tps53622 +hwmon_in.mode_0x001c_0x03=constant +hwmon_in.int_cons_0x001c_0x03=2632 +hwmon_in.mode_0x001c_0x05=constant +hwmon_in.int_cons_0x001c_0x05=2380 +# in29 +hwmon_in.mode_0x001d_0x00=config +hwmon_in.int_cons_0x001d_0x00=0 +hwmon_in.src_0x001d_0x00=file +hwmon_in.frmt_0x001d_0x00=buf +hwmon_in.fpath_0x001d_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001d_0x00=0 +hwmon_in.len_0x001d_0x00=8 +hwmon_in.bit_offset_0x001d_0x00= +hwmon_in.str_cons_0x001d_0x00=in1_input +hwmon_in.mode_0x001d_0x01=str_constant +hwmon_in.str_cons_0x001d_0x01=CPU_P3V3_STBY +hwmon_in.mode_0x001d_0x02=str_constant +hwmon_in.str_cons_0x001d_0x02=ina3221 +hwmon_in.mode_0x001d_0x03=constant +hwmon_in.int_cons_0x001d_0x03=3476 +hwmon_in.mode_0x001d_0x05=constant +hwmon_in.int_cons_0x001d_0x05=3140 +# in30 +hwmon_in.mode_0x001e_0x00=config +hwmon_in.int_cons_0x001e_0x00=0 +hwmon_in.src_0x001e_0x00=file +hwmon_in.frmt_0x001e_0x00=buf +hwmon_in.fpath_0x001e_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001e_0x00=0 +hwmon_in.len_0x001e_0x00=8 +hwmon_in.bit_offset_0x001e_0x00= +hwmon_in.str_cons_0x001e_0x00=in2_input +hwmon_in.mode_0x001e_0x01=str_constant +hwmon_in.str_cons_0x001e_0x01=CPU_P5V_AUX_IN +hwmon_in.mode_0x001e_0x02=str_constant +hwmon_in.str_cons_0x001e_0x02=ina3221 +hwmon_in.mode_0x001e_0x03=constant +hwmon_in.int_cons_0x001e_0x03=5229 +hwmon_in.mode_0x001e_0x05=constant +hwmon_in.int_cons_0x001e_0x05=4730 +# in21: original place was 0x30,last one +hwmon_in.mode_0x0015_0x00=config +hwmon_in.int_cons_0x0015_0x00=0 +hwmon_in.src_0x0015_0x00=file +hwmon_in.frmt_0x0015_0x00=buf +hwmon_in.fpath_0x0015_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x0015_0x00=0 +hwmon_in.len_0x0015_0x00=8 +hwmon_in.bit_offset_0x0015_0x00= +hwmon_in.str_cons_0x0015_0x00=in3_input +hwmon_in.mode_0x0015_0x01=str_constant +hwmon_in.str_cons_0x0015_0x01=CPU_P1V7_VCCSCFUSESUS_IN +hwmon_in.mode_0x0015_0x02=str_constant +hwmon_in.str_cons_0x0015_0x02=ina3221 +hwmon_in.mode_0x0015_0x03=constant +hwmon_in.int_cons_0x0015_0x03=1789 +hwmon_in.mode_0x0015_0x05=constant +hwmon_in.int_cons_0x0015_0x05=1620 + +# curr1 +hwmon_curr.mode_0x0001_0x00=config +hwmon_curr.int_cons_0x0001_0x00=0 +hwmon_curr.src_0x0001_0x00=file +hwmon_curr.frmt_0x0001_0x00=buf +hwmon_curr.fpath_0x0001_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_curr.addr_0x0001_0x00=0 +hwmon_curr.len_0x0001_0x00=8 +hwmon_curr.bit_offset_0x0001_0x00= +hwmon_curr.str_cons_0x0001_0x00=curr1_input + +hwmon_curr.mode_0x0001_0x01=str_constant +hwmon_curr.str_cons_0x0001_0x01=CPU_VCCIN_C + +hwmon_curr.mode_0x0001_0x02=str_constant +hwmon_curr.str_cons_0x0001_0x02=tps53622 + +hwmon_curr.mode_0x0001_0x03=constant +hwmon_curr.int_cons_0x0001_0x03=47300 + +hwmon_curr.mode_0x0001_0x05=constant +hwmon_curr.int_cons_0x0001_0x05=0 + +# curr2 +hwmon_curr.mode_0x0002_0x00=config +hwmon_curr.int_cons_0x0002_0x00=0 +hwmon_curr.src_0x0002_0x00=file +hwmon_curr.frmt_0x0002_0x00=buf +hwmon_curr.fpath_0x0002_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_curr.addr_0x0002_0x00=0 +hwmon_curr.len_0x0002_0x00=8 +hwmon_curr.bit_offset_0x0002_0x00= +hwmon_curr.str_cons_0x0002_0x00=curr2_input + +hwmon_curr.mode_0x0002_0x01=str_constant +hwmon_curr.str_cons_0x0002_0x01=CPU_P1V05_C + +hwmon_curr.mode_0x0002_0x02=str_constant +hwmon_curr.str_cons_0x0002_0x02=tps53622 + +hwmon_curr.mode_0x0002_0x03=constant +hwmon_curr.int_cons_0x0002_0x03=15400 + +hwmon_curr.mode_0x0002_0x05=constant +hwmon_curr.int_cons_0x0002_0x05=0 + +# curr3 +hwmon_curr.mode_0x0003_0x00=config +hwmon_curr.int_cons_0x0003_0x00=0 +hwmon_curr.src_0x0003_0x00=file +hwmon_curr.frmt_0x0003_0x00=buf +hwmon_curr.fpath_0x0003_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_curr.addr_0x0003_0x00=0 +hwmon_curr.len_0x0003_0x00=8 +hwmon_curr.bit_offset_0x0003_0x00= +hwmon_curr.str_cons_0x0003_0x00=curr1_input + +hwmon_curr.mode_0x0003_0x01=str_constant +hwmon_curr.str_cons_0x0003_0x01=CPU_P1V2_VDDQ_C + +hwmon_curr.mode_0x0003_0x02=str_constant +hwmon_curr.str_cons_0x0003_0x02=tps53622 + +hwmon_curr.mode_0x0003_0x03=constant +hwmon_curr.int_cons_0x0003_0x03=9900 + +hwmon_curr.mode_0x0003_0x05=constant +hwmon_curr.int_cons_0x0003_0x05=0 + +# curr4 +hwmon_curr.mode_0x0004_0x00=config +hwmon_curr.int_cons_0x0004_0x00=0 +hwmon_curr.src_0x0004_0x00=file +hwmon_curr.frmt_0x0004_0x00=buf +hwmon_curr.fpath_0x0004_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_curr.addr_0x0004_0x00=0 +hwmon_curr.len_0x0004_0x00=8 +hwmon_curr.bit_offset_0x0004_0x00= +hwmon_curr.str_cons_0x0004_0x00=curr2_input + +hwmon_curr.mode_0x0004_0x01=str_constant +hwmon_curr.str_cons_0x0004_0x01=CPU_P2V5_VPP_C + +hwmon_curr.mode_0x0004_0x02=str_constant +hwmon_curr.str_cons_0x0004_0x02=tps53622 + +hwmon_curr.mode_0x0004_0x03=constant +hwmon_curr.int_cons_0x0004_0x03=2200 + +hwmon_curr.mode_0x0004_0x05=constant +hwmon_curr.int_cons_0x0004_0x05=0 + +# curr5 +hwmon_curr.mode_0x0005_0x00=config +hwmon_curr.int_cons_0x0005_0x00=0 +hwmon_curr.src_0x0005_0x00=file +hwmon_curr.frmt_0x0005_0x00=buf +hwmon_curr.fpath_0x0005_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0005_0x00=0 +hwmon_curr.len_0x0005_0x00=8 +hwmon_curr.bit_offset_0x0005_0x00= +hwmon_curr.str_cons_0x0005_0x00=curr1_input + +hwmon_curr.mode_0x0005_0x01=str_constant +hwmon_curr.str_cons_0x0005_0x01=CPU_P3V3_STBY_C + +hwmon_curr.mode_0x0005_0x02=str_constant +hwmon_curr.str_cons_0x0005_0x02=ina3221 + +hwmon_curr.mode_0x0005_0x03=constant +hwmon_curr.int_cons_0x0005_0x03=4686 + +hwmon_curr.mode_0x0005_0x05=constant +hwmon_curr.int_cons_0x0005_0x05=0 + +# curr6 +hwmon_curr.mode_0x0006_0x00=config +hwmon_curr.int_cons_0x0006_0x00=0 +hwmon_curr.src_0x0006_0x00=file +hwmon_curr.frmt_0x0006_0x00=buf +hwmon_curr.fpath_0x0006_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0006_0x00=0 +hwmon_curr.len_0x0006_0x00=8 +hwmon_curr.bit_offset_0x0006_0x00= +hwmon_curr.str_cons_0x0006_0x00=curr2_input + +hwmon_curr.mode_0x0006_0x01=str_constant +hwmon_curr.str_cons_0x0006_0x01=CPU_P5V_AUX_IN_C + +hwmon_curr.mode_0x0006_0x02=str_constant +hwmon_curr.str_cons_0x0006_0x02=ina3221 + +hwmon_curr.mode_0x0006_0x03=constant +hwmon_curr.int_cons_0x0006_0x03=2200 + +hwmon_curr.mode_0x0006_0x05=constant +hwmon_curr.int_cons_0x0006_0x05=0 + +# curr7 +hwmon_curr.mode_0x0007_0x00=config +hwmon_curr.int_cons_0x0007_0x00=0 +hwmon_curr.src_0x0007_0x00=file +hwmon_curr.frmt_0x0007_0x00=buf +hwmon_curr.fpath_0x0007_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0007_0x00=0 +hwmon_curr.len_0x0007_0x00=8 +hwmon_curr.bit_offset_0x0007_0x00= +hwmon_curr.str_cons_0x0007_0x00=curr3_input + +hwmon_curr.mode_0x0007_0x01=str_constant +hwmon_curr.str_cons_0x0007_0x01=CPU_P1V7_VCCSCFUSESUS_IN_C + +hwmon_curr.mode_0x0007_0x02=str_constant +hwmon_curr.str_cons_0x0007_0x02=ina3221 + +hwmon_curr.mode_0x0007_0x03=constant +hwmon_curr.int_cons_0x0007_0x03=2200 + +hwmon_curr.mode_0x0007_0x05=constant +hwmon_curr.int_cons_0x0007_0x05=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SFF.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SFF.cfg new file mode 100755 index 000000000000..bdb9ce15cca5 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-SFF.cfg @@ -0,0 +1,1032 @@ +# sff number +dev_num_3_0=32 + +eeprom_size_3_1=0x8180 +eeprom_size_3_2=0x8180 +eeprom_size_3_3=0x8180 +eeprom_size_3_4=0x8180 +eeprom_size_3_5=0x8180 +eeprom_size_3_6=0x8180 +eeprom_size_3_7=0x8180 +eeprom_size_3_8=0x8180 +eeprom_size_3_9=0x8180 +eeprom_size_3_10=0x8180 +eeprom_size_3_11=0x8180 +eeprom_size_3_12=0x8180 +eeprom_size_3_13=0x8180 +eeprom_size_3_14=0x8180 +eeprom_size_3_15=0x8180 +eeprom_size_3_16=0x8180 +eeprom_size_3_17=0x8180 +eeprom_size_3_18=0x8180 +eeprom_size_3_19=0x8180 +eeprom_size_3_20=0x8180 +eeprom_size_3_21=0x8180 +eeprom_size_3_22=0x8180 +eeprom_size_3_23=0x8180 +eeprom_size_3_24=0x8180 +eeprom_size_3_25=0x8180 +eeprom_size_3_26=0x8180 +eeprom_size_3_27=0x8180 +eeprom_size_3_28=0x8180 +eeprom_size_3_29=0x8180 +eeprom_size_3_30=0x8180 +eeprom_size_3_31=0x8180 +eeprom_size_3_32=0x8180 + +eeprom_path_3_1=/sys/bus/i2c/devices/46-0050/eeprom +eeprom_path_3_2=/sys/bus/i2c/devices/47-0050/eeprom +eeprom_path_3_3=/sys/bus/i2c/devices/48-0050/eeprom +eeprom_path_3_4=/sys/bus/i2c/devices/49-0050/eeprom +eeprom_path_3_5=/sys/bus/i2c/devices/50-0050/eeprom +eeprom_path_3_6=/sys/bus/i2c/devices/51-0050/eeprom +eeprom_path_3_7=/sys/bus/i2c/devices/52-0050/eeprom +eeprom_path_3_8=/sys/bus/i2c/devices/53-0050/eeprom +eeprom_path_3_9=/sys/bus/i2c/devices/54-0050/eeprom +eeprom_path_3_10=/sys/bus/i2c/devices/55-0050/eeprom +eeprom_path_3_11=/sys/bus/i2c/devices/56-0050/eeprom +eeprom_path_3_12=/sys/bus/i2c/devices/57-0050/eeprom +eeprom_path_3_13=/sys/bus/i2c/devices/58-0050/eeprom +eeprom_path_3_14=/sys/bus/i2c/devices/59-0050/eeprom +eeprom_path_3_15=/sys/bus/i2c/devices/60-0050/eeprom +eeprom_path_3_16=/sys/bus/i2c/devices/61-0050/eeprom +eeprom_path_3_17=/sys/bus/i2c/devices/62-0050/eeprom +eeprom_path_3_18=/sys/bus/i2c/devices/63-0050/eeprom +eeprom_path_3_19=/sys/bus/i2c/devices/64-0050/eeprom +eeprom_path_3_20=/sys/bus/i2c/devices/65-0050/eeprom +eeprom_path_3_21=/sys/bus/i2c/devices/66-0050/eeprom +eeprom_path_3_22=/sys/bus/i2c/devices/67-0050/eeprom +eeprom_path_3_23=/sys/bus/i2c/devices/68-0050/eeprom +eeprom_path_3_24=/sys/bus/i2c/devices/69-0050/eeprom +eeprom_path_3_25=/sys/bus/i2c/devices/70-0050/eeprom +eeprom_path_3_26=/sys/bus/i2c/devices/71-0050/eeprom +eeprom_path_3_27=/sys/bus/i2c/devices/72-0050/eeprom +eeprom_path_3_28=/sys/bus/i2c/devices/73-0050/eeprom +eeprom_path_3_29=/sys/bus/i2c/devices/74-0050/eeprom +eeprom_path_3_30=/sys/bus/i2c/devices/75-0050/eeprom +eeprom_path_3_31=/sys/bus/i2c/devices/76-0050/eeprom +eeprom_path_3_32=/sys/bus/i2c/devices/77-0050/eeprom + + +sff_cpld_reg.mode_1_6=config +sff_cpld_reg.src_1_6=cpld +sff_cpld_reg.frmt_1_6=bit +sff_cpld_reg.pola_1_6=negative +sff_cpld_reg.addr_1_6=0x00030022 +sff_cpld_reg.len_1_6=1 +sff_cpld_reg.bit_offset_1_6=0 + +sff_cpld_reg.mode_2_6=config +sff_cpld_reg.src_2_6=cpld +sff_cpld_reg.frmt_2_6=bit +sff_cpld_reg.pola_2_6=negative +sff_cpld_reg.addr_2_6=0x00030022 +sff_cpld_reg.len_2_6=1 +sff_cpld_reg.bit_offset_2_6=1 + +sff_cpld_reg.mode_3_6=config +sff_cpld_reg.src_3_6=cpld +sff_cpld_reg.frmt_3_6=bit +sff_cpld_reg.pola_3_6=negative +sff_cpld_reg.addr_3_6=0x00030022 +sff_cpld_reg.len_3_6=1 +sff_cpld_reg.bit_offset_3_6=2 + +sff_cpld_reg.mode_4_6=config +sff_cpld_reg.src_4_6=cpld +sff_cpld_reg.frmt_4_6=bit +sff_cpld_reg.pola_4_6=negative +sff_cpld_reg.addr_4_6=0x00030022 +sff_cpld_reg.len_4_6=1 +sff_cpld_reg.bit_offset_4_6=3 + +sff_cpld_reg.mode_5_6=config +sff_cpld_reg.src_5_6=cpld +sff_cpld_reg.frmt_5_6=bit +sff_cpld_reg.pola_5_6=negative +sff_cpld_reg.addr_5_6=0x00030022 +sff_cpld_reg.len_5_6=1 +sff_cpld_reg.bit_offset_5_6=4 + +sff_cpld_reg.mode_6_6=config +sff_cpld_reg.src_6_6=cpld +sff_cpld_reg.frmt_6_6=bit +sff_cpld_reg.pola_6_6=negative +sff_cpld_reg.addr_6_6=0x00030022 +sff_cpld_reg.len_6_6=1 +sff_cpld_reg.bit_offset_6_6=5 + +sff_cpld_reg.mode_7_6=config +sff_cpld_reg.src_7_6=cpld +sff_cpld_reg.frmt_7_6=bit +sff_cpld_reg.pola_7_6=negative +sff_cpld_reg.addr_7_6=0x00030022 +sff_cpld_reg.len_7_6=1 +sff_cpld_reg.bit_offset_7_6=6 + +sff_cpld_reg.mode_8_6=config +sff_cpld_reg.src_8_6=cpld +sff_cpld_reg.frmt_8_6=bit +sff_cpld_reg.pola_8_6=negative +sff_cpld_reg.addr_8_6=0x00030022 +sff_cpld_reg.len_8_6=1 +sff_cpld_reg.bit_offset_8_6=7 + +sff_cpld_reg.mode_9_6=config +sff_cpld_reg.src_9_6=cpld +sff_cpld_reg.frmt_9_6=bit +sff_cpld_reg.pola_9_6=negative +sff_cpld_reg.addr_9_6=0x00030023 +sff_cpld_reg.len_9_6=1 +sff_cpld_reg.bit_offset_9_6=0 + +sff_cpld_reg.mode_10_6=config +sff_cpld_reg.src_10_6=cpld +sff_cpld_reg.frmt_10_6=bit +sff_cpld_reg.pola_10_6=negative +sff_cpld_reg.addr_10_6=0x00030023 +sff_cpld_reg.len_10_6=1 +sff_cpld_reg.bit_offset_10_6=1 + +sff_cpld_reg.mode_11_6=config +sff_cpld_reg.src_11_6=cpld +sff_cpld_reg.frmt_11_6=bit +sff_cpld_reg.pola_11_6=negative +sff_cpld_reg.addr_11_6=0x00030023 +sff_cpld_reg.len_11_6=1 +sff_cpld_reg.bit_offset_11_6=2 + +sff_cpld_reg.mode_12_6=config +sff_cpld_reg.src_12_6=cpld +sff_cpld_reg.frmt_12_6=bit +sff_cpld_reg.pola_12_6=negative +sff_cpld_reg.addr_12_6=0x00030023 +sff_cpld_reg.len_12_6=1 +sff_cpld_reg.bit_offset_12_6=3 + +sff_cpld_reg.mode_13_6=config +sff_cpld_reg.src_13_6=cpld +sff_cpld_reg.frmt_13_6=bit +sff_cpld_reg.pola_13_6=negative +sff_cpld_reg.addr_13_6=0x00030023 +sff_cpld_reg.len_13_6=1 +sff_cpld_reg.bit_offset_13_6=4 + +sff_cpld_reg.mode_14_6=config +sff_cpld_reg.src_14_6=cpld +sff_cpld_reg.frmt_14_6=bit +sff_cpld_reg.pola_14_6=negative +sff_cpld_reg.addr_14_6=0x00030023 +sff_cpld_reg.len_14_6=1 +sff_cpld_reg.bit_offset_14_6=5 + +sff_cpld_reg.mode_15_6=config +sff_cpld_reg.src_15_6=cpld +sff_cpld_reg.frmt_15_6=bit +sff_cpld_reg.pola_15_6=negative +sff_cpld_reg.addr_15_6=0x00030023 +sff_cpld_reg.len_15_6=1 +sff_cpld_reg.bit_offset_15_6=6 + +sff_cpld_reg.mode_16_6=config +sff_cpld_reg.src_16_6=cpld +sff_cpld_reg.frmt_16_6=bit +sff_cpld_reg.pola_16_6=negative +sff_cpld_reg.addr_16_6=0x00030023 +sff_cpld_reg.len_16_6=1 +sff_cpld_reg.bit_offset_16_6=7 + +sff_cpld_reg.mode_17_6=config +sff_cpld_reg.src_17_6=cpld +sff_cpld_reg.frmt_17_6=bit +sff_cpld_reg.pola_17_6=negative +sff_cpld_reg.addr_17_6=0x00020021 +sff_cpld_reg.len_17_6=1 +sff_cpld_reg.bit_offset_17_6=0 + +sff_cpld_reg.mode_18_6=config +sff_cpld_reg.src_18_6=cpld +sff_cpld_reg.frmt_18_6=bit +sff_cpld_reg.pola_18_6=negative +sff_cpld_reg.addr_18_6=0x00020021 +sff_cpld_reg.len_18_6=1 +sff_cpld_reg.bit_offset_18_6=1 + +sff_cpld_reg.mode_19_6=config +sff_cpld_reg.src_19_6=cpld +sff_cpld_reg.frmt_19_6=bit +sff_cpld_reg.pola_19_6=negative +sff_cpld_reg.addr_19_6=0x00020021 +sff_cpld_reg.len_19_6=1 +sff_cpld_reg.bit_offset_19_6=2 + +sff_cpld_reg.mode_20_6=config +sff_cpld_reg.src_20_6=cpld +sff_cpld_reg.frmt_20_6=bit +sff_cpld_reg.pola_20_6=negative +sff_cpld_reg.addr_20_6=0x00020021 +sff_cpld_reg.len_20_6=1 +sff_cpld_reg.bit_offset_20_6=3 + +sff_cpld_reg.mode_21_6=config +sff_cpld_reg.src_21_6=cpld +sff_cpld_reg.frmt_21_6=bit +sff_cpld_reg.pola_21_6=negative +sff_cpld_reg.addr_21_6=0x00020021 +sff_cpld_reg.len_21_6=1 +sff_cpld_reg.bit_offset_21_6=4 + +sff_cpld_reg.mode_22_6=config +sff_cpld_reg.src_22_6=cpld +sff_cpld_reg.frmt_22_6=bit +sff_cpld_reg.pola_22_6=negative +sff_cpld_reg.addr_22_6=0x00020021 +sff_cpld_reg.len_22_6=1 +sff_cpld_reg.bit_offset_22_6=5 + +sff_cpld_reg.mode_23_6=config +sff_cpld_reg.src_23_6=cpld +sff_cpld_reg.frmt_23_6=bit +sff_cpld_reg.pola_23_6=negative +sff_cpld_reg.addr_23_6=0x00020021 +sff_cpld_reg.len_23_6=1 +sff_cpld_reg.bit_offset_23_6=6 + +sff_cpld_reg.mode_24_6=config +sff_cpld_reg.src_24_6=cpld +sff_cpld_reg.frmt_24_6=bit +sff_cpld_reg.pola_24_6=negative +sff_cpld_reg.addr_24_6=0x00020021 +sff_cpld_reg.len_24_6=1 +sff_cpld_reg.bit_offset_24_6=7 + +sff_cpld_reg.mode_25_6=config +sff_cpld_reg.src_25_6=cpld +sff_cpld_reg.frmt_25_6=bit +sff_cpld_reg.pola_25_6=negative +sff_cpld_reg.addr_25_6=0x00020022 +sff_cpld_reg.len_25_6=1 +sff_cpld_reg.bit_offset_25_6=0 + +sff_cpld_reg.mode_26_6=config +sff_cpld_reg.src_26_6=cpld +sff_cpld_reg.frmt_26_6=bit +sff_cpld_reg.pola_26_6=negative +sff_cpld_reg.addr_26_6=0x00020022 +sff_cpld_reg.len_26_6=1 +sff_cpld_reg.bit_offset_26_6=1 + +sff_cpld_reg.mode_27_6=config +sff_cpld_reg.src_27_6=cpld +sff_cpld_reg.frmt_27_6=bit +sff_cpld_reg.pola_27_6=negative +sff_cpld_reg.addr_27_6=0x00020022 +sff_cpld_reg.len_27_6=1 +sff_cpld_reg.bit_offset_27_6=2 + +sff_cpld_reg.mode_28_6=config +sff_cpld_reg.src_28_6=cpld +sff_cpld_reg.frmt_28_6=bit +sff_cpld_reg.pola_28_6=negative +sff_cpld_reg.addr_28_6=0x00020022 +sff_cpld_reg.len_28_6=1 +sff_cpld_reg.bit_offset_28_6=3 + +sff_cpld_reg.mode_29_6=config +sff_cpld_reg.src_29_6=cpld +sff_cpld_reg.frmt_29_6=bit +sff_cpld_reg.pola_29_6=negative +sff_cpld_reg.addr_29_6=0x00020022 +sff_cpld_reg.len_29_6=1 +sff_cpld_reg.bit_offset_29_6=4 + +sff_cpld_reg.mode_30_6=config +sff_cpld_reg.src_30_6=cpld +sff_cpld_reg.frmt_30_6=bit +sff_cpld_reg.pola_30_6=negative +sff_cpld_reg.addr_30_6=0x00020022 +sff_cpld_reg.len_30_6=1 +sff_cpld_reg.bit_offset_30_6=5 + +sff_cpld_reg.mode_31_6=config +sff_cpld_reg.src_31_6=cpld +sff_cpld_reg.frmt_31_6=bit +sff_cpld_reg.pola_31_6=negative +sff_cpld_reg.addr_31_6=0x00020022 +sff_cpld_reg.len_31_6=1 +sff_cpld_reg.bit_offset_31_6=6 + +sff_cpld_reg.mode_32_6=config +sff_cpld_reg.src_32_6=cpld +sff_cpld_reg.frmt_32_6=bit +sff_cpld_reg.pola_32_6=negative +sff_cpld_reg.addr_32_6=0x00020022 +sff_cpld_reg.len_32_6=1 +sff_cpld_reg.bit_offset_32_6=7 + + +sff_cpld_reg.mode_1_8=config +sff_cpld_reg.src_1_8=cpld +sff_cpld_reg.frmt_1_8=bit +sff_cpld_reg.pola_1_8=negative +sff_cpld_reg.addr_1_8=0x00020030 +sff_cpld_reg.len_1_8=1 +sff_cpld_reg.bit_offset_1_8=0 + +sff_cpld_reg.mode_2_8=config +sff_cpld_reg.src_2_8=cpld +sff_cpld_reg.frmt_2_8=bit +sff_cpld_reg.pola_2_8=negative +sff_cpld_reg.addr_2_8=0x00020030 +sff_cpld_reg.len_2_8=1 +sff_cpld_reg.bit_offset_2_8=1 + +sff_cpld_reg.mode_3_8=config +sff_cpld_reg.src_3_8=cpld +sff_cpld_reg.frmt_3_8=bit +sff_cpld_reg.pola_3_8=negative +sff_cpld_reg.addr_3_8=0x00020030 +sff_cpld_reg.len_3_8=1 +sff_cpld_reg.bit_offset_3_8=2 + +sff_cpld_reg.mode_4_8=config +sff_cpld_reg.src_4_8=cpld +sff_cpld_reg.frmt_4_8=bit +sff_cpld_reg.pola_4_8=negative +sff_cpld_reg.addr_4_8=0x00020030 +sff_cpld_reg.len_4_8=1 +sff_cpld_reg.bit_offset_4_8=3 + +sff_cpld_reg.mode_5_8=config +sff_cpld_reg.src_5_8=cpld +sff_cpld_reg.frmt_5_8=bit +sff_cpld_reg.pola_5_8=negative +sff_cpld_reg.addr_5_8=0x00020030 +sff_cpld_reg.len_5_8=1 +sff_cpld_reg.bit_offset_5_8=4 + +sff_cpld_reg.mode_6_8=config +sff_cpld_reg.src_6_8=cpld +sff_cpld_reg.frmt_6_8=bit +sff_cpld_reg.pola_6_8=negative +sff_cpld_reg.addr_6_8=0x00020030 +sff_cpld_reg.len_6_8=1 +sff_cpld_reg.bit_offset_6_8=5 + +sff_cpld_reg.mode_7_8=config +sff_cpld_reg.src_7_8=cpld +sff_cpld_reg.frmt_7_8=bit +sff_cpld_reg.pola_7_8=negative +sff_cpld_reg.addr_7_8=0x00020030 +sff_cpld_reg.len_7_8=1 +sff_cpld_reg.bit_offset_7_8=6 + +sff_cpld_reg.mode_8_8=config +sff_cpld_reg.src_8_8=cpld +sff_cpld_reg.frmt_8_8=bit +sff_cpld_reg.pola_8_8=negative +sff_cpld_reg.addr_8_8=0x00020030 +sff_cpld_reg.len_8_8=1 +sff_cpld_reg.bit_offset_8_8=7 + +sff_cpld_reg.mode_9_8=config +sff_cpld_reg.src_9_8=cpld +sff_cpld_reg.frmt_9_8=bit +sff_cpld_reg.pola_9_8=negative +sff_cpld_reg.addr_9_8=0x00020031 +sff_cpld_reg.len_9_8=1 +sff_cpld_reg.bit_offset_9_8=0 + +sff_cpld_reg.mode_10_8=config +sff_cpld_reg.src_10_8=cpld +sff_cpld_reg.frmt_10_8=bit +sff_cpld_reg.pola_10_8=negative +sff_cpld_reg.addr_10_8=0x00020031 +sff_cpld_reg.len_10_8=1 +sff_cpld_reg.bit_offset_10_8=1 + +sff_cpld_reg.mode_11_8=config +sff_cpld_reg.src_11_8=cpld +sff_cpld_reg.frmt_11_8=bit +sff_cpld_reg.pola_11_8=negative +sff_cpld_reg.addr_11_8=0x00020031 +sff_cpld_reg.len_11_8=1 +sff_cpld_reg.bit_offset_11_8=2 + +sff_cpld_reg.mode_12_8=config +sff_cpld_reg.src_12_8=cpld +sff_cpld_reg.frmt_12_8=bit +sff_cpld_reg.pola_12_8=negative +sff_cpld_reg.addr_12_8=0x00020031 +sff_cpld_reg.len_12_8=1 +sff_cpld_reg.bit_offset_12_8=3 + +sff_cpld_reg.mode_13_8=config +sff_cpld_reg.src_13_8=cpld +sff_cpld_reg.frmt_13_8=bit +sff_cpld_reg.pola_13_8=negative +sff_cpld_reg.addr_13_8=0x00020031 +sff_cpld_reg.len_13_8=1 +sff_cpld_reg.bit_offset_13_8=4 + +sff_cpld_reg.mode_14_8=config +sff_cpld_reg.src_14_8=cpld +sff_cpld_reg.frmt_14_8=bit +sff_cpld_reg.pola_14_8=negative +sff_cpld_reg.addr_14_8=0x00020031 +sff_cpld_reg.len_14_8=1 +sff_cpld_reg.bit_offset_14_8=5 + +sff_cpld_reg.mode_15_8=config +sff_cpld_reg.src_15_8=cpld +sff_cpld_reg.frmt_15_8=bit +sff_cpld_reg.pola_15_8=negative +sff_cpld_reg.addr_15_8=0x00020031 +sff_cpld_reg.len_15_8=1 +sff_cpld_reg.bit_offset_15_8=6 + +sff_cpld_reg.mode_16_8=config +sff_cpld_reg.src_16_8=cpld +sff_cpld_reg.frmt_16_8=bit +sff_cpld_reg.pola_16_8=negative +sff_cpld_reg.addr_16_8=0x00020031 +sff_cpld_reg.len_16_8=1 +sff_cpld_reg.bit_offset_16_8=7 + +sff_cpld_reg.mode_17_8=config +sff_cpld_reg.src_17_8=cpld +sff_cpld_reg.frmt_17_8=bit +sff_cpld_reg.pola_17_8=negative +sff_cpld_reg.addr_17_8=0x00020032 +sff_cpld_reg.len_17_8=1 +sff_cpld_reg.bit_offset_17_8=0 + +sff_cpld_reg.mode_18_8=config +sff_cpld_reg.src_18_8=cpld +sff_cpld_reg.frmt_18_8=bit +sff_cpld_reg.pola_18_8=negative +sff_cpld_reg.addr_18_8=0x00020032 +sff_cpld_reg.len_18_8=1 +sff_cpld_reg.bit_offset_18_8=1 + +sff_cpld_reg.mode_19_8=config +sff_cpld_reg.src_19_8=cpld +sff_cpld_reg.frmt_19_8=bit +sff_cpld_reg.pola_19_8=negative +sff_cpld_reg.addr_19_8=0x00020032 +sff_cpld_reg.len_19_8=1 +sff_cpld_reg.bit_offset_19_8=2 + +sff_cpld_reg.mode_20_8=config +sff_cpld_reg.src_20_8=cpld +sff_cpld_reg.frmt_20_8=bit +sff_cpld_reg.pola_20_8=negative +sff_cpld_reg.addr_20_8=0x00020032 +sff_cpld_reg.len_20_8=1 +sff_cpld_reg.bit_offset_20_8=3 + +sff_cpld_reg.mode_21_8=config +sff_cpld_reg.src_21_8=cpld +sff_cpld_reg.frmt_21_8=bit +sff_cpld_reg.pola_21_8=negative +sff_cpld_reg.addr_21_8=0x00020032 +sff_cpld_reg.len_21_8=1 +sff_cpld_reg.bit_offset_21_8=4 + +sff_cpld_reg.mode_22_8=config +sff_cpld_reg.src_22_8=cpld +sff_cpld_reg.frmt_22_8=bit +sff_cpld_reg.pola_22_8=negative +sff_cpld_reg.addr_22_8=0x00020032 +sff_cpld_reg.len_22_8=1 +sff_cpld_reg.bit_offset_22_8=5 + +sff_cpld_reg.mode_23_8=config +sff_cpld_reg.src_23_8=cpld +sff_cpld_reg.frmt_23_8=bit +sff_cpld_reg.pola_23_8=negative +sff_cpld_reg.addr_23_8=0x00020032 +sff_cpld_reg.len_23_8=1 +sff_cpld_reg.bit_offset_23_8=6 + +sff_cpld_reg.mode_24_8=config +sff_cpld_reg.src_24_8=cpld +sff_cpld_reg.frmt_24_8=bit +sff_cpld_reg.pola_24_8=negative +sff_cpld_reg.addr_24_8=0x00020032 +sff_cpld_reg.len_24_8=1 +sff_cpld_reg.bit_offset_24_8=7 + +sff_cpld_reg.mode_25_8=config +sff_cpld_reg.src_25_8=cpld +sff_cpld_reg.frmt_25_8=bit +sff_cpld_reg.pola_25_8=negative +sff_cpld_reg.addr_25_8=0x00020033 +sff_cpld_reg.len_25_8=1 +sff_cpld_reg.bit_offset_25_8=0 + +sff_cpld_reg.mode_26_8=config +sff_cpld_reg.src_26_8=cpld +sff_cpld_reg.frmt_26_8=bit +sff_cpld_reg.pola_26_8=negative +sff_cpld_reg.addr_26_8=0x00020033 +sff_cpld_reg.len_26_8=1 +sff_cpld_reg.bit_offset_26_8=1 + +sff_cpld_reg.mode_27_8=config +sff_cpld_reg.src_27_8=cpld +sff_cpld_reg.frmt_27_8=bit +sff_cpld_reg.pola_27_8=negative +sff_cpld_reg.addr_27_8=0x00020033 +sff_cpld_reg.len_27_8=1 +sff_cpld_reg.bit_offset_27_8=2 + +sff_cpld_reg.mode_28_8=config +sff_cpld_reg.src_28_8=cpld +sff_cpld_reg.frmt_28_8=bit +sff_cpld_reg.pola_28_8=negative +sff_cpld_reg.addr_28_8=0x00020033 +sff_cpld_reg.len_28_8=1 +sff_cpld_reg.bit_offset_28_8=3 + +sff_cpld_reg.mode_29_8=config +sff_cpld_reg.src_29_8=cpld +sff_cpld_reg.frmt_29_8=bit +sff_cpld_reg.pola_29_8=negative +sff_cpld_reg.addr_29_8=0x00020033 +sff_cpld_reg.len_29_8=1 +sff_cpld_reg.bit_offset_29_8=4 + +sff_cpld_reg.mode_30_8=config +sff_cpld_reg.src_30_8=cpld +sff_cpld_reg.frmt_30_8=bit +sff_cpld_reg.pola_30_8=negative +sff_cpld_reg.addr_30_8=0x00020033 +sff_cpld_reg.len_30_8=1 +sff_cpld_reg.bit_offset_30_8=5 + +sff_cpld_reg.mode_31_8=config +sff_cpld_reg.src_31_8=cpld +sff_cpld_reg.frmt_31_8=bit +sff_cpld_reg.pola_31_8=negative +sff_cpld_reg.addr_31_8=0x00020033 +sff_cpld_reg.len_31_8=1 +sff_cpld_reg.bit_offset_31_8=6 + +sff_cpld_reg.mode_32_8=config +sff_cpld_reg.src_32_8=cpld +sff_cpld_reg.frmt_32_8=bit +sff_cpld_reg.pola_32_8=negative +sff_cpld_reg.addr_32_8=0x00020033 +sff_cpld_reg.len_32_8=1 +sff_cpld_reg.bit_offset_32_8=7 + + +sff_cpld_reg.mode_1_1=config +sff_cpld_reg.src_1_1=cpld +sff_cpld_reg.frmt_1_1=bit +sff_cpld_reg.addr_1_1=0x00030034 +sff_cpld_reg.len_1_1=1 +sff_cpld_reg.bit_offset_1_1=0 + +sff_cpld_reg.mode_2_1=config +sff_cpld_reg.src_2_1=cpld +sff_cpld_reg.frmt_2_1=bit +sff_cpld_reg.addr_2_1=0x00030034 +sff_cpld_reg.len_2_1=1 +sff_cpld_reg.bit_offset_2_1=1 + +sff_cpld_reg.mode_3_1=config +sff_cpld_reg.src_3_1=cpld +sff_cpld_reg.frmt_3_1=bit +sff_cpld_reg.addr_3_1=0x00030034 +sff_cpld_reg.len_3_1=1 +sff_cpld_reg.bit_offset_3_1=2 + +sff_cpld_reg.mode_4_1=config +sff_cpld_reg.src_4_1=cpld +sff_cpld_reg.frmt_4_1=bit +sff_cpld_reg.addr_4_1=0x00030034 +sff_cpld_reg.len_4_1=1 +sff_cpld_reg.bit_offset_4_1=3 + +sff_cpld_reg.mode_5_1=config +sff_cpld_reg.src_5_1=cpld +sff_cpld_reg.frmt_5_1=bit +sff_cpld_reg.addr_5_1=0x00030034 +sff_cpld_reg.len_5_1=1 +sff_cpld_reg.bit_offset_5_1=4 + +sff_cpld_reg.mode_6_1=config +sff_cpld_reg.src_6_1=cpld +sff_cpld_reg.frmt_6_1=bit +sff_cpld_reg.addr_6_1=0x00030034 +sff_cpld_reg.len_6_1=1 +sff_cpld_reg.bit_offset_6_1=5 + +sff_cpld_reg.mode_7_1=config +sff_cpld_reg.src_7_1=cpld +sff_cpld_reg.frmt_7_1=bit +sff_cpld_reg.addr_7_1=0x00030034 +sff_cpld_reg.len_7_1=1 +sff_cpld_reg.bit_offset_7_1=6 + +sff_cpld_reg.mode_8_1=config +sff_cpld_reg.src_8_1=cpld +sff_cpld_reg.frmt_8_1=bit +sff_cpld_reg.addr_8_1=0x00030034 +sff_cpld_reg.len_8_1=1 +sff_cpld_reg.bit_offset_8_1=7 + +sff_cpld_reg.mode_9_1=config +sff_cpld_reg.src_9_1=cpld +sff_cpld_reg.frmt_9_1=bit +sff_cpld_reg.addr_9_1=0x00030035 +sff_cpld_reg.len_9_1=1 +sff_cpld_reg.bit_offset_9_1=0 + +sff_cpld_reg.mode_10_1=config +sff_cpld_reg.src_10_1=cpld +sff_cpld_reg.frmt_10_1=bit +sff_cpld_reg.addr_10_1=0x00030035 +sff_cpld_reg.len_10_1=1 +sff_cpld_reg.bit_offset_10_1=1 + +sff_cpld_reg.mode_11_1=config +sff_cpld_reg.src_11_1=cpld +sff_cpld_reg.frmt_11_1=bit +sff_cpld_reg.addr_11_1=0x00030035 +sff_cpld_reg.len_11_1=1 +sff_cpld_reg.bit_offset_11_1=2 + +sff_cpld_reg.mode_12_1=config +sff_cpld_reg.src_12_1=cpld +sff_cpld_reg.frmt_12_1=bit +sff_cpld_reg.addr_12_1=0x00030035 +sff_cpld_reg.len_12_1=1 +sff_cpld_reg.bit_offset_12_1=3 + +sff_cpld_reg.mode_13_1=config +sff_cpld_reg.src_13_1=cpld +sff_cpld_reg.frmt_13_1=bit +sff_cpld_reg.addr_13_1=0x00030035 +sff_cpld_reg.len_13_1=1 +sff_cpld_reg.bit_offset_13_1=4 + +sff_cpld_reg.mode_14_1=config +sff_cpld_reg.src_14_1=cpld +sff_cpld_reg.frmt_14_1=bit +sff_cpld_reg.addr_14_1=0x00030035 +sff_cpld_reg.len_14_1=1 +sff_cpld_reg.bit_offset_14_1=5 + +sff_cpld_reg.mode_15_1=config +sff_cpld_reg.src_15_1=cpld +sff_cpld_reg.frmt_15_1=bit +sff_cpld_reg.addr_15_1=0x00030035 +sff_cpld_reg.len_15_1=1 +sff_cpld_reg.bit_offset_15_1=6 + +sff_cpld_reg.mode_16_1=config +sff_cpld_reg.src_16_1=cpld +sff_cpld_reg.frmt_16_1=bit +sff_cpld_reg.addr_16_1=0x00030035 +sff_cpld_reg.len_16_1=1 +sff_cpld_reg.bit_offset_16_1=7 + +sff_cpld_reg.mode_17_1=config +sff_cpld_reg.src_17_1=cpld +sff_cpld_reg.frmt_17_1=bit +sff_cpld_reg.addr_17_1=0x00020039 +sff_cpld_reg.len_17_1=1 +sff_cpld_reg.bit_offset_17_1=0 + +sff_cpld_reg.mode_18_1=config +sff_cpld_reg.src_18_1=cpld +sff_cpld_reg.frmt_18_1=bit +sff_cpld_reg.addr_18_1=0x00020039 +sff_cpld_reg.len_18_1=1 +sff_cpld_reg.bit_offset_18_1=1 + +sff_cpld_reg.mode_19_1=config +sff_cpld_reg.src_19_1=cpld +sff_cpld_reg.frmt_19_1=bit +sff_cpld_reg.addr_19_1=0x00020039 +sff_cpld_reg.len_19_1=1 +sff_cpld_reg.bit_offset_19_1=2 + +sff_cpld_reg.mode_20_1=config +sff_cpld_reg.src_20_1=cpld +sff_cpld_reg.frmt_20_1=bit +sff_cpld_reg.addr_20_1=0x00020039 +sff_cpld_reg.len_20_1=1 +sff_cpld_reg.bit_offset_20_1=3 + +sff_cpld_reg.mode_21_1=config +sff_cpld_reg.src_21_1=cpld +sff_cpld_reg.frmt_21_1=bit +sff_cpld_reg.addr_21_1=0x00020039 +sff_cpld_reg.len_21_1=1 +sff_cpld_reg.bit_offset_21_1=4 + +sff_cpld_reg.mode_22_1=config +sff_cpld_reg.src_22_1=cpld +sff_cpld_reg.frmt_22_1=bit +sff_cpld_reg.addr_22_1=0x00020039 +sff_cpld_reg.len_22_1=1 +sff_cpld_reg.bit_offset_22_1=5 + +sff_cpld_reg.mode_23_1=config +sff_cpld_reg.src_23_1=cpld +sff_cpld_reg.frmt_23_1=bit +sff_cpld_reg.addr_23_1=0x00020039 +sff_cpld_reg.len_23_1=1 +sff_cpld_reg.bit_offset_23_1=6 + +sff_cpld_reg.mode_24_1=config +sff_cpld_reg.src_24_1=cpld +sff_cpld_reg.frmt_24_1=bit +sff_cpld_reg.addr_24_1=0x00020039 +sff_cpld_reg.len_24_1=1 +sff_cpld_reg.bit_offset_24_1=7 + +sff_cpld_reg.mode_25_1=config +sff_cpld_reg.src_25_1=cpld +sff_cpld_reg.frmt_25_1=bit +sff_cpld_reg.addr_25_1=0x0002003a +sff_cpld_reg.len_25_1=1 +sff_cpld_reg.bit_offset_25_1=0 + +sff_cpld_reg.mode_26_1=config +sff_cpld_reg.src_26_1=cpld +sff_cpld_reg.frmt_26_1=bit +sff_cpld_reg.addr_26_1=0x0002003a +sff_cpld_reg.len_26_1=1 +sff_cpld_reg.bit_offset_26_1=1 + +sff_cpld_reg.mode_27_1=config +sff_cpld_reg.src_27_1=cpld +sff_cpld_reg.frmt_27_1=bit +sff_cpld_reg.addr_27_1=0x0002003a +sff_cpld_reg.len_27_1=1 +sff_cpld_reg.bit_offset_27_1=2 + +sff_cpld_reg.mode_28_1=config +sff_cpld_reg.src_28_1=cpld +sff_cpld_reg.frmt_28_1=bit +sff_cpld_reg.addr_28_1=0x0002003a +sff_cpld_reg.len_28_1=1 +sff_cpld_reg.bit_offset_28_1=3 + +sff_cpld_reg.mode_29_1=config +sff_cpld_reg.src_29_1=cpld +sff_cpld_reg.frmt_29_1=bit +sff_cpld_reg.addr_29_1=0x0002003a +sff_cpld_reg.len_29_1=1 +sff_cpld_reg.bit_offset_29_1=4 + +sff_cpld_reg.mode_30_1=config +sff_cpld_reg.src_30_1=cpld +sff_cpld_reg.frmt_30_1=bit +sff_cpld_reg.addr_30_1=0x0002003a +sff_cpld_reg.len_30_1=1 +sff_cpld_reg.bit_offset_30_1=5 + +sff_cpld_reg.mode_31_1=config +sff_cpld_reg.src_31_1=cpld +sff_cpld_reg.frmt_31_1=bit +sff_cpld_reg.addr_31_1=0x0002003a +sff_cpld_reg.len_31_1=1 +sff_cpld_reg.bit_offset_31_1=6 + +sff_cpld_reg.mode_32_1=config +sff_cpld_reg.src_32_1=cpld +sff_cpld_reg.frmt_32_1=bit +sff_cpld_reg.addr_32_1=0x0002003a +sff_cpld_reg.len_32_1=1 +sff_cpld_reg.bit_offset_32_1=7 + + +sff_cpld_reg.mode_1_7=config +sff_cpld_reg.src_1_7=cpld +sff_cpld_reg.frmt_1_7=bit +sff_cpld_reg.addr_1_7=0x00030032 +sff_cpld_reg.len_1_7=1 +sff_cpld_reg.bit_offset_1_7=0 + +sff_cpld_reg.mode_2_7=config +sff_cpld_reg.src_2_7=cpld +sff_cpld_reg.frmt_2_7=bit +sff_cpld_reg.addr_2_7=0x00030032 +sff_cpld_reg.len_2_7=1 +sff_cpld_reg.bit_offset_2_7=1 + +sff_cpld_reg.mode_3_7=config +sff_cpld_reg.src_3_7=cpld +sff_cpld_reg.frmt_3_7=bit +sff_cpld_reg.addr_3_7=0x00030032 +sff_cpld_reg.len_3_7=1 +sff_cpld_reg.bit_offset_3_7=2 + +sff_cpld_reg.mode_4_7=config +sff_cpld_reg.src_4_7=cpld +sff_cpld_reg.frmt_4_7=bit +sff_cpld_reg.addr_4_7=0x00030032 +sff_cpld_reg.len_4_7=1 +sff_cpld_reg.bit_offset_4_7=3 + +sff_cpld_reg.mode_5_7=config +sff_cpld_reg.src_5_7=cpld +sff_cpld_reg.frmt_5_7=bit +sff_cpld_reg.addr_5_7=0x00030032 +sff_cpld_reg.len_5_7=1 +sff_cpld_reg.bit_offset_5_7=4 + +sff_cpld_reg.mode_6_7=config +sff_cpld_reg.src_6_7=cpld +sff_cpld_reg.frmt_6_7=bit +sff_cpld_reg.addr_6_7=0x00030032 +sff_cpld_reg.len_6_7=1 +sff_cpld_reg.bit_offset_6_7=5 + +sff_cpld_reg.mode_7_7=config +sff_cpld_reg.src_7_7=cpld +sff_cpld_reg.frmt_7_7=bit +sff_cpld_reg.addr_7_7=0x00030032 +sff_cpld_reg.len_7_7=1 +sff_cpld_reg.bit_offset_7_7=6 + +sff_cpld_reg.mode_8_7=config +sff_cpld_reg.src_8_7=cpld +sff_cpld_reg.frmt_8_7=bit +sff_cpld_reg.addr_8_7=0x00030032 +sff_cpld_reg.len_8_7=1 +sff_cpld_reg.bit_offset_8_7=7 + +sff_cpld_reg.mode_9_7=config +sff_cpld_reg.src_9_7=cpld +sff_cpld_reg.frmt_9_7=bit +sff_cpld_reg.addr_9_7=0x00030033 +sff_cpld_reg.len_9_7=1 +sff_cpld_reg.bit_offset_9_7=0 + +sff_cpld_reg.mode_10_7=config +sff_cpld_reg.src_10_7=cpld +sff_cpld_reg.frmt_10_7=bit +sff_cpld_reg.addr_10_7=0x00030033 +sff_cpld_reg.len_10_7=1 +sff_cpld_reg.bit_offset_10_7=1 + +sff_cpld_reg.mode_11_7=config +sff_cpld_reg.src_11_7=cpld +sff_cpld_reg.frmt_11_7=bit +sff_cpld_reg.addr_11_7=0x00030033 +sff_cpld_reg.len_11_7=1 +sff_cpld_reg.bit_offset_11_7=2 + +sff_cpld_reg.mode_12_7=config +sff_cpld_reg.src_12_7=cpld +sff_cpld_reg.frmt_12_7=bit +sff_cpld_reg.addr_12_7=0x00030033 +sff_cpld_reg.len_12_7=1 +sff_cpld_reg.bit_offset_12_7=3 + +sff_cpld_reg.mode_13_7=config +sff_cpld_reg.src_13_7=cpld +sff_cpld_reg.frmt_13_7=bit +sff_cpld_reg.addr_13_7=0x00030033 +sff_cpld_reg.len_13_7=1 +sff_cpld_reg.bit_offset_13_7=4 + +sff_cpld_reg.mode_14_7=config +sff_cpld_reg.src_14_7=cpld +sff_cpld_reg.frmt_14_7=bit +sff_cpld_reg.addr_14_7=0x00030033 +sff_cpld_reg.len_14_7=1 +sff_cpld_reg.bit_offset_14_7=5 + +sff_cpld_reg.mode_15_7=config +sff_cpld_reg.src_15_7=cpld +sff_cpld_reg.frmt_15_7=bit +sff_cpld_reg.addr_15_7=0x00030033 +sff_cpld_reg.len_15_7=1 +sff_cpld_reg.bit_offset_15_7=6 + +sff_cpld_reg.mode_16_7=config +sff_cpld_reg.src_16_7=cpld +sff_cpld_reg.frmt_16_7=bit +sff_cpld_reg.addr_16_7=0x00030033 +sff_cpld_reg.len_16_7=1 +sff_cpld_reg.bit_offset_16_7=7 + +sff_cpld_reg.mode_17_7=config +sff_cpld_reg.src_17_7=cpld +sff_cpld_reg.frmt_17_7=bit +sff_cpld_reg.addr_17_7=0x00020037 +sff_cpld_reg.len_17_7=1 +sff_cpld_reg.bit_offset_17_7=0 + +sff_cpld_reg.mode_18_7=config +sff_cpld_reg.src_18_7=cpld +sff_cpld_reg.frmt_18_7=bit +sff_cpld_reg.addr_18_7=0x00020037 +sff_cpld_reg.len_18_7=1 +sff_cpld_reg.bit_offset_18_7=1 + +sff_cpld_reg.mode_19_7=config +sff_cpld_reg.src_19_7=cpld +sff_cpld_reg.frmt_19_7=bit +sff_cpld_reg.addr_19_7=0x00020037 +sff_cpld_reg.len_19_7=1 +sff_cpld_reg.bit_offset_19_7=2 + +sff_cpld_reg.mode_20_7=config +sff_cpld_reg.src_20_7=cpld +sff_cpld_reg.frmt_20_7=bit +sff_cpld_reg.addr_20_7=0x00020037 +sff_cpld_reg.len_20_7=1 +sff_cpld_reg.bit_offset_20_7=3 + +sff_cpld_reg.mode_21_7=config +sff_cpld_reg.src_21_7=cpld +sff_cpld_reg.frmt_21_7=bit +sff_cpld_reg.addr_21_7=0x00020037 +sff_cpld_reg.len_21_7=1 +sff_cpld_reg.bit_offset_21_7=4 + +sff_cpld_reg.mode_22_7=config +sff_cpld_reg.src_22_7=cpld +sff_cpld_reg.frmt_22_7=bit +sff_cpld_reg.addr_22_7=0x00020037 +sff_cpld_reg.len_22_7=1 +sff_cpld_reg.bit_offset_22_7=5 + +sff_cpld_reg.mode_23_7=config +sff_cpld_reg.src_23_7=cpld +sff_cpld_reg.frmt_23_7=bit +sff_cpld_reg.addr_23_7=0x00020037 +sff_cpld_reg.len_23_7=1 +sff_cpld_reg.bit_offset_23_7=6 + +sff_cpld_reg.mode_24_7=config +sff_cpld_reg.src_24_7=cpld +sff_cpld_reg.frmt_24_7=bit +sff_cpld_reg.addr_24_7=0x00020037 +sff_cpld_reg.len_24_7=1 +sff_cpld_reg.bit_offset_24_7=7 + +sff_cpld_reg.mode_25_7=config +sff_cpld_reg.src_25_7=cpld +sff_cpld_reg.frmt_25_7=bit +sff_cpld_reg.addr_25_7=0x00020038 +sff_cpld_reg.len_25_7=1 +sff_cpld_reg.bit_offset_25_7=0 + +sff_cpld_reg.mode_26_7=config +sff_cpld_reg.src_26_7=cpld +sff_cpld_reg.frmt_26_7=bit +sff_cpld_reg.addr_26_7=0x00020038 +sff_cpld_reg.len_26_7=1 +sff_cpld_reg.bit_offset_26_7=1 + +sff_cpld_reg.mode_27_7=config +sff_cpld_reg.src_27_7=cpld +sff_cpld_reg.frmt_27_7=bit +sff_cpld_reg.addr_27_7=0x00020038 +sff_cpld_reg.len_27_7=1 +sff_cpld_reg.bit_offset_27_7=2 + +sff_cpld_reg.mode_28_7=config +sff_cpld_reg.src_28_7=cpld +sff_cpld_reg.frmt_28_7=bit +sff_cpld_reg.addr_28_7=0x00020038 +sff_cpld_reg.len_28_7=1 +sff_cpld_reg.bit_offset_28_7=3 + +sff_cpld_reg.mode_29_7=config +sff_cpld_reg.src_29_7=cpld +sff_cpld_reg.frmt_29_7=bit +sff_cpld_reg.addr_29_7=0x00020038 +sff_cpld_reg.len_29_7=1 +sff_cpld_reg.bit_offset_29_7=4 + +sff_cpld_reg.mode_30_7=config +sff_cpld_reg.src_30_7=cpld +sff_cpld_reg.frmt_30_7=bit +sff_cpld_reg.addr_30_7=0x00020038 +sff_cpld_reg.len_30_7=1 +sff_cpld_reg.bit_offset_30_7=5 + +sff_cpld_reg.mode_31_7=config +sff_cpld_reg.src_31_7=cpld +sff_cpld_reg.frmt_31_7=bit +sff_cpld_reg.addr_31_7=0x00020038 +sff_cpld_reg.len_31_7=1 +sff_cpld_reg.bit_offset_31_7=6 + +sff_cpld_reg.mode_32_7=config +sff_cpld_reg.src_32_7=cpld +sff_cpld_reg.frmt_32_7=bit +sff_cpld_reg.addr_32_7=0x00020038 +sff_cpld_reg.len_32_7=1 +sff_cpld_reg.bit_offset_32_7=7 diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-V2-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-V2-SENSOR.cfg new file mode 100755 index 000000000000..bfffc5edab73 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS8400-V2-SENSOR.cfg @@ -0,0 +1,1348 @@ +# temp sensor number +dev_num_0_1=21 + +# voltage sensor number +dev_num_0_2=30 + +# current sensor number +dev_num_0_3=7 + +# sensor temp1 input +hwmon_temp.mode_0x0001_0x00=config +hwmon_temp.int_cons_0x0001_0x00=0 +hwmon_temp.src_0x0001_0x00=file +hwmon_temp.frmt_0x0001_0x00=buf +hwmon_temp.fpath_0x0001_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x00=0 +hwmon_temp.len_0x0001_0x00=8 +hwmon_temp.bit_offset_0x0001_0x00= +hwmon_temp.str_cons_0x0001_0x00=temp1_input + +# sensor temp1 alias +hwmon_temp.mode_0x0001_0x01=config +hwmon_temp.int_cons_0x0001_0x01= +hwmon_temp.src_0x0001_0x01=file +hwmon_temp.frmt_0x0001_0x01=buf +hwmon_temp.fpath_0x0001_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x01=0 +hwmon_temp.len_0x0001_0x01=16 +hwmon_temp.bit_offset_0x0001_0x01= +hwmon_temp.str_cons_0x0001_0x01=temp1_label + +hwmon_temp.mode_0x0001_0x02=str_constant +hwmon_temp.str_cons_0x0001_0x02=cpu + +# sensor temp1 max +hwmon_temp.mode_0x0001_0x03=config +hwmon_temp.int_cons_0x0001_0x03=0 +hwmon_temp.src_0x0001_0x03=file +hwmon_temp.frmt_0x0001_0x03=buf +hwmon_temp.fpath_0x0001_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x03=0 +hwmon_temp.len_0x0001_0x03=8 +hwmon_temp.bit_offset_0x0001_0x03= +hwmon_temp.str_cons_0x0001_0x03=temp1_max + + +# sensor temp2 input +hwmon_temp.mode_0x0002_0x00=config +hwmon_temp.int_cons_0x0002_0x00=0 +hwmon_temp.src_0x0002_0x00=file +hwmon_temp.frmt_0x0002_0x00=buf +hwmon_temp.fpath_0x0002_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x00=0 +hwmon_temp.len_0x0002_0x00=8 +hwmon_temp.bit_offset_0x0002_0x00= +hwmon_temp.str_cons_0x0002_0x00=temp2_input + +# sensor temp2 alias +hwmon_temp.mode_0x0002_0x01=config +hwmon_temp.int_cons_0x0002_0x01= +hwmon_temp.src_0x0002_0x01=file +hwmon_temp.frmt_0x0002_0x01=buf +hwmon_temp.fpath_0x0002_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x01=0 +hwmon_temp.len_0x0002_0x01=16 +hwmon_temp.bit_offset_0x0002_0x01= +hwmon_temp.str_cons_0x0002_0x01=temp2_label + +hwmon_temp.mode_0x0002_0x02=str_constant +hwmon_temp.str_cons_0x0002_0x02=cpu + +# sensor temp2 max +hwmon_temp.mode_0x0002_0x03=config +hwmon_temp.int_cons_0x0002_0x03=0 +hwmon_temp.src_0x0002_0x03=file +hwmon_temp.frmt_0x0002_0x03=buf +hwmon_temp.fpath_0x0002_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x03=0 +hwmon_temp.len_0x0002_0x03=8 +hwmon_temp.bit_offset_0x0002_0x03= +hwmon_temp.str_cons_0x0002_0x03=temp2_max + + +# sensor temp3 input +hwmon_temp.mode_0x0003_0x00=config +hwmon_temp.int_cons_0x0003_0x00=0 +hwmon_temp.src_0x0003_0x00=file +hwmon_temp.frmt_0x0003_0x00=buf +hwmon_temp.fpath_0x0003_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x00=0 +hwmon_temp.len_0x0003_0x00=8 +hwmon_temp.bit_offset_0x0003_0x00= +hwmon_temp.str_cons_0x0003_0x00=temp3_input + +# sensor temp3 alias +hwmon_temp.mode_0x0003_0x01=config +hwmon_temp.int_cons_0x0003_0x01= +hwmon_temp.src_0x0003_0x01=file +hwmon_temp.frmt_0x0003_0x01=buf +hwmon_temp.fpath_0x0003_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x01=0 +hwmon_temp.len_0x0003_0x01=16 +hwmon_temp.bit_offset_0x0003_0x01= +hwmon_temp.str_cons_0x0003_0x01=temp3_label + +hwmon_temp.mode_0x0003_0x02=str_constant +hwmon_temp.str_cons_0x0003_0x02=cpu + +# sensor temp3 max +hwmon_temp.mode_0x0003_0x03=config +hwmon_temp.int_cons_0x0003_0x03=0 +hwmon_temp.src_0x0003_0x03=file +hwmon_temp.frmt_0x0003_0x03=buf +hwmon_temp.fpath_0x0003_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x03=0 +hwmon_temp.len_0x0003_0x03=8 +hwmon_temp.bit_offset_0x0003_0x03= +hwmon_temp.str_cons_0x0003_0x03=temp3_max + + +# sensor temp4 input +hwmon_temp.mode_0x0004_0x00=config +hwmon_temp.int_cons_0x0004_0x00=0 +hwmon_temp.src_0x0004_0x00=file +hwmon_temp.frmt_0x0004_0x00=buf +hwmon_temp.fpath_0x0004_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x00=0 +hwmon_temp.len_0x0004_0x00=8 +hwmon_temp.bit_offset_0x0004_0x00= +hwmon_temp.str_cons_0x0004_0x00=temp4_input + +# sensor temp4 alias +hwmon_temp.mode_0x0004_0x01=config +hwmon_temp.int_cons_0x0004_0x01= +hwmon_temp.src_0x0004_0x01=file +hwmon_temp.frmt_0x0004_0x01=buf +hwmon_temp.fpath_0x0004_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x01=0 +hwmon_temp.len_0x0004_0x01=16 +hwmon_temp.bit_offset_0x0004_0x01= +hwmon_temp.str_cons_0x0004_0x01=temp4_label + +hwmon_temp.mode_0x0004_0x02=str_constant +hwmon_temp.str_cons_0x0004_0x02=cpu + +# sensor temp4 max +hwmon_temp.mode_0x0004_0x03=config +hwmon_temp.int_cons_0x0004_0x03=0 +hwmon_temp.src_0x0004_0x03=file +hwmon_temp.frmt_0x0004_0x03=buf +hwmon_temp.fpath_0x0004_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x03=0 +hwmon_temp.len_0x0004_0x03=8 +hwmon_temp.bit_offset_0x0004_0x03= +hwmon_temp.str_cons_0x0004_0x03=temp4_max + + +# sensor temp5 input +hwmon_temp.mode_0x0005_0x00=config +hwmon_temp.int_cons_0x0005_0x00=0 +hwmon_temp.src_0x0005_0x00=file +hwmon_temp.frmt_0x0005_0x00=buf +hwmon_temp.fpath_0x0005_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x00=0 +hwmon_temp.len_0x0005_0x00=8 +hwmon_temp.bit_offset_0x0005_0x00= +hwmon_temp.str_cons_0x0005_0x00=temp5_input + +# sensor temp5 alias +hwmon_temp.mode_0x0005_0x01=config +hwmon_temp.int_cons_0x0005_0x01= +hwmon_temp.src_0x0005_0x01=file +hwmon_temp.frmt_0x0005_0x01=buf +hwmon_temp.fpath_0x0005_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x01=0 +hwmon_temp.len_0x0005_0x01=16 +hwmon_temp.bit_offset_0x0005_0x01= +hwmon_temp.str_cons_0x0005_0x01=temp5_label + +hwmon_temp.mode_0x0005_0x02=str_constant +hwmon_temp.str_cons_0x0005_0x02=cpu + +# sensor temp5 max +hwmon_temp.mode_0x0005_0x03=config +hwmon_temp.int_cons_0x0005_0x03=0 +hwmon_temp.src_0x0005_0x03=file +hwmon_temp.frmt_0x0005_0x03=buf +hwmon_temp.fpath_0x0005_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x03=0 +hwmon_temp.len_0x0005_0x03=8 +hwmon_temp.bit_offset_0x0005_0x03= +hwmon_temp.str_cons_0x0005_0x03=temp5_max + +# sensor temp6 input +hwmon_temp.mode_0x0006_0x00=config +hwmon_temp.int_cons_0x0006_0x00=3 +hwmon_temp.src_0x0006_0x00=file +hwmon_temp.frmt_0x0006_0x00=buf +hwmon_temp.fpath_0x0006_0x00=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x00=0 +hwmon_temp.len_0x0006_0x00=8 +hwmon_temp.bit_offset_0x0006_0x00=0 +hwmon_temp.str_cons_0x0006_0x00=temp1_input +hwmon_temp.int_extra1_0x0006_0x00=1000 +hwmon_temp.int_extra2_0x0006_0x00=-3000 + +# sensor temp6 alias +hwmon_temp.mode_0x0006_0x01=str_constant +hwmon_temp.str_cons_0x0006_0x01=air_inlet_TL + +# sensor temp6 type +hwmon_temp.mode_0x0006_0x02=str_constant +hwmon_temp.str_cons_0x0006_0x02=lm75 + +# sensor temp6 max +hwmon_temp.mode_0x0006_0x03=config +hwmon_temp.int_cons_0x0006_0x03=0 +hwmon_temp.src_0x0006_0x03=file +hwmon_temp.frmt_0x0006_0x03=buf +hwmon_temp.fpath_0x0006_0x03=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x03=0 +hwmon_temp.len_0x0006_0x03=8 +hwmon_temp.bit_offset_0x0006_0x03= +hwmon_temp.str_cons_0x0006_0x03=temp1_max + +# sensor temp6 max_hyst +hwmon_temp.mode_0x0006_0x04=config +hwmon_temp.int_cons_0x0006_0x04=0 +hwmon_temp.src_0x0006_0x04=file +hwmon_temp.frmt_0x0006_0x04=buf +hwmon_temp.fpath_0x0006_0x04=/sys/bus/i2c/devices/40-004f/hwmon/ +hwmon_temp.addr_0x0006_0x04=0 +hwmon_temp.len_0x0006_0x04=8 +hwmon_temp.bit_offset_0x0006_0x04= +hwmon_temp.str_cons_0x0006_0x04=temp1_max_hyst + + +# sensor temp7 input +hwmon_temp.mode_0x0007_0x00=config +hwmon_temp.int_cons_0x0007_0x00=0 +hwmon_temp.src_0x0007_0x00=file +hwmon_temp.frmt_0x0007_0x00=buf +hwmon_temp.fpath_0x0007_0x00=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x00=0 +hwmon_temp.len_0x0007_0x00=8 +hwmon_temp.bit_offset_0x0007_0x00= +hwmon_temp.str_cons_0x0007_0x00=temp1_input + +# sensor temp7 alias +hwmon_temp.mode_0x0007_0x01=str_constant +hwmon_temp.str_cons_0x0007_0x01=air_inlet_BL + +# sensor temp7 type +hwmon_temp.mode_0x0007_0x02=str_constant +hwmon_temp.str_cons_0x0007_0x02=lm75 + +# sensor temp7 max +hwmon_temp.mode_0x0007_0x03=config +hwmon_temp.int_cons_0x0007_0x03=0 +hwmon_temp.src_0x0007_0x03=file +hwmon_temp.frmt_0x0007_0x03=buf +hwmon_temp.fpath_0x0007_0x03=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x03=0 +hwmon_temp.len_0x0007_0x03=8 +hwmon_temp.bit_offset_0x0007_0x03= +hwmon_temp.str_cons_0x0007_0x03=temp1_max + +# sensor temp7 max_hyst +hwmon_temp.mode_0x0007_0x04=config +hwmon_temp.int_cons_0x0007_0x04=0 +hwmon_temp.src_0x0007_0x04=file +hwmon_temp.frmt_0x0007_0x04=buf +hwmon_temp.fpath_0x0007_0x04=/sys/bus/i2c/devices/39-004b/hwmon/ +hwmon_temp.addr_0x0007_0x04=0 +hwmon_temp.len_0x0007_0x04=8 +hwmon_temp.bit_offset_0x0007_0x04= +hwmon_temp.str_cons_0x0007_0x04=temp1_max_hyst + + +# sensor temp8 input +hwmon_temp.mode_0x0008_0x00=config +hwmon_temp.int_cons_0x0008_0x00=0 +hwmon_temp.src_0x0008_0x00=file +hwmon_temp.frmt_0x0008_0x00=buf +hwmon_temp.fpath_0x0008_0x00=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x00=0 +hwmon_temp.len_0x0008_0x00=8 +hwmon_temp.bit_offset_0x0008_0x00= +hwmon_temp.str_cons_0x0008_0x00=temp1_input + +# sensor temp8 alias +hwmon_temp.mode_0x0008_0x01=str_constant +hwmon_temp.str_cons_0x0008_0x01=air_outlet_L + +# sensor temp8 type +hwmon_temp.mode_0x0008_0x02=str_constant +hwmon_temp.str_cons_0x0008_0x02=lm75 + +# sensor temp8 max +hwmon_temp.mode_0x0008_0x03=config +hwmon_temp.int_cons_0x0008_0x03=0 +hwmon_temp.src_0x0008_0x03=file +hwmon_temp.frmt_0x0008_0x03=buf +hwmon_temp.fpath_0x0008_0x03=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x03=0 +hwmon_temp.len_0x0008_0x03=8 +hwmon_temp.bit_offset_0x0008_0x03= +hwmon_temp.str_cons_0x0008_0x03=temp1_max + +# sensor temp8 max_hyst +hwmon_temp.mode_0x0008_0x04=config +hwmon_temp.int_cons_0x0008_0x04=0 +hwmon_temp.src_0x0008_0x04=file +hwmon_temp.frmt_0x0008_0x04=buf +hwmon_temp.fpath_0x0008_0x04=/sys/bus/i2c/devices/36-0048/hwmon/ +hwmon_temp.addr_0x0008_0x04=0 +hwmon_temp.len_0x0008_0x04=8 +hwmon_temp.bit_offset_0x0008_0x04= +hwmon_temp.str_cons_0x0008_0x04=temp1_max_hyst + + +# sensor temp9 input +hwmon_temp.mode_0x0009_0x00=config +hwmon_temp.int_cons_0x0009_0x00=0 +hwmon_temp.src_0x0009_0x00=file +hwmon_temp.frmt_0x0009_0x00=buf +hwmon_temp.fpath_0x0009_0x00=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x00=0 +hwmon_temp.len_0x0009_0x00=8 +hwmon_temp.bit_offset_0x0009_0x00= +hwmon_temp.str_cons_0x0009_0x00=temp1_input + +# sensor temp9 alias +hwmon_temp.mode_0x0009_0x01=str_constant +hwmon_temp.str_cons_0x0009_0x01=air_outlet_R + +# sensor temp9 type +hwmon_temp.mode_0x0009_0x02=str_constant +hwmon_temp.str_cons_0x0009_0x02=lm75 + +# sensor temp9 max +hwmon_temp.mode_0x0009_0x03=config +hwmon_temp.int_cons_0x0009_0x03=0 +hwmon_temp.src_0x0009_0x03=file +hwmon_temp.frmt_0x0009_0x03=buf +hwmon_temp.fpath_0x0009_0x03=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x03=0 +hwmon_temp.len_0x0009_0x03=8 +hwmon_temp.bit_offset_0x0009_0x03= +hwmon_temp.str_cons_0x0009_0x03=temp1_max + +# sensor temp9 max_hyst +hwmon_temp.mode_0x0009_0x04=config +hwmon_temp.int_cons_0x0009_0x04=0 +hwmon_temp.src_0x0009_0x04=file +hwmon_temp.frmt_0x0009_0x04=buf +hwmon_temp.fpath_0x0009_0x04=/sys/bus/i2c/devices/36-0049/hwmon/ +hwmon_temp.addr_0x0009_0x04=0 +hwmon_temp.len_0x0009_0x04=8 +hwmon_temp.bit_offset_0x0009_0x04= +hwmon_temp.str_cons_0x0009_0x04=temp1_max_hyst + + +# sensor temp10 input +hwmon_temp.mode_0x000a_0x00=config +hwmon_temp.int_cons_0x000a_0x00=0 +hwmon_temp.src_0x000a_0x00=file +hwmon_temp.frmt_0x000a_0x00=buf +hwmon_temp.fpath_0x000a_0x00=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x00=0 +hwmon_temp.len_0x000a_0x00=8 +hwmon_temp.bit_offset_0x000a_0x00= +hwmon_temp.str_cons_0x000a_0x00=temp1_input + +# sensor temp10 alias +hwmon_temp.mode_0x000a_0x01=str_constant +hwmon_temp.str_cons_0x000a_0x01=air_hotlet + +# sensor temp10 type +hwmon_temp.mode_0x000a_0x02=str_constant +hwmon_temp.str_cons_0x000a_0x02=lm75 + +# sensor temp10 max +hwmon_temp.mode_0x000a_0x03=config +hwmon_temp.int_cons_0x000a_0x03=0 +hwmon_temp.src_0x000a_0x03=file +hwmon_temp.frmt_0x000a_0x03=buf +hwmon_temp.fpath_0x000a_0x03=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x03=0 +hwmon_temp.len_0x000a_0x03=8 +hwmon_temp.bit_offset_0x000a_0x03= +hwmon_temp.str_cons_0x000a_0x03=temp1_max + +# sensor temp10 max_hyst +hwmon_temp.mode_0x000a_0x04=config +hwmon_temp.int_cons_0x000a_0x04=0 +hwmon_temp.src_0x000a_0x04=file +hwmon_temp.frmt_0x000a_0x04=buf +hwmon_temp.fpath_0x000a_0x04=/sys/bus/i2c/devices/40-004e/hwmon/ +hwmon_temp.addr_0x000a_0x04=0 +hwmon_temp.len_0x000a_0x04=8 +hwmon_temp.bit_offset_0x000a_0x04= +hwmon_temp.str_cons_0x000a_0x04=temp1_max_hyst + + +# sensor temp11 input +hwmon_temp.mode_0x000b_0x00=config +hwmon_temp.int_cons_0x000b_0x00=0 +hwmon_temp.src_0x000b_0x00=file +hwmon_temp.frmt_0x000b_0x00=buf +hwmon_temp.fpath_0x000b_0x00=/sys/bus/i2c/devices/39-004c/hwmon/ +hwmon_temp.addr_0x000b_0x00=0 +hwmon_temp.len_0x000b_0x00=8 +hwmon_temp.bit_offset_0x000b_0x00= +hwmon_temp.str_cons_0x000b_0x00=temp2_input + +# sensor temp11 alias +hwmon_temp.mode_0x000b_0x01=str_constant +hwmon_temp.str_cons_0x000b_0x01=MAC_PACKAGE0 + +# sensor temp11 type +hwmon_temp.mode_0x000b_0x02=str_constant +hwmon_temp.str_cons_0x000b_0x02=tmp411 + +# sensor temp11 max +hwmon_temp.mode_0x000b_0x03=config +hwmon_temp.int_cons_0x000b_0x03=0 +hwmon_temp.src_0x000b_0x03=file +hwmon_temp.frmt_0x000b_0x03=buf +hwmon_temp.fpath_0x000b_0x03=/sys/bus/i2c/devices/39-004c/hwmon/ +hwmon_temp.addr_0x000b_0x03=0 +hwmon_temp.len_0x000b_0x03=8 +hwmon_temp.bit_offset_0x000b_0x03= +hwmon_temp.str_cons_0x000b_0x03=temp2_max + +# sensor temp12 input +hwmon_temp.mode_0x000c_0x00=config +hwmon_temp.int_cons_0x000c_0x00=0 +hwmon_temp.src_0x000c_0x00=file +hwmon_temp.frmt_0x000c_0x00=buf +hwmon_temp.fpath_0x000c_0x00=/sys/bus/i2c/devices/40-004c/hwmon/ +hwmon_temp.addr_0x000c_0x00=0 +hwmon_temp.len_0x000c_0x00=8 +hwmon_temp.bit_offset_0x000c_0x00= +hwmon_temp.str_cons_0x000c_0x00=temp2_input + +# sensor temp12 alias +hwmon_temp.mode_0x000c_0x01=str_constant +hwmon_temp.str_cons_0x000c_0x01=MAC_PACKAGE1 + +# sensor temp12 type +hwmon_temp.mode_0x000c_0x02=str_constant +hwmon_temp.str_cons_0x000c_0x02=tmp411 + +# sensor temp12 max +hwmon_temp.mode_0x000c_0x03=config +hwmon_temp.int_cons_0x000c_0x03=0 +hwmon_temp.src_0x000c_0x03=file +hwmon_temp.frmt_0x000c_0x03=buf +hwmon_temp.fpath_0x000c_0x03=/sys/bus/i2c/devices/40-004c/hwmon/ +hwmon_temp.addr_0x000c_0x03=0 +hwmon_temp.len_0x000c_0x03=8 +hwmon_temp.bit_offset_0x000c_0x03= +hwmon_temp.str_cons_0x000c_0x03=temp2_max + +# sensor temp13 input +hwmon_temp.mode_0x000d_0x00=config +hwmon_temp.int_cons_0x000d_0x00=0 +hwmon_temp.src_0x000d_0x00=file +hwmon_temp.frmt_0x000d_0x00=buf +hwmon_temp.fpath_0x000d_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000d_0x00=0 +hwmon_temp.len_0x000d_0x00=16 +hwmon_temp.bit_offset_0x000d_0x00= +hwmon_temp.str_cons_0x000d_0x00=temp1_input + +# sensor temp13 alias +hwmon_temp.mode_0x000d_0x01=str_constant +hwmon_temp.str_cons_0x000d_0x01=MAC_DIE_0 + +# sensor temp13 type +hwmon_temp.mode_0x000d_0x02=str_constant +hwmon_temp.str_cons_0x000d_0x02=mac_bsc + + +# sensor temp14 input +hwmon_temp.mode_0x000e_0x00=config +hwmon_temp.int_cons_0x000e_0x00=0 +hwmon_temp.src_0x000e_0x00=file +hwmon_temp.frmt_0x000e_0x00=buf +hwmon_temp.fpath_0x000e_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000e_0x00=0 +hwmon_temp.len_0x000e_0x00=16 +hwmon_temp.bit_offset_0x000e_0x00= +hwmon_temp.str_cons_0x000e_0x00=temp2_input + +# sensor temp14 alias +hwmon_temp.mode_0x000e_0x01=str_constant +hwmon_temp.str_cons_0x000e_0x01=MAC_DIE_1 + +# sensor temp14 type +hwmon_temp.mode_0x000e_0x02=str_constant +hwmon_temp.str_cons_0x000e_0x02=mac_bsc + + +# sensor temp15 input +hwmon_temp.mode_0x000f_0x00=config +hwmon_temp.int_cons_0x000f_0x00=0 +hwmon_temp.src_0x000f_0x00=file +hwmon_temp.frmt_0x000f_0x00=buf +hwmon_temp.fpath_0x000f_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x000f_0x00=0 +hwmon_temp.len_0x000f_0x00=16 +hwmon_temp.bit_offset_0x000f_0x00= +hwmon_temp.str_cons_0x000f_0x00=temp3_input + +# sensor temp15 alias +hwmon_temp.mode_0x000f_0x01=str_constant +hwmon_temp.str_cons_0x000f_0x01=MAC_DIE_2 + +# sensor temp15 type +hwmon_temp.mode_0x000f_0x02=str_constant +hwmon_temp.str_cons_0x000f_0x02=mac_bsc + + +# sensor temp16 input +hwmon_temp.mode_0x0010_0x00=config +hwmon_temp.int_cons_0x0010_0x00=0 +hwmon_temp.src_0x0010_0x00=file +hwmon_temp.frmt_0x0010_0x00=buf +hwmon_temp.fpath_0x0010_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0010_0x00=0 +hwmon_temp.len_0x0010_0x00=16 +hwmon_temp.bit_offset_0x0010_0x00= +hwmon_temp.str_cons_0x0010_0x00=temp4_input + +# sensor temp16 alias +hwmon_temp.mode_0x0010_0x01=str_constant +hwmon_temp.str_cons_0x0010_0x01=MAC_DIE_3 + +# sensor temp16 type +hwmon_temp.mode_0x0010_0x02=str_constant +hwmon_temp.str_cons_0x0010_0x02=mac_bsc + + +# sensor temp17 input +hwmon_temp.mode_0x0011_0x00=config +hwmon_temp.int_cons_0x0011_0x00=0 +hwmon_temp.src_0x0011_0x00=file +hwmon_temp.frmt_0x0011_0x00=buf +hwmon_temp.fpath_0x0011_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0011_0x00=0 +hwmon_temp.len_0x0011_0x00=16 +hwmon_temp.bit_offset_0x0011_0x00= +hwmon_temp.str_cons_0x0011_0x00=temp5_input + +# sensor temp17 alias +hwmon_temp.mode_0x0011_0x01=str_constant +hwmon_temp.str_cons_0x0011_0x01=MAC_DIE_4 + +# sensor temp17 type +hwmon_temp.mode_0x0011_0x02=str_constant +hwmon_temp.str_cons_0x0011_0x02=mac_bsc + + +# sensor temp18 input +hwmon_temp.mode_0x0012_0x00=config +hwmon_temp.int_cons_0x0012_0x00=0 +hwmon_temp.src_0x0012_0x00=file +hwmon_temp.frmt_0x0012_0x00=buf +hwmon_temp.fpath_0x0012_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0012_0x00=0 +hwmon_temp.len_0x0012_0x00=16 +hwmon_temp.bit_offset_0x0012_0x00= +hwmon_temp.str_cons_0x0012_0x00=temp6_input + +# sensor temp18 alias +hwmon_temp.mode_0x0012_0x01=str_constant +hwmon_temp.str_cons_0x0012_0x01=MAC_DIE_5 + +# sensor temp18 type +hwmon_temp.mode_0x0012_0x02=str_constant +hwmon_temp.str_cons_0x0012_0x02=mac_bsc + + +# sensor temp19 input +hwmon_temp.mode_0x0013_0x00=config +hwmon_temp.int_cons_0x0013_0x00=0 +hwmon_temp.src_0x0013_0x00=file +hwmon_temp.frmt_0x0013_0x00=buf +hwmon_temp.fpath_0x0013_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0013_0x00=0 +hwmon_temp.len_0x0013_0x00=16 +hwmon_temp.bit_offset_0x0013_0x00= +hwmon_temp.str_cons_0x0013_0x00=temp7_input + +# sensor temp19 alias +hwmon_temp.mode_0x0013_0x01=str_constant +hwmon_temp.str_cons_0x0013_0x01=MAC_DIE_6 + +# sensor temp19 type +hwmon_temp.mode_0x0013_0x02=str_constant +hwmon_temp.str_cons_0x0013_0x02=mac_bsc + + +# sensor temp20 input +hwmon_temp.mode_0x0014_0x00=config +hwmon_temp.int_cons_0x0014_0x00=0 +hwmon_temp.src_0x0014_0x00=file +hwmon_temp.frmt_0x0014_0x00=buf +hwmon_temp.fpath_0x0014_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0014_0x00=0 +hwmon_temp.len_0x0014_0x00=16 +hwmon_temp.bit_offset_0x0014_0x00= +hwmon_temp.str_cons_0x0014_0x00=temp8_input + +# sensor temp20 alias +hwmon_temp.mode_0x0014_0x01=str_constant +hwmon_temp.str_cons_0x0014_0x01=MAC_DIE_7 + +# sensor temp20 type +hwmon_temp.mode_0x0014_0x02=str_constant +hwmon_temp.str_cons_0x0014_0x02=mac_bsc + + +# sensor temp21 input +hwmon_temp.mode_0x0015_0x00=config +hwmon_temp.int_cons_0x0015_0x00=0 +hwmon_temp.src_0x0015_0x00=file +hwmon_temp.frmt_0x0015_0x00=buf +hwmon_temp.fpath_0x0015_0x00=/sys/bus/i2c/devices/44-0044/hwmon/ +hwmon_temp.addr_0x0015_0x00=0 +hwmon_temp.len_0x0015_0x00=16 +hwmon_temp.bit_offset_0x0015_0x00= +hwmon_temp.str_cons_0x0015_0x00=temp9_input + +# sensor temp21 alias +hwmon_temp.mode_0x0015_0x01=str_constant +hwmon_temp.str_cons_0x0015_0x01=MAC_DIE_8 + +# sensor temp21 type +hwmon_temp.mode_0x0015_0x02=str_constant +hwmon_temp.str_cons_0x0015_0x02=mac_bsc + + +# 2:type 3:max 4:max_hyst 5:min 6:crit +# in1 +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=0 +hwmon_in.src_0x0001_0x00=file +hwmon_in.frmt_0x0001_0x00=buf +hwmon_in.fpath_0x0001_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0001_0x00=0 +hwmon_in.len_0x0001_0x00=8 +hwmon_in.bit_offset_0x0001_0x00= +hwmon_in.str_cons_0x0001_0x00=in1_input +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_BOARD_VDD5V_CLK_MCU +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=ucd90160 +hwmon_in.mode_0x0001_0x03=constant +hwmon_in.int_cons_0x0001_0x03=5345 +hwmon_in.mode_0x0001_0x05=constant +hwmon_in.int_cons_0x0001_0x05=4840 +# in2 +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=0 +hwmon_in.src_0x0002_0x00=file +hwmon_in.frmt_0x0002_0x00=buf +hwmon_in.fpath_0x0002_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0002_0x00=0 +hwmon_in.len_0x0002_0x00=8 +hwmon_in.bit_offset_0x0002_0x00= +hwmon_in.str_cons_0x0002_0x00=in2_input +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_BOARD_VDD3.3_CLK +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=ucd90160 +hwmon_in.mode_0x0002_0x03=constant +hwmon_in.int_cons_0x0002_0x03=3560 +hwmon_in.mode_0x0002_0x05=constant +hwmon_in.int_cons_0x0002_0x05=3220 +# in3 +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=0 +hwmon_in.src_0x0003_0x00=file +hwmon_in.frmt_0x0003_0x00=buf +hwmon_in.fpath_0x0003_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0003_0x00=0 +hwmon_in.len_0x0003_0x00=8 +hwmon_in.bit_offset_0x0003_0x00= +hwmon_in.str_cons_0x0003_0x00=in3_input +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_BOARD_VDD1.0V +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=ucd90160 +hwmon_in.mode_0x0003_0x03=constant +hwmon_in.int_cons_0x0003_0x03=1049 +hwmon_in.mode_0x0003_0x05=constant +hwmon_in.int_cons_0x0003_0x05=950 +# in4 +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=0 +hwmon_in.src_0x0004_0x00=file +hwmon_in.frmt_0x0004_0x00=buf +hwmon_in.fpath_0x0004_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0004_0x00=0 +hwmon_in.len_0x0004_0x00=8 +hwmon_in.bit_offset_0x0004_0x00= +hwmon_in.str_cons_0x0004_0x00=in4_input +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_BOARD_VDD1.8V +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=ucd90160 +hwmon_in.mode_0x0004_0x03=constant +hwmon_in.int_cons_0x0004_0x03=1903 +hwmon_in.mode_0x0004_0x05=constant +hwmon_in.int_cons_0x0004_0x05=1720 +# in5 +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=0 +hwmon_in.src_0x0005_0x00=file +hwmon_in.frmt_0x0005_0x00=buf +hwmon_in.fpath_0x0005_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0005_0x00=0 +hwmon_in.len_0x0005_0x00=8 +hwmon_in.bit_offset_0x0005_0x00= +hwmon_in.str_cons_0x0005_0x00=in5_input +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_BOARD_VDD3.3V +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=ucd90160 +hwmon_in.mode_0x0005_0x03=constant +hwmon_in.int_cons_0x0005_0x03=3499 +hwmon_in.mode_0x0005_0x05=constant +hwmon_in.int_cons_0x0005_0x05=3170 +# in6 +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=0 +hwmon_in.src_0x0006_0x00=file +hwmon_in.frmt_0x0006_0x00=buf +hwmon_in.fpath_0x0006_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0006_0x00=0 +hwmon_in.len_0x0006_0x00=8 +hwmon_in.bit_offset_0x0006_0x00= +hwmon_in.str_cons_0x0006_0x00=in6_input +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_BOARD_VDD1.2V +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=ucd90160 +hwmon_in.mode_0x0006_0x03=constant +hwmon_in.int_cons_0x0006_0x03=1272 +hwmon_in.mode_0x0006_0x05=constant +hwmon_in.int_cons_0x0006_0x05=1150 +# in7 +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=0 +hwmon_in.src_0x0007_0x00=file +hwmon_in.frmt_0x0007_0x00=buf +hwmon_in.fpath_0x0007_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0007_0x00=0 +hwmon_in.len_0x0007_0x00=8 +hwmon_in.bit_offset_0x0007_0x00= +hwmon_in.str_cons_0x0007_0x00=in7_input +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_BOARD_VDD_CORE +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=ucd90160 +hwmon_in.mode_0x0007_0x03=constant +hwmon_in.int_cons_0x0007_0x03=950 +hwmon_in.mode_0x0007_0x05=constant +hwmon_in.int_cons_0x0007_0x05=670 +# in8 +hwmon_in.mode_0x0008_0x00=config +hwmon_in.int_cons_0x0008_0x00=0 +hwmon_in.src_0x0008_0x00=file +hwmon_in.frmt_0x0008_0x00=buf +hwmon_in.fpath_0x0008_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0008_0x00=0 +hwmon_in.len_0x0008_0x00=8 +hwmon_in.bit_offset_0x0008_0x00= +hwmon_in.str_cons_0x0008_0x00=in8_input +hwmon_in.mode_0x0008_0x01=str_constant +hwmon_in.str_cons_0x0008_0x01=MAC_BOARD_ANALOG0.75V +hwmon_in.mode_0x0008_0x02=str_constant +hwmon_in.str_cons_0x0008_0x02=ucd90160 +hwmon_in.mode_0x0008_0x03=constant +hwmon_in.int_cons_0x0008_0x03=800 +hwmon_in.mode_0x0008_0x05=constant +hwmon_in.int_cons_0x0008_0x05=700 +# in9 +hwmon_in.mode_0x0009_0x00=config +hwmon_in.int_cons_0x0009_0x00=0 +hwmon_in.src_0x0009_0x00=file +hwmon_in.frmt_0x0009_0x00=buf +hwmon_in.fpath_0x0009_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0009_0x00=0 +hwmon_in.len_0x0009_0x00=8 +hwmon_in.bit_offset_0x0009_0x00= +hwmon_in.str_cons_0x0009_0x00=in9_input +hwmon_in.mode_0x0009_0x01=str_constant +hwmon_in.str_cons_0x0009_0x01=MAC_BOARD_MAC_VDD1.2V +hwmon_in.mode_0x0009_0x02=str_constant +hwmon_in.str_cons_0x0009_0x02=ucd90160 +hwmon_in.mode_0x0009_0x03=constant +hwmon_in.int_cons_0x0009_0x03=1259 +hwmon_in.mode_0x0009_0x05=constant +hwmon_in.int_cons_0x0009_0x05=1140 +# in10 +hwmon_in.mode_0x000a_0x00=config +hwmon_in.int_cons_0x000a_0x00=0 +hwmon_in.src_0x000a_0x00=file +hwmon_in.frmt_0x000a_0x00=buf +hwmon_in.fpath_0x000a_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000a_0x00=0 +hwmon_in.len_0x000a_0x00=8 +hwmon_in.bit_offset_0x000a_0x00= +hwmon_in.str_cons_0x000a_0x00=in10_input +hwmon_in.mode_0x000a_0x01=str_constant +hwmon_in.str_cons_0x000a_0x01=MAC_BOARD_VDDO1.8V +hwmon_in.mode_0x000a_0x02=str_constant +hwmon_in.str_cons_0x000a_0x02=ucd90160 +hwmon_in.mode_0x000a_0x03=constant +hwmon_in.int_cons_0x000a_0x03=1937 +hwmon_in.mode_0x000a_0x05=constant +hwmon_in.int_cons_0x000a_0x05=1750 +# in11 +hwmon_in.mode_0x000b_0x00=config +hwmon_in.int_cons_0x000b_0x00=0 +hwmon_in.src_0x000b_0x00=file +hwmon_in.frmt_0x000b_0x00=buf +hwmon_in.fpath_0x000b_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000b_0x00=0 +hwmon_in.len_0x000b_0x00=8 +hwmon_in.bit_offset_0x000b_0x00= +hwmon_in.str_cons_0x000b_0x00=in11_input +hwmon_in.mode_0x000b_0x01=str_constant +hwmon_in.str_cons_0x000b_0x01=MAC_BOARD_MAC_ANA1.2V +hwmon_in.mode_0x000b_0x02=str_constant +hwmon_in.str_cons_0x000b_0x02=ucd90160 +hwmon_in.mode_0x000b_0x03=constant +hwmon_in.int_cons_0x000b_0x03=1276 +hwmon_in.mode_0x000b_0x05=constant +hwmon_in.int_cons_0x000b_0x05=1150 +# in12 +hwmon_in.mode_0x000c_0x00=config +hwmon_in.int_cons_0x000c_0x00=0 +hwmon_in.src_0x000c_0x00=file +hwmon_in.frmt_0x000c_0x00=buf +hwmon_in.fpath_0x000c_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000c_0x00=0 +hwmon_in.len_0x000c_0x00=8 +hwmon_in.bit_offset_0x000c_0x00= +hwmon_in.str_cons_0x000c_0x00=in12_input +hwmon_in.mode_0x000c_0x01=str_constant +hwmon_in.str_cons_0x000c_0x01=MAC_BOARD_MAC_ANA1.8V +hwmon_in.mode_0x000c_0x02=str_constant +hwmon_in.str_cons_0x000c_0x02=ucd90160 +hwmon_in.mode_0x000c_0x03=constant +hwmon_in.int_cons_0x000c_0x03=1910 +hwmon_in.mode_0x000c_0x05=constant +hwmon_in.int_cons_0x000c_0x05=1730 +# in13 +hwmon_in.mode_0x000d_0x00=config +hwmon_in.int_cons_0x000d_0x00=0 +hwmon_in.src_0x000d_0x00=file +hwmon_in.frmt_0x000d_0x00=buf +hwmon_in.fpath_0x000d_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000d_0x00=0 +hwmon_in.len_0x000d_0x00=8 +hwmon_in.bit_offset_0x000d_0x00= +hwmon_in.str_cons_0x000d_0x00=in13_input +hwmon_in.mode_0x000d_0x01=str_constant +hwmon_in.str_cons_0x000d_0x01=MAC_BOARD_QSFP56_VDD3.3V_A +hwmon_in.mode_0x000d_0x02=str_constant +hwmon_in.str_cons_0x000d_0x02=ucd90160 +hwmon_in.mode_0x000d_0x03=constant +hwmon_in.int_cons_0x000d_0x03=3595 +hwmon_in.mode_0x000d_0x05=constant +hwmon_in.int_cons_0x000d_0x05=3250 +# in14 +hwmon_in.mode_0x000e_0x00=config +hwmon_in.int_cons_0x000e_0x00=0 +hwmon_in.src_0x000e_0x00=file +hwmon_in.frmt_0x000e_0x00=buf +hwmon_in.fpath_0x000e_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000e_0x00=0 +hwmon_in.len_0x000e_0x00=8 +hwmon_in.bit_offset_0x000e_0x00= +hwmon_in.str_cons_0x000e_0x00=in14_input +hwmon_in.mode_0x000e_0x01=str_constant +hwmon_in.str_cons_0x000e_0x01=MAC_BOARD_QSFP56_VDD3.3V_B +hwmon_in.mode_0x000e_0x02=str_constant +hwmon_in.str_cons_0x000e_0x02=ucd90160 +hwmon_in.mode_0x000e_0x03=constant +hwmon_in.int_cons_0x000e_0x03=3601 +hwmon_in.mode_0x000e_0x05=constant +hwmon_in.int_cons_0x000e_0x05=3260 +# in15 +hwmon_in.mode_0x000f_0x00=config +hwmon_in.int_cons_0x000f_0x00=0 +hwmon_in.src_0x000f_0x00=file +hwmon_in.frmt_0x000f_0x00=buf +hwmon_in.fpath_0x000f_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x000f_0x00=0 +hwmon_in.len_0x000f_0x00=8 +hwmon_in.bit_offset_0x000f_0x00= +hwmon_in.str_cons_0x000f_0x00=in15_input +hwmon_in.mode_0x000f_0x01=str_constant +hwmon_in.str_cons_0x000f_0x01=MAC_BOARD_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x000f_0x02=str_constant +hwmon_in.str_cons_0x000f_0x02=ucd90160 +hwmon_in.mode_0x000f_0x03=constant +hwmon_in.int_cons_0x000f_0x03=3565 +hwmon_in.mode_0x000f_0x05=constant +hwmon_in.int_cons_0x000f_0x05=3230 +# in16 +hwmon_in.mode_0x0010_0x00=config +hwmon_in.int_cons_0x0010_0x00=0 +hwmon_in.src_0x0010_0x00=file +hwmon_in.frmt_0x0010_0x00=buf +hwmon_in.fpath_0x0010_0x00=/sys/bus/i2c/devices/45-005b/hwmon/ +hwmon_in.addr_0x0010_0x00=0 +hwmon_in.len_0x0010_0x00=8 +hwmon_in.bit_offset_0x0010_0x00= +hwmon_in.str_cons_0x0010_0x00=in16_input +hwmon_in.mode_0x0010_0x01=str_constant +hwmon_in.str_cons_0x0010_0x01=MAC_BOARD_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0010_0x02=str_constant +hwmon_in.str_cons_0x0010_0x02=ucd90160 +hwmon_in.mode_0x0010_0x03=constant +hwmon_in.int_cons_0x0010_0x03=3564 +hwmon_in.mode_0x0010_0x05=constant +hwmon_in.int_cons_0x0010_0x05=3220 +# in17 +hwmon_in.mode_0x0011_0x00=config +hwmon_in.int_cons_0x0011_0x00=0 +hwmon_in.src_0x0011_0x00=file +hwmon_in.frmt_0x0011_0x00=buf +hwmon_in.fpath_0x0011_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0011_0x00=0 +hwmon_in.len_0x0011_0x00=8 +hwmon_in.bit_offset_0x0011_0x00= +hwmon_in.str_cons_0x0011_0x00=in1_input +hwmon_in.mode_0x0011_0x01=str_constant +hwmon_in.str_cons_0x0011_0x01=CPU_CONNECT_VDD5.0V +hwmon_in.mode_0x0011_0x02=str_constant +hwmon_in.str_cons_0x0011_0x02=ucd90160 +hwmon_in.mode_0x0011_0x03=constant +hwmon_in.int_cons_0x0011_0x03=5429 +hwmon_in.mode_0x0011_0x05=constant +hwmon_in.int_cons_0x0011_0x05=4910 +# in18 +hwmon_in.mode_0x0012_0x00=config +hwmon_in.int_cons_0x0012_0x00=0 +hwmon_in.src_0x0012_0x00=file +hwmon_in.frmt_0x0012_0x00=buf +hwmon_in.fpath_0x0012_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0012_0x00=0 +hwmon_in.len_0x0012_0x00=8 +hwmon_in.bit_offset_0x0012_0x00= +hwmon_in.str_cons_0x0012_0x00=in4_input +hwmon_in.mode_0x0012_0x01=str_constant +hwmon_in.str_cons_0x0012_0x01=CPU_CONNECT_VDD3.3V +hwmon_in.mode_0x0012_0x02=str_constant +hwmon_in.str_cons_0x0012_0x02=ucd90160 +hwmon_in.mode_0x0012_0x03=constant +hwmon_in.int_cons_0x0012_0x03=3437 +hwmon_in.mode_0x0012_0x05=constant +hwmon_in.int_cons_0x0012_0x05=3110 +# in19 +hwmon_in.mode_0x0013_0x00=config +hwmon_in.int_cons_0x0013_0x00=0 +hwmon_in.src_0x0013_0x00=file +hwmon_in.frmt_0x0013_0x00=buf +hwmon_in.fpath_0x0013_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0013_0x00=0 +hwmon_in.len_0x0013_0x00=8 +hwmon_in.bit_offset_0x0013_0x00= +hwmon_in.str_cons_0x0013_0x00=in6_input +hwmon_in.mode_0x0013_0x01=str_constant +hwmon_in.str_cons_0x0013_0x01=CPU_CONNECT_VDD12V +hwmon_in.mode_0x0013_0x02=str_constant +hwmon_in.str_cons_0x0013_0x02=ucd90160 +hwmon_in.mode_0x0013_0x03=constant +hwmon_in.int_cons_0x0013_0x03=12700 +hwmon_in.mode_0x0013_0x05=constant +hwmon_in.int_cons_0x0013_0x05=11300 +# in20 +hwmon_in.mode_0x0014_0x00=config +hwmon_in.int_cons_0x0014_0x00=0 +hwmon_in.src_0x0014_0x00=file +hwmon_in.frmt_0x0014_0x00=buf +hwmon_in.fpath_0x0014_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0014_0x00=0 +hwmon_in.len_0x0014_0x00=8 +hwmon_in.bit_offset_0x0014_0x00= +hwmon_in.str_cons_0x0014_0x00=in7_input +hwmon_in.mode_0x0014_0x01=str_constant +hwmon_in.str_cons_0x0014_0x01=CPU_CONNECT_VDD3.3_STBY +hwmon_in.mode_0x0014_0x02=str_constant +hwmon_in.str_cons_0x0014_0x02=ucd90160 +hwmon_in.mode_0x0014_0x03=constant +hwmon_in.int_cons_0x0014_0x03=3489 +hwmon_in.mode_0x0014_0x05=constant +hwmon_in.int_cons_0x0014_0x05=3160 +# in21 +hwmon_in.mode_0x0015_0x00=config +hwmon_in.int_cons_0x0015_0x00=0 +hwmon_in.src_0x0015_0x00=file +hwmon_in.frmt_0x0015_0x00=buf +hwmon_in.fpath_0x0015_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0015_0x00=0 +hwmon_in.len_0x0015_0x00=8 +hwmon_in.bit_offset_0x0015_0x00= +hwmon_in.str_cons_0x0015_0x00=in8_input +hwmon_in.mode_0x0015_0x01=str_constant +hwmon_in.str_cons_0x0015_0x01=CPU_CONNECT_SSD_VDD3.3V +hwmon_in.mode_0x0015_0x02=str_constant +hwmon_in.str_cons_0x0015_0x02=ucd90160 +hwmon_in.mode_0x0015_0x03=constant +hwmon_in.int_cons_0x0015_0x03=3475 +hwmon_in.mode_0x0015_0x05=constant +hwmon_in.int_cons_0x0015_0x05=3140 +# in22 +hwmon_in.mode_0x0016_0x00=config +hwmon_in.int_cons_0x0016_0x00=0 +hwmon_in.src_0x0016_0x00=file +hwmon_in.frmt_0x0016_0x00=buf +hwmon_in.fpath_0x0016_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0016_0x00=0 +hwmon_in.len_0x0016_0x00=8 +hwmon_in.bit_offset_0x0016_0x00= +hwmon_in.str_cons_0x0016_0x00=in9_input +hwmon_in.mode_0x0016_0x01=str_constant +hwmon_in.str_cons_0x0016_0x01=CPU_CONNECT_PHY_VDD1V0 +hwmon_in.mode_0x0016_0x02=str_constant +hwmon_in.str_cons_0x0016_0x02=ucd90160 +hwmon_in.mode_0x0016_0x03=constant +hwmon_in.int_cons_0x0016_0x03=1050 +hwmon_in.mode_0x0016_0x05=constant +hwmon_in.int_cons_0x0016_0x05=950 +# in23 +hwmon_in.mode_0x0017_0x00=config +hwmon_in.int_cons_0x0017_0x00=0 +hwmon_in.src_0x0017_0x00=file +hwmon_in.frmt_0x0017_0x00=buf +hwmon_in.fpath_0x0017_0x00=/sys/bus/i2c/devices/24-005b/hwmon/ +hwmon_in.addr_0x0017_0x00=0 +hwmon_in.len_0x0017_0x00=8 +hwmon_in.bit_offset_0x0017_0x00= +hwmon_in.str_cons_0x0017_0x00=in11_input +hwmon_in.mode_0x0017_0x01=str_constant +hwmon_in.str_cons_0x0017_0x01=CPU_CONNECT_ODD_PHY_M +hwmon_in.mode_0x0017_0x02=str_constant +hwmon_in.str_cons_0x0017_0x02=ucd90160 +hwmon_in.mode_0x0017_0x03=constant +hwmon_in.int_cons_0x0017_0x03=3444 +hwmon_in.mode_0x0017_0x05=constant +hwmon_in.int_cons_0x0017_0x05=3116 +# in24 +hwmon_in.mode_0x0018_0x00=config +hwmon_in.int_cons_0x0018_0x00=0 +hwmon_in.src_0x0018_0x00=file +hwmon_in.frmt_0x0018_0x00=buf +hwmon_in.fpath_0x0018_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_in.addr_0x0018_0x00=0 +hwmon_in.len_0x0018_0x00=8 +hwmon_in.bit_offset_0x0018_0x00= +hwmon_in.str_cons_0x0018_0x00=in3_input +hwmon_in.mode_0x0018_0x01=str_constant +hwmon_in.str_cons_0x0018_0x01=CPU_VCCIN +hwmon_in.mode_0x0018_0x02=str_constant +hwmon_in.str_cons_0x0018_0x02=tps53622 +hwmon_in.mode_0x0018_0x03=constant +hwmon_in.int_cons_0x0018_0x03=1879 +hwmon_in.mode_0x0018_0x05=constant +hwmon_in.int_cons_0x0018_0x05=1700 +# in25 +hwmon_in.mode_0x0019_0x00=config +hwmon_in.int_cons_0x0019_0x00=0 +hwmon_in.src_0x0019_0x00=file +hwmon_in.frmt_0x0019_0x00=buf +hwmon_in.fpath_0x0019_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_in.addr_0x0019_0x00=0 +hwmon_in.len_0x0019_0x00=8 +hwmon_in.bit_offset_0x0019_0x00= +hwmon_in.str_cons_0x0019_0x00=in4_input +hwmon_in.mode_0x0019_0x01=str_constant +hwmon_in.str_cons_0x0019_0x01=CPU_P1V05 +hwmon_in.mode_0x0019_0x02=str_constant +hwmon_in.str_cons_0x0019_0x02=tps53622 +hwmon_in.mode_0x0019_0x03=constant +hwmon_in.int_cons_0x0019_0x03=1103 +hwmon_in.mode_0x0019_0x05=constant +hwmon_in.int_cons_0x0019_0x05=1000 +# in26 +hwmon_in.mode_0x001a_0x00=config +hwmon_in.int_cons_0x001a_0x00=0 +hwmon_in.src_0x001a_0x00=file +hwmon_in.frmt_0x001a_0x00=buf +hwmon_in.fpath_0x001a_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_in.addr_0x001a_0x00=0 +hwmon_in.len_0x001a_0x00=8 +hwmon_in.bit_offset_0x001a_0x00= +hwmon_in.str_cons_0x001a_0x00=in3_input +hwmon_in.mode_0x001a_0x01=str_constant +hwmon_in.str_cons_0x001a_0x01=CPU_P1V2_VDDQ +hwmon_in.mode_0x001a_0x02=str_constant +hwmon_in.str_cons_0x001a_0x02=tps53622 +hwmon_in.mode_0x001a_0x03=constant +hwmon_in.int_cons_0x001a_0x03=1258 +hwmon_in.mode_0x001a_0x05=constant +hwmon_in.int_cons_0x001a_0x05=1140 +# in27 +hwmon_in.mode_0x001b_0x00=config +hwmon_in.int_cons_0x001b_0x00=3 +hwmon_in.src_0x001b_0x00=file +hwmon_in.frmt_0x001b_0x00=buf +hwmon_in.fpath_0x001b_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_in.addr_0x001b_0x00=0 +hwmon_in.len_0x001b_0x00=8 +hwmon_in.bit_offset_0x001b_0x00=0 +hwmon_in.str_cons_0x001b_0x00=in4_input +hwmon_in.int_extra1_0x001b_0x00=1124 +hwmon_in.mode_0x001b_0x01=str_constant +hwmon_in.str_cons_0x001b_0x01=CPU_P2V5_VPP +hwmon_in.mode_0x001b_0x02=str_constant +hwmon_in.str_cons_0x001b_0x02=tps53622 +hwmon_in.mode_0x001b_0x03=constant +hwmon_in.int_cons_0x001b_0x03=2632 +hwmon_in.mode_0x001b_0x05=constant +hwmon_in.int_cons_0x001b_0x05=2380 +# in28 +hwmon_in.mode_0x001c_0x00=config +hwmon_in.int_cons_0x001c_0x00=0 +hwmon_in.src_0x001c_0x00=file +hwmon_in.frmt_0x001c_0x00=buf +hwmon_in.fpath_0x001c_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001c_0x00=0 +hwmon_in.len_0x001c_0x00=8 +hwmon_in.bit_offset_0x001c_0x00= +hwmon_in.str_cons_0x001c_0x00=in1_input +hwmon_in.mode_0x001c_0x01=str_constant +hwmon_in.str_cons_0x001c_0x01=CPU_P3V3_STBY +hwmon_in.mode_0x001c_0x02=str_constant +hwmon_in.str_cons_0x001c_0x02=ina3221 +hwmon_in.mode_0x001c_0x03=constant +hwmon_in.int_cons_0x001c_0x03=3476 +hwmon_in.mode_0x001c_0x05=constant +hwmon_in.int_cons_0x001c_0x05=3140 +# in29 +hwmon_in.mode_0x001d_0x00=config +hwmon_in.int_cons_0x001d_0x00=0 +hwmon_in.src_0x001d_0x00=file +hwmon_in.frmt_0x001d_0x00=buf +hwmon_in.fpath_0x001d_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001d_0x00=0 +hwmon_in.len_0x001d_0x00=8 +hwmon_in.bit_offset_0x001d_0x00= +hwmon_in.str_cons_0x001d_0x00=in2_input +hwmon_in.mode_0x001d_0x01=str_constant +hwmon_in.str_cons_0x001d_0x01=CPU_P5V_AUX_IN +hwmon_in.mode_0x001d_0x02=str_constant +hwmon_in.str_cons_0x001d_0x02=ina3221 +hwmon_in.mode_0x001d_0x03=constant +hwmon_in.int_cons_0x001d_0x03=5229 +hwmon_in.mode_0x001d_0x05=constant +hwmon_in.int_cons_0x001d_0x05=4730 +# in30 +hwmon_in.mode_0x001e_0x00=config +hwmon_in.int_cons_0x001e_0x00=0 +hwmon_in.src_0x001e_0x00=file +hwmon_in.frmt_0x001e_0x00=buf +hwmon_in.fpath_0x001e_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_in.addr_0x001e_0x00=0 +hwmon_in.len_0x001e_0x00=8 +hwmon_in.bit_offset_0x001e_0x00= +hwmon_in.str_cons_0x001e_0x00=in3_input +hwmon_in.mode_0x001e_0x01=str_constant +hwmon_in.str_cons_0x001e_0x01=CPU_P1V7_VCCSCFUSESUS_IN +hwmon_in.mode_0x001e_0x02=str_constant +hwmon_in.str_cons_0x001e_0x02=ina3221 +hwmon_in.mode_0x001e_0x03=constant +hwmon_in.int_cons_0x001e_0x03=1789 +hwmon_in.mode_0x001e_0x05=constant +hwmon_in.int_cons_0x001e_0x05=1620 + +# curr1 +hwmon_curr.mode_0x0001_0x00=config +hwmon_curr.int_cons_0x0001_0x00=0 +hwmon_curr.src_0x0001_0x00=file +hwmon_curr.frmt_0x0001_0x00=buf +hwmon_curr.fpath_0x0001_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_curr.addr_0x0001_0x00=0 +hwmon_curr.len_0x0001_0x00=8 +hwmon_curr.bit_offset_0x0001_0x00= +hwmon_curr.str_cons_0x0001_0x00=curr1_input + +hwmon_curr.mode_0x0001_0x01=str_constant +hwmon_curr.str_cons_0x0001_0x01=CPU_VCCIN_C + +hwmon_curr.mode_0x0001_0x02=str_constant +hwmon_curr.str_cons_0x0001_0x02=tps53622 + +hwmon_curr.mode_0x0001_0x03=constant +hwmon_curr.int_cons_0x0001_0x03=47300 + +hwmon_curr.mode_0x0001_0x05=constant +hwmon_curr.int_cons_0x0001_0x05=0 + +# curr2 +hwmon_curr.mode_0x0002_0x00=config +hwmon_curr.int_cons_0x0002_0x00=0 +hwmon_curr.src_0x0002_0x00=file +hwmon_curr.frmt_0x0002_0x00=buf +hwmon_curr.fpath_0x0002_0x00=/sys/bus/i2c/devices/25-0060/hwmon/ +hwmon_curr.addr_0x0002_0x00=0 +hwmon_curr.len_0x0002_0x00=8 +hwmon_curr.bit_offset_0x0002_0x00= +hwmon_curr.str_cons_0x0002_0x00=curr2_input + +hwmon_curr.mode_0x0002_0x01=str_constant +hwmon_curr.str_cons_0x0002_0x01=CPU_P1V05_C + +hwmon_curr.mode_0x0002_0x02=str_constant +hwmon_curr.str_cons_0x0002_0x02=tps53622 + +hwmon_curr.mode_0x0002_0x03=constant +hwmon_curr.int_cons_0x0002_0x03=15400 + +hwmon_curr.mode_0x0002_0x05=constant +hwmon_curr.int_cons_0x0002_0x05=0 + +# curr3 +hwmon_curr.mode_0x0003_0x00=config +hwmon_curr.int_cons_0x0003_0x00=0 +hwmon_curr.src_0x0003_0x00=file +hwmon_curr.frmt_0x0003_0x00=buf +hwmon_curr.fpath_0x0003_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_curr.addr_0x0003_0x00=0 +hwmon_curr.len_0x0003_0x00=8 +hwmon_curr.bit_offset_0x0003_0x00= +hwmon_curr.str_cons_0x0003_0x00=curr1_input + +hwmon_curr.mode_0x0003_0x01=str_constant +hwmon_curr.str_cons_0x0003_0x01=CPU_P1V2_VDDQ_C + +hwmon_curr.mode_0x0003_0x02=str_constant +hwmon_curr.str_cons_0x0003_0x02=tps53622 + +hwmon_curr.mode_0x0003_0x03=constant +hwmon_curr.int_cons_0x0003_0x03=9900 + +hwmon_curr.mode_0x0003_0x05=constant +hwmon_curr.int_cons_0x0003_0x05=0 + +# curr4 +hwmon_curr.mode_0x0004_0x00=config +hwmon_curr.int_cons_0x0004_0x00=0 +hwmon_curr.src_0x0004_0x00=file +hwmon_curr.frmt_0x0004_0x00=buf +hwmon_curr.fpath_0x0004_0x00=/sys/bus/i2c/devices/25-006c/hwmon/ +hwmon_curr.addr_0x0004_0x00=0 +hwmon_curr.len_0x0004_0x00=8 +hwmon_curr.bit_offset_0x0004_0x00= +hwmon_curr.str_cons_0x0004_0x00=curr2_input + +hwmon_curr.mode_0x0004_0x01=str_constant +hwmon_curr.str_cons_0x0004_0x01=CPU_P2V5_VPP_C + +hwmon_curr.mode_0x0004_0x02=str_constant +hwmon_curr.str_cons_0x0004_0x02=tps53622 + +hwmon_curr.mode_0x0004_0x03=constant +hwmon_curr.int_cons_0x0004_0x03=2200 + +hwmon_curr.mode_0x0004_0x05=constant +hwmon_curr.int_cons_0x0004_0x05=0 + +# curr5 +hwmon_curr.mode_0x0005_0x00=config +hwmon_curr.int_cons_0x0005_0x00=0 +hwmon_curr.src_0x0005_0x00=file +hwmon_curr.frmt_0x0005_0x00=buf +hwmon_curr.fpath_0x0005_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0005_0x00=0 +hwmon_curr.len_0x0005_0x00=8 +hwmon_curr.bit_offset_0x0005_0x00= +hwmon_curr.str_cons_0x0005_0x00=curr1_input + +hwmon_curr.mode_0x0005_0x01=str_constant +hwmon_curr.str_cons_0x0005_0x01=CPU_P3V3_STBY_C + +hwmon_curr.mode_0x0005_0x02=str_constant +hwmon_curr.str_cons_0x0005_0x02=ina3221 + +hwmon_curr.mode_0x0005_0x03=constant +hwmon_curr.int_cons_0x0005_0x03=4686 + +hwmon_curr.mode_0x0005_0x05=constant +hwmon_curr.int_cons_0x0005_0x05=0 + +# curr6 +hwmon_curr.mode_0x0006_0x00=config +hwmon_curr.int_cons_0x0006_0x00=0 +hwmon_curr.src_0x0006_0x00=file +hwmon_curr.frmt_0x0006_0x00=buf +hwmon_curr.fpath_0x0006_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0006_0x00=0 +hwmon_curr.len_0x0006_0x00=8 +hwmon_curr.bit_offset_0x0006_0x00= +hwmon_curr.str_cons_0x0006_0x00=curr2_input + +hwmon_curr.mode_0x0006_0x01=str_constant +hwmon_curr.str_cons_0x0006_0x01=CPU_P5V_AUX_IN_C + +hwmon_curr.mode_0x0006_0x02=str_constant +hwmon_curr.str_cons_0x0006_0x02=ina3221 + +hwmon_curr.mode_0x0006_0x03=constant +hwmon_curr.int_cons_0x0006_0x03=2200 + +hwmon_curr.mode_0x0006_0x05=constant +hwmon_curr.int_cons_0x0006_0x05=0 + +# curr7 +hwmon_curr.mode_0x0007_0x00=config +hwmon_curr.int_cons_0x0007_0x00=0 +hwmon_curr.src_0x0007_0x00=file +hwmon_curr.frmt_0x0007_0x00=buf +hwmon_curr.fpath_0x0007_0x00=/sys/bus/i2c/devices/25-0043/hwmon/ +hwmon_curr.addr_0x0007_0x00=0 +hwmon_curr.len_0x0007_0x00=8 +hwmon_curr.bit_offset_0x0007_0x00= +hwmon_curr.str_cons_0x0007_0x00=curr3_input + +hwmon_curr.mode_0x0007_0x01=str_constant +hwmon_curr.str_cons_0x0007_0x01=CPU_P1V7_VCCSCFUSESUS_IN_C + +hwmon_curr.mode_0x0007_0x02=str_constant +hwmon_curr.str_cons_0x0007_0x02=ina3221 + +hwmon_curr.mode_0x0007_0x03=constant +hwmon_curr.int_cons_0x0007_0x03=2200 + +hwmon_curr.mode_0x0007_0x05=constant +hwmon_curr.int_cons_0x0007_0x05=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-CPLD.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-CPLD.cfg new file mode 100755 index 000000000000..6c669c649626 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-CPLD.cfg @@ -0,0 +1,219 @@ +other_i2c_dev.bus_0_0=1 +other_i2c_dev.addr_0_0=0x56 + +eeprom_path_0_0=/sys/bus/i2c/devices/1-0056/eeprom + +eeprom_size_0_0=256 + +watchdog_id_0=0 + +watchdog_name_0_0=identity +watchdog_name_0_1=state +watchdog_name_0_2=timeleft +watchdog_name_0_3=timeout + +cpld_i2c_dev.bus_0_2=60 +cpld_i2c_dev.addr_0_2=0x3d +cpld_i2c_dev.bus_0_3=87 +cpld_i2c_dev.addr_0_3=0x0d +cpld_i2c_dev.bus_0_4=95 +cpld_i2c_dev.addr_0_4=0x0d +cpld_i2c_dev.bus_0_5=77 +cpld_i2c_dev.addr_0_5=0x1d +cpld_i2c_dev.bus_0_6=77 +cpld_i2c_dev.addr_0_6=0x2d +cpld_i2c_dev.bus_0_7=111 +cpld_i2c_dev.addr_0_7=0x3d + +cpld_lpc_dev_0_0=0x700 +cpld_lpc_dev_0_1=0x900 + +mode_cpld_0_0=lpc +mode_cpld_0_1=lpc +mode_cpld_0_2=i2c +mode_cpld_0_3=i2c +mode_cpld_0_4=i2c +mode_cpld_0_5=i2c +mode_cpld_0_6=i2c +mode_cpld_0_7=i2c + +dev_num_0_8=8 + +cpld_name_0_0=CPU_CPLD +cpld_name_0_1=BASE_CPLD +cpld_name_0_2=UPORT_CPLD +cpld_name_0_3=UFCB_CPLD +cpld_name_0_4=DFCB_CPLD +cpld_name_0_5=MAC_CPLDA +cpld_name_0_6=MAC_CPLDB +cpld_name_0_7=DPORT_CPLD + +cpld_type_0_0=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_1=LATTICE/LCMXO3LF-4300C-6BG324I +cpld_type_0_2=LATTICE/LCMXO3LF-4300C-6BG324I +cpld_type_0_3=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_4=LATTICE/LCMXO3LF-2100C-5BG256C +cpld_type_0_5=LATTICE/LCMXO3LF-4300C-6BG324I +cpld_type_0_6=LATTICE/LCMXO3LF-4300C-6BG324I +cpld_type_0_7=LATTICE/LCMXO3LF-4300C-6BG324I + +cpld_version.mode_0_0=config +cpld_version.int_cons_0_0= +cpld_version.src_0_0=cpld +cpld_version.frmt_0_0=num_bytes +cpld_version.pola_0_0= +cpld_version.fpath_0_0= +cpld_version.addr_0_0=0x00000000 +cpld_version.len_0_0=4 +cpld_version.bit_offset_0_0= + +cpld_version.mode_0_1=config +cpld_version.int_cons_0_1= +cpld_version.src_0_1=cpld +cpld_version.frmt_0_1=num_bytes +cpld_version.pola_0_1= +cpld_version.fpath_0_1= +cpld_version.addr_0_1=0x00010000 +cpld_version.len_0_1=4 +cpld_version.bit_offset_0_1= + +cpld_version.mode_0_2=config +cpld_version.int_cons_0_2= +cpld_version.src_0_2=cpld +cpld_version.frmt_0_2=num_bytes +cpld_version.pola_0_2= +cpld_version.fpath_0_2= +cpld_version.addr_0_2=0x00020000 +cpld_version.len_0_2=4 +cpld_version.bit_offset_0_2= + +cpld_version.mode_0_3=config +cpld_version.int_cons_0_3= +cpld_version.src_0_3=cpld +cpld_version.frmt_0_3=num_bytes +cpld_version.pola_0_3= +cpld_version.fpath_0_3= +cpld_version.addr_0_3=0x00030000 +cpld_version.len_0_3=4 +cpld_version.bit_offset_0_3= + +cpld_version.mode_0_4=config +cpld_version.int_cons_0_4= +cpld_version.src_0_4=cpld +cpld_version.frmt_0_4=num_bytes +cpld_version.pola_0_4= +cpld_version.fpath_0_4= +cpld_version.addr_0_4=0x00040000 +cpld_version.len_0_4=4 +cpld_version.bit_offset_0_4= + +cpld_version.mode_0_5=config +cpld_version.int_cons_0_5= +cpld_version.src_0_5=cpld +cpld_version.frmt_0_5=num_bytes +cpld_version.pola_0_5= +cpld_version.fpath_0_5= +cpld_version.addr_0_5=0x00050000 +cpld_version.len_0_5=4 +cpld_version.bit_offset_0_5= + +cpld_version.mode_0_6=config +cpld_version.int_cons_0_6= +cpld_version.src_0_6=cpld +cpld_version.frmt_0_6=num_bytes +cpld_version.pola_0_6= +cpld_version.fpath_0_6= +cpld_version.addr_0_6=0x00060000 +cpld_version.len_0_6=4 +cpld_version.bit_offset_0_6= + +cpld_version.mode_0_7=config +cpld_version.int_cons_0_7= +cpld_version.src_0_7=cpld +cpld_version.frmt_0_7=num_bytes +cpld_version.pola_0_7= +cpld_version.fpath_0_7= +cpld_version.addr_0_7=0x00070000 +cpld_version.len_0_7=4 +cpld_version.bit_offset_0_7= + +cpld_test_reg.mode_0_0=config +cpld_test_reg.int_cons_0_0= +cpld_test_reg.src_0_0=cpld +cpld_test_reg.frmt_0_0=byte +cpld_test_reg.pola_0_0= +cpld_test_reg.fpath_0_0= +cpld_test_reg.addr_0_0=0x00000005 +cpld_test_reg.len_0_0=1 +cpld_test_reg.bit_offset_0_0= + +cpld_test_reg.mode_0_1=config +cpld_test_reg.int_cons_0_1= +cpld_test_reg.src_0_1=cpld +cpld_test_reg.frmt_0_1=byte +cpld_test_reg.pola_0_1= +cpld_test_reg.fpath_0_1= +cpld_test_reg.addr_0_1=0x00010055 +cpld_test_reg.len_0_1=1 +cpld_test_reg.bit_offset_0_1= + +cpld_test_reg.mode_0_2=config +cpld_test_reg.int_cons_0_2= +cpld_test_reg.src_0_2=cpld +cpld_test_reg.frmt_0_2=byte +cpld_test_reg.pola_0_2= +cpld_test_reg.fpath_0_2= +cpld_test_reg.addr_0_2=0x000200aa +cpld_test_reg.len_0_2=1 +cpld_test_reg.bit_offset_0_2= + +cpld_test_reg.mode_0_3=config +cpld_test_reg.int_cons_0_3= +cpld_test_reg.src_0_3=cpld +cpld_test_reg.frmt_0_3=byte +cpld_test_reg.pola_0_3= +cpld_test_reg.fpath_0_3= +cpld_test_reg.addr_0_3=0x000300aa +cpld_test_reg.len_0_3=1 +cpld_test_reg.bit_offset_0_3= + +cpld_test_reg.mode_0_4=config +cpld_test_reg.int_cons_0_4= +cpld_test_reg.src_0_4=cpld +cpld_test_reg.frmt_0_4=byte +cpld_test_reg.pola_0_4= +cpld_test_reg.fpath_0_4= +cpld_test_reg.addr_0_4=0x000400aa +cpld_test_reg.len_0_4=1 +cpld_test_reg.bit_offset_0_4= + +cpld_test_reg.mode_0_5=config +cpld_test_reg.int_cons_0_5= +cpld_test_reg.src_0_5=cpld +cpld_test_reg.frmt_0_5=byte +cpld_test_reg.pola_0_5= +cpld_test_reg.fpath_0_5= +cpld_test_reg.addr_0_5=0x00050055 +cpld_test_reg.len_0_5=1 +cpld_test_reg.bit_offset_0_5= + +cpld_test_reg.mode_0_6=config +cpld_test_reg.int_cons_0_6= +cpld_test_reg.src_0_6=cpld +cpld_test_reg.frmt_0_6=byte +cpld_test_reg.pola_0_6= +cpld_test_reg.fpath_0_6= +cpld_test_reg.addr_0_6=0x000600aa +cpld_test_reg.len_0_6=1 +cpld_test_reg.bit_offset_0_6= + +cpld_test_reg.mode_0_7=config +cpld_test_reg.int_cons_0_7= +cpld_test_reg.src_0_7=cpld +cpld_test_reg.frmt_0_7=byte +cpld_test_reg.pola_0_7= +cpld_test_reg.fpath_0_7= +cpld_test_reg.addr_0_7=0x000700aa +cpld_test_reg.len_0_7=1 +cpld_test_reg.bit_offset_0_7= + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FAN.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FAN.cfg new file mode 100755 index 000000000000..3bd43a58c525 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FAN.cfg @@ -0,0 +1,501 @@ +other_i2c_dev.bus_1_1=90 +other_i2c_dev.addr_1_1=0x50 +other_i2c_dev.bus_1_2=98 +other_i2c_dev.addr_1_2=0x50 +other_i2c_dev.bus_1_3=91 +other_i2c_dev.addr_1_3=0x50 +other_i2c_dev.bus_1_4=99 +other_i2c_dev.addr_1_4=0x50 +other_i2c_dev.bus_1_5=92 +other_i2c_dev.addr_1_5=0x50 +other_i2c_dev.bus_1_6=100 +other_i2c_dev.addr_1_6=0x50 +other_i2c_dev.bus_1_7=93 +other_i2c_dev.addr_1_7=0x50 +other_i2c_dev.bus_1_8=101 +other_i2c_dev.addr_1_8=0x50 + +# fan number +dev_num_1_0=8 + +# fan motor number +dev_num_1_5=2 + +fan_e2_mode=fru + +fan_sysfs_name=eeprom + +fan_direction_0_1=FAN12K8080-F + +dev_present_status.mode_1_1=config +dev_present_status.src_1_1=cpld +dev_present_status.frmt_1_1=bit +dev_present_status.pola_1_1=negative +dev_present_status.addr_1_1=0x00030030 +dev_present_status.len_1_1=1 +dev_present_status.bit_offset_1_1=0 + +dev_present_status.mode_1_2=config +dev_present_status.src_1_2=cpld +dev_present_status.frmt_1_2=bit +dev_present_status.pola_1_2=negative +dev_present_status.addr_1_2=0x00040030 +dev_present_status.len_1_2=1 +dev_present_status.bit_offset_1_2=0 + +dev_present_status.mode_1_3=config +dev_present_status.src_1_3=cpld +dev_present_status.frmt_1_3=bit +dev_present_status.pola_1_3=negative +dev_present_status.addr_1_3=0x00030030 +dev_present_status.len_1_3=1 +dev_present_status.bit_offset_1_3=1 + +dev_present_status.mode_1_4=config +dev_present_status.src_1_4=cpld +dev_present_status.frmt_1_4=bit +dev_present_status.pola_1_4=negative +dev_present_status.addr_1_4=0x00040030 +dev_present_status.len_1_4=1 +dev_present_status.bit_offset_1_4=1 + +dev_present_status.mode_1_5=config +dev_present_status.src_1_5=cpld +dev_present_status.frmt_1_5=bit +dev_present_status.pola_1_5=negative +dev_present_status.addr_1_5=0x00030030 +dev_present_status.len_1_5=1 +dev_present_status.bit_offset_1_5=2 + +dev_present_status.mode_1_6=config +dev_present_status.src_1_6=cpld +dev_present_status.frmt_1_6=bit +dev_present_status.pola_1_6=negative +dev_present_status.addr_1_6=0x00040030 +dev_present_status.len_1_6=1 +dev_present_status.bit_offset_1_6=2 + +dev_present_status.mode_1_7=config +dev_present_status.src_1_7=cpld +dev_present_status.frmt_1_7=bit +dev_present_status.pola_1_7=negative +dev_present_status.addr_1_7=0x00030030 +dev_present_status.len_1_7=1 +dev_present_status.bit_offset_1_7=3 + +dev_present_status.mode_1_8=config +dev_present_status.src_1_8=cpld +dev_present_status.frmt_1_8=bit +dev_present_status.pola_1_8=negative +dev_present_status.addr_1_8=0x00040030 +dev_present_status.len_1_8=1 +dev_present_status.bit_offset_1_8=3 + +fan_roll_status.mode_1_1=config +fan_roll_status.int_cons_1_1= +fan_roll_status.src_1_1=cpld +fan_roll_status.frmt_1_1=bit +fan_roll_status.pola_1_1=positive +fan_roll_status.fpath_1_1= +fan_roll_status.addr_1_1=0x00030031 +fan_roll_status.len_1_1=1 +fan_roll_status.bit_offset_1_1=0 + +fan_roll_status.mode_1_2=config +fan_roll_status.int_cons_1_2= +fan_roll_status.src_1_2=cpld +fan_roll_status.frmt_1_2=bit +fan_roll_status.pola_1_2=positive +fan_roll_status.fpath_1_2= +fan_roll_status.addr_1_2=0x00030034 +fan_roll_status.len_1_2=1 +fan_roll_status.bit_offset_1_2=0 + +fan_roll_status.mode_2_1=config +fan_roll_status.int_cons_2_1= +fan_roll_status.src_2_1=cpld +fan_roll_status.frmt_2_1=bit +fan_roll_status.pola_2_1=positive +fan_roll_status.fpath_2_1= +fan_roll_status.addr_2_1=0x00040031 +fan_roll_status.len_2_1=1 +fan_roll_status.bit_offset_2_1=0 + +fan_roll_status.mode_2_2=config +fan_roll_status.int_cons_2_2= +fan_roll_status.src_2_2=cpld +fan_roll_status.frmt_2_2=bit +fan_roll_status.pola_2_2=positive +fan_roll_status.fpath_2_2= +fan_roll_status.addr_2_2=0x00040034 +fan_roll_status.len_2_2=1 +fan_roll_status.bit_offset_2_2=0 + +fan_roll_status.mode_3_1=config +fan_roll_status.int_cons_3_1= +fan_roll_status.src_3_1=cpld +fan_roll_status.frmt_3_1=bit +fan_roll_status.pola_3_1=positive +fan_roll_status.fpath_3_1= +fan_roll_status.addr_3_1=0x00030031 +fan_roll_status.len_3_1=1 +fan_roll_status.bit_offset_3_1=1 + +fan_roll_status.mode_3_2=config +fan_roll_status.int_cons_3_2= +fan_roll_status.src_3_2=cpld +fan_roll_status.frmt_3_2=bit +fan_roll_status.pola_3_2=positive +fan_roll_status.fpath_3_2= +fan_roll_status.addr_3_2=0x00030034 +fan_roll_status.len_3_2=1 +fan_roll_status.bit_offset_3_2=1 + +fan_roll_status.mode_4_1=config +fan_roll_status.int_cons_4_1= +fan_roll_status.src_4_1=cpld +fan_roll_status.frmt_4_1=bit +fan_roll_status.pola_4_1=positive +fan_roll_status.fpath_4_1= +fan_roll_status.addr_4_1=0x00040031 +fan_roll_status.len_4_1=1 +fan_roll_status.bit_offset_4_1=1 + +fan_roll_status.mode_4_2=config +fan_roll_status.int_cons_4_2= +fan_roll_status.src_4_2=cpld +fan_roll_status.frmt_4_2=bit +fan_roll_status.pola_4_2=positive +fan_roll_status.fpath_4_2= +fan_roll_status.addr_4_2=0x00040034 +fan_roll_status.len_4_2=1 +fan_roll_status.bit_offset_4_2=1 + +fan_roll_status.mode_5_1=config +fan_roll_status.int_cons_5_1= +fan_roll_status.src_5_1=cpld +fan_roll_status.frmt_5_1=bit +fan_roll_status.pola_5_1=positive +fan_roll_status.fpath_5_1= +fan_roll_status.addr_5_1=0x00030031 +fan_roll_status.len_5_1=1 +fan_roll_status.bit_offset_5_1=2 + +fan_roll_status.mode_5_2=config +fan_roll_status.int_cons_5_2= +fan_roll_status.src_5_2=cpld +fan_roll_status.frmt_5_2=bit +fan_roll_status.pola_5_2=positive +fan_roll_status.fpath_5_2= +fan_roll_status.addr_5_2=0x00030034 +fan_roll_status.len_5_2=1 +fan_roll_status.bit_offset_5_2=2 + +fan_roll_status.mode_6_1=config +fan_roll_status.int_cons_6_1= +fan_roll_status.src_6_1=cpld +fan_roll_status.frmt_6_1=bit +fan_roll_status.pola_6_1=positive +fan_roll_status.fpath_6_1= +fan_roll_status.addr_6_1=0x00040031 +fan_roll_status.len_6_1=1 +fan_roll_status.bit_offset_6_1=2 + +fan_roll_status.mode_6_2=config +fan_roll_status.int_cons_6_2= +fan_roll_status.src_6_2=cpld +fan_roll_status.frmt_6_2=bit +fan_roll_status.pola_6_2=positive +fan_roll_status.fpath_6_2= +fan_roll_status.addr_6_2=0x00040034 +fan_roll_status.len_6_2=1 +fan_roll_status.bit_offset_6_2=2 + +fan_roll_status.mode_7_1=config +fan_roll_status.int_cons_7_1= +fan_roll_status.src_7_1=cpld +fan_roll_status.frmt_7_1=bit +fan_roll_status.pola_7_1=positive +fan_roll_status.fpath_7_1= +fan_roll_status.addr_7_1=0x00030031 +fan_roll_status.len_7_1=1 +fan_roll_status.bit_offset_7_1=3 + +fan_roll_status.mode_7_2=config +fan_roll_status.int_cons_7_2= +fan_roll_status.src_7_2=cpld +fan_roll_status.frmt_7_2=bit +fan_roll_status.pola_7_2=positive +fan_roll_status.fpath_7_2= +fan_roll_status.addr_7_2=0x00030034 +fan_roll_status.len_7_2=1 +fan_roll_status.bit_offset_7_2=3 + +fan_roll_status.mode_8_1=config +fan_roll_status.int_cons_8_1= +fan_roll_status.src_8_1=cpld +fan_roll_status.frmt_8_1=bit +fan_roll_status.pola_8_1=positive +fan_roll_status.fpath_8_1= +fan_roll_status.addr_8_1=0x00040031 +fan_roll_status.len_8_1=1 +fan_roll_status.bit_offset_8_1=3 + +fan_roll_status.mode_8_2=config +fan_roll_status.int_cons_8_2= +fan_roll_status.src_8_2=cpld +fan_roll_status.frmt_8_2=bit +fan_roll_status.pola_8_2=positive +fan_roll_status.fpath_8_2= +fan_roll_status.addr_8_2=0x00040034 +fan_roll_status.len_8_2=1 +fan_roll_status.bit_offset_8_2=3 + +fan_speed.mode_1_1=config +fan_speed.int_cons_1_1= +fan_speed.src_1_1=cpld +fan_speed.frmt_1_1=num_bytes +fan_speed.pola_1_1=negative +fan_speed.fpath_1_1= +fan_speed.addr_1_1=0x0003001B +fan_speed.len_1_1=2 +fan_speed.bit_offset_1_1= + +fan_speed.mode_1_2=config +fan_speed.int_cons_1_2= +fan_speed.src_1_2=cpld +fan_speed.frmt_1_2=num_bytes +fan_speed.pola_1_2=negative +fan_speed.fpath_1_2= +fan_speed.addr_1_2=0x00030025 +fan_speed.len_1_2=2 +fan_speed.bit_offset_1_2= + +fan_speed.mode_2_1=config +fan_speed.int_cons_2_1= +fan_speed.src_2_1=cpld +fan_speed.frmt_2_1=num_bytes +fan_speed.pola_2_1=negative +fan_speed.fpath_2_1= +fan_speed.addr_2_1=0x0004001B +fan_speed.len_2_1=2 +fan_speed.bit_offset_2_1= + +fan_speed.mode_2_2=config +fan_speed.int_cons_2_2= +fan_speed.src_2_2=cpld +fan_speed.frmt_2_2=num_bytes +fan_speed.pola_2_2=negative +fan_speed.fpath_2_2= +fan_speed.addr_2_2=0x00040025 +fan_speed.len_2_2=2 +fan_speed.bit_offset_2_2= + +fan_speed.mode_3_1=config +fan_speed.int_cons_3_1= +fan_speed.src_3_1=cpld +fan_speed.frmt_3_1=num_bytes +fan_speed.pola_3_1=negative +fan_speed.fpath_3_1= +fan_speed.addr_3_1=0x0003001D +fan_speed.len_3_1=2 +fan_speed.bit_offset_3_1= + +fan_speed.mode_3_2=config +fan_speed.int_cons_3_2= +fan_speed.src_3_2=cpld +fan_speed.frmt_3_2=num_bytes +fan_speed.pola_3_2=negative +fan_speed.fpath_3_2= +fan_speed.addr_3_2=0x00030027 +fan_speed.len_3_2=2 +fan_speed.bit_offset_3_2= + +fan_speed.mode_4_1=config +fan_speed.int_cons_4_1= +fan_speed.src_4_1=cpld +fan_speed.frmt_4_1=num_bytes +fan_speed.pola_4_1=negative +fan_speed.fpath_4_1= +fan_speed.addr_4_1=0x0004001D +fan_speed.len_4_1=2 +fan_speed.bit_offset_4_1= + +fan_speed.mode_4_2=config +fan_speed.int_cons_4_2= +fan_speed.src_4_2=cpld +fan_speed.frmt_4_2=num_bytes +fan_speed.pola_4_2=negative +fan_speed.fpath_4_2= +fan_speed.addr_4_2=0x00040027 +fan_speed.len_4_2=2 +fan_speed.bit_offset_4_2= + +fan_speed.mode_5_1=config +fan_speed.int_cons_5_1= +fan_speed.src_5_1=cpld +fan_speed.frmt_5_1=num_bytes +fan_speed.pola_5_1=negative +fan_speed.fpath_5_1= +fan_speed.addr_5_1=0x0003001F +fan_speed.len_5_1=2 +fan_speed.bit_offset_5_1= + +fan_speed.mode_5_2=config +fan_speed.int_cons_5_2= +fan_speed.src_5_2=cpld +fan_speed.frmt_5_2=num_bytes +fan_speed.pola_5_2=negative +fan_speed.fpath_5_2= +fan_speed.addr_5_2=0x00030029 +fan_speed.len_5_2=2 +fan_speed.bit_offset_5_2= + +fan_speed.mode_6_1=config +fan_speed.int_cons_6_1= +fan_speed.src_6_1=cpld +fan_speed.frmt_6_1=num_bytes +fan_speed.pola_6_1=negative +fan_speed.fpath_6_1= +fan_speed.addr_6_1=0x0004001F +fan_speed.len_6_1=2 +fan_speed.bit_offset_6_1= + +fan_speed.mode_6_2=config +fan_speed.int_cons_6_2= +fan_speed.src_6_2=cpld +fan_speed.frmt_6_2=num_bytes +fan_speed.pola_6_2=negative +fan_speed.fpath_6_2= +fan_speed.addr_6_2=0x00040029 +fan_speed.len_6_2=2 +fan_speed.bit_offset_6_2= + +fan_speed.mode_7_1=config +fan_speed.int_cons_7_1= +fan_speed.src_7_1=cpld +fan_speed.frmt_7_1=num_bytes +fan_speed.pola_7_1=negative +fan_speed.fpath_7_1= +fan_speed.addr_7_1=0x00030021 +fan_speed.len_7_1=2 +fan_speed.bit_offset_7_1= + +fan_speed.mode_7_2=config +fan_speed.int_cons_7_2= +fan_speed.src_7_2=cpld +fan_speed.frmt_7_2=num_bytes +fan_speed.pola_7_2=negative +fan_speed.fpath_7_2= +fan_speed.addr_7_2=0x0003002b +fan_speed.len_7_2=2 +fan_speed.bit_offset_7_2= + +fan_speed.mode_8_1=config +fan_speed.int_cons_8_1= +fan_speed.src_8_1=cpld +fan_speed.frmt_8_1=num_bytes +fan_speed.pola_8_1=negative +fan_speed.fpath_8_1= +fan_speed.addr_8_1=0x00040021 +fan_speed.len_8_1=2 +fan_speed.bit_offset_8_1= + +fan_speed.mode_8_2=config +fan_speed.int_cons_8_2= +fan_speed.src_8_2=cpld +fan_speed.frmt_8_2=num_bytes +fan_speed.pola_8_2=negative +fan_speed.fpath_8_2= +fan_speed.addr_8_2=0x0004002b +fan_speed.len_8_2=2 +fan_speed.bit_offset_8_2= + +fan_ratio.mode_1=config +fan_ratio.int_cons_1= +fan_ratio.src_1=cpld +fan_ratio.frmt_1=byte +fan_ratio.pola_1= +fan_ratio.fpath_1= +fan_ratio.addr_1=0x00030014 +fan_ratio.len_1=1 +fan_ratio.bit_offset_1= + +fan_ratio.mode_2=config +fan_ratio.int_cons_2= +fan_ratio.src_2=cpld +fan_ratio.frmt_2=byte +fan_ratio.pola_2= +fan_ratio.fpath_2= +fan_ratio.addr_2=0x00040014 +fan_ratio.len_2=1 +fan_ratio.bit_offset_2= + +fan_ratio.mode_3=config +fan_ratio.int_cons_3= +fan_ratio.src_3=cpld +fan_ratio.frmt_3=byte +fan_ratio.pola_3= +fan_ratio.fpath_3= +fan_ratio.addr_3=0x00030015 +fan_ratio.len_3=1 +fan_ratio.bit_offset_3= + +fan_ratio.mode_4=config +fan_ratio.int_cons_4= +fan_ratio.src_4=cpld +fan_ratio.frmt_4=byte +fan_ratio.pola_4= +fan_ratio.fpath_4= +fan_ratio.addr_4=0x00040015 +fan_ratio.len_4=1 +fan_ratio.bit_offset_4= + +fan_ratio.mode_5=config +fan_ratio.int_cons_5= +fan_ratio.src_5=cpld +fan_ratio.frmt_5=byte +fan_ratio.pola_5= +fan_ratio.fpath_5= +fan_ratio.addr_5=0x00030016 +fan_ratio.len_5=1 +fan_ratio.bit_offset_5= + +fan_ratio.mode_6=config +fan_ratio.int_cons_6= +fan_ratio.src_6=cpld +fan_ratio.frmt_6=byte +fan_ratio.pola_6= +fan_ratio.fpath_6= +fan_ratio.addr_6=0x00040016 +fan_ratio.len_6=1 +fan_ratio.bit_offset_6= + +fan_ratio.mode_7=config +fan_ratio.int_cons_7= +fan_ratio.src_7=cpld +fan_ratio.frmt_7=byte +fan_ratio.pola_7= +fan_ratio.fpath_7= +fan_ratio.addr_7=0x00030017 +fan_ratio.len_7=1 +fan_ratio.bit_offset_7= + +fan_ratio.mode_8=config +fan_ratio.int_cons_8= +fan_ratio.src_8=cpld +fan_ratio.frmt_8=byte +fan_ratio.pola_8= +fan_ratio.fpath_8= +fan_ratio.addr_8=0x00040017 +fan_ratio.len_8=1 +fan_ratio.bit_offset_8= + +# display fan name number +dev_num_1_7=1 + +fan_type_num_1=1 + +fan_name_1_1=FAN12K8080-F + +decode_fan_name_1=FAN12K8080-F \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FPGA.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FPGA.cfg new file mode 100755 index 000000000000..b651cd1c1e4e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-FPGA.cfg @@ -0,0 +1,103 @@ +# FPGA number +dev_num_0_9=3 + +fpga_name_0_0=UPORT_FPGA +fpga_name_0_1=MAC_FPGA +fpga_name_0_2=DPORT_FPGA + + +fpga_version.mode_0_0=config +fpga_version.int_cons_0_0= +fpga_version.src_0_0=file +fpga_version.frmt_0_0=num_bytes +fpga_version.pola_0_0=negative +fpga_version.fpath_0_0=/dev/fpga0 +fpga_version.addr_0_0=0x0 +fpga_version.len_0_0=4 +fpga_version.bit_offset_0_0= + +fpga_version.mode_0_1=config +fpga_version.int_cons_0_1= +fpga_version.src_0_1=file +fpga_version.frmt_0_1=num_bytes +fpga_version.pola_0_1=negative +fpga_version.fpath_0_1=/dev/fpga1 +fpga_version.addr_0_1=0x0 +fpga_version.len_0_1=4 +fpga_version.bit_offset_0_1= + +fpga_version.mode_0_2=config +fpga_version.int_cons_0_2= +fpga_version.src_0_2=file +fpga_version.frmt_0_2=num_bytes +fpga_version.pola_0_2=negative +fpga_version.fpath_0_2=/dev/fpga2 +fpga_version.addr_0_2=0x0 +fpga_version.len_0_2=4 +fpga_version.bit_offset_0_2= + + +fpga_test_reg.mode_0_0=config +fpga_test_reg.int_cons_0_0= +fpga_test_reg.src_0_0=file +fpga_test_reg.frmt_0_0=num_bytes +fpga_test_reg.pola_0_0=negative +fpga_test_reg.fpath_0_0=/dev/fpga0 +fpga_test_reg.addr_0_0=0x08 +fpga_test_reg.len_0_0=4 +fpga_test_reg.bit_offset_0_0= + +fpga_test_reg.mode_0_1=config +fpga_test_reg.int_cons_0_1= +fpga_test_reg.src_0_1=file +fpga_test_reg.frmt_0_1=num_bytes +fpga_test_reg.pola_0_1=negative +fpga_test_reg.fpath_0_1=/dev/fpga1 +fpga_test_reg.addr_0_1=0x08 +fpga_test_reg.len_0_1=4 +fpga_test_reg.bit_offset_0_1= + +fpga_test_reg.mode_0_2=config +fpga_test_reg.int_cons_0_2= +fpga_test_reg.src_0_2=file +fpga_test_reg.frmt_0_2=num_bytes +fpga_test_reg.pola_0_2=negative +fpga_test_reg.fpath_0_2=/dev/fpga2 +fpga_test_reg.addr_0_2=0x08 +fpga_test_reg.len_0_2=4 +fpga_test_reg.bit_offset_0_2= + + +fpga_model_reg.mode_0_0=config +fpga_model_reg.int_cons_0_0= +fpga_model_reg.src_0_0=file +fpga_model_reg.frmt_0_0=num_bytes +fpga_model_reg.pola_0_0=negative +fpga_model_reg.fpath_0_0=/dev/fpga0 +fpga_model_reg.addr_0_0=0x98 +fpga_model_reg.len_0_0=4 +fpga_model_reg.bit_offset_0_0= + +fpga_model_reg.mode_0_1=config +fpga_model_reg.int_cons_0_1= +fpga_model_reg.src_0_1=file +fpga_model_reg.frmt_0_1=num_bytes +fpga_model_reg.pola_0_1=negative +fpga_model_reg.fpath_0_1=/dev/fpga1 +fpga_model_reg.addr_0_1=0xb0 +fpga_model_reg.len_0_1=4 +fpga_model_reg.bit_offset_0_1= + +fpga_model_reg.mode_0_2=config +fpga_model_reg.int_cons_0_2= +fpga_model_reg.src_0_2=file +fpga_model_reg.frmt_0_2=num_bytes +fpga_model_reg.pola_0_2=negative +fpga_model_reg.fpath_0_2=/dev/fpga2 +fpga_model_reg.addr_0_2=0x98 +fpga_model_reg.len_0_2=4 +fpga_model_reg.bit_offset_0_2= + + +fpga_model_decode_0x0=XC7A100T-2FGG484C +fpga_model_decode_0x200=XC7A200T-2FBG484I \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-LED.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-LED.cfg new file mode 100755 index 000000000000..14b301e5cd09 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-LED.cfg @@ -0,0 +1,101 @@ +led_status.mode_0_0=config +led_status.src_0_0=cpld +led_status.frmt_0_0=bit +led_status.addr_0_0=0x00050008 +led_status.len_0_0=3 + +led_status_decode_0_0=0 +led_status_decode_0_1=7 +led_status_decode_0_2=3 +led_status_decode_0_3=5 +led_status_decode_0_4=1 +led_status_decode_0_5=6 +led_status_decode_0_6=2 +led_status_decode_0_7=0 + +led_status.mode_4_0=config +led_status.src_4_0=cpld +led_status.frmt_4_0=bit +led_status.addr_4_0=0x0005000a +led_status.len_4_0=3 + +led_status_decode_4_0=0 +led_status_decode_4_1=7 +led_status_decode_4_2=3 +led_status_decode_4_3=5 +led_status_decode_4_4=1 +led_status_decode_4_5=6 +led_status_decode_4_6=2 +led_status_decode_4_7=0 + +led_status.mode_6_0=config +led_status.src_6_0=cpld +led_status.frmt_6_0=bit +led_status.addr_6_0=0x00050009 +led_status.len_6_0=3 + +led_status_decode_6_0=0 +led_status_decode_6_1=7 +led_status_decode_6_2=3 +led_status_decode_6_3=5 +led_status_decode_6_4=1 +led_status_decode_6_5=6 +led_status_decode_6_6=2 +led_status_decode_6_7=0 + +led_status.mode_10_1=config +led_status.src_10_1=cpld +led_status.frmt_10_1=bit +led_status.addr_10_1=0x0003003b +led_status.len_10_1=3 + +led_status.mode_10_2=config +led_status.src_10_2=cpld +led_status.frmt_10_2=bit +led_status.addr_10_2=0x0004003b +led_status.len_10_2=3 + +led_status.mode_10_3=config +led_status.src_10_3=cpld +led_status.frmt_10_3=bit +led_status.addr_10_3=0x0003003c +led_status.len_10_3=3 + +led_status.mode_10_4=config +led_status.src_10_4=cpld +led_status.frmt_10_4=bit +led_status.addr_10_4=0x0004003c +led_status.len_10_4=3 + +led_status.mode_10_5=config +led_status.src_10_5=cpld +led_status.frmt_10_5=bit +led_status.addr_10_5=0x0003003d +led_status.len_10_5=3 + +led_status.mode_10_6=config +led_status.src_10_6=cpld +led_status.frmt_10_6=bit +led_status.addr_10_6=0x0004003d +led_status.len_10_6=3 + +led_status.mode_10_7=config +led_status.src_10_7=cpld +led_status.frmt_10_7=bit +led_status.addr_10_7=0x0003003e +led_status.len_10_7=3 + +led_status.mode_10_8=config +led_status.src_10_8=cpld +led_status.frmt_10_8=bit +led_status.addr_10_8=0x0004003e +led_status.len_10_8=3 + +led_status_decode_10_0=0 +led_status_decode_10_1=7 +led_status_decode_10_2=3 +led_status_decode_10_3=5 +led_status_decode_10_4=1 +led_status_decode_10_5=6 +led_status_decode_10_6=2 +led_status_decode_10_7=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-PSU.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-PSU.cfg new file mode 100755 index 000000000000..288c7d4da87a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-PSU.cfg @@ -0,0 +1,622 @@ +# psu number +dev_num_2_0=4 + +# psu temp number +dev_num_2_1=3 + +other_i2c_dev.bus_2_1=79 +other_i2c_dev.addr_2_1=0x50 +other_i2c_dev.bus_2_2=80 +other_i2c_dev.addr_2_2=0x50 +other_i2c_dev.bus_2_3=82 +other_i2c_dev.addr_2_3=0x50 +other_i2c_dev.bus_2_4=81 +other_i2c_dev.addr_2_4=0x50 + +psu_pmbus_id_1_11=0x4F005880 +psu_pmbus_id_2_11=0x50005880 +psu_pmbus_id_3_11=0x52005880 +psu_pmbus_id_4_11=0x51005880 + +psu_status.mode_1_0=config +psu_status.src_1_0=cpld +psu_status.frmt_1_0=bit +psu_status.pola_1_0=negative +psu_status.addr_1_0=0x00010064 +psu_status.len_1_0=1 +psu_status.bit_offset_1_0=0 + +psu_status.mode_1_1=config +psu_status.src_1_1=cpld +psu_status.frmt_1_1=bit +psu_status.pola_1_1=positive +psu_status.addr_1_1=0x00010064 +psu_status.len_1_1=1 +psu_status.bit_offset_1_1=1 + +psu_status.mode_1_2=config +psu_status.src_1_2=cpld +psu_status.frmt_1_2=bit +psu_status.pola_1_2=positive +psu_status.addr_1_2=0x00010064 +psu_status.len_1_2=1 +psu_status.bit_offset_1_2=2 + +psu_status.mode_2_0=config +psu_status.src_2_0=cpld +psu_status.frmt_2_0=bit +psu_status.pola_2_0=negative +psu_status.addr_2_0=0x00010064 +psu_status.len_2_0=1 +psu_status.bit_offset_2_0=4 + +psu_status.mode_2_1=config +psu_status.src_2_1=cpld +psu_status.frmt_2_1=bit +psu_status.pola_2_1=positive +psu_status.addr_2_1=0x00010064 +psu_status.len_2_1=1 +psu_status.bit_offset_2_1=5 + +psu_status.mode_2_2=config +psu_status.src_2_2=cpld +psu_status.frmt_2_2=bit +psu_status.pola_2_2=positive +psu_status.addr_2_2=0x00010064 +psu_status.len_2_2=1 +psu_status.bit_offset_2_2=6 + +psu_status.mode_3_0=config +psu_status.src_3_0=cpld +psu_status.frmt_3_0=bit +psu_status.pola_3_0=negative +psu_status.addr_3_0=0x00010065 +psu_status.len_3_0=1 +psu_status.bit_offset_3_0=4 + +psu_status.mode_3_1=config +psu_status.src_3_1=cpld +psu_status.frmt_3_1=bit +psu_status.pola_3_1=positive +psu_status.addr_3_1=0x00010065 +psu_status.len_3_1=1 +psu_status.bit_offset_3_1=5 + +psu_status.mode_3_2=config +psu_status.src_3_2=cpld +psu_status.frmt_3_2=bit +psu_status.pola_3_2=positive +psu_status.addr_3_2=0x00010065 +psu_status.len_3_2=1 +psu_status.bit_offset_3_2=6 + +psu_status.mode_4_0=config +psu_status.src_4_0=cpld +psu_status.frmt_4_0=bit +psu_status.pola_4_0=negative +psu_status.addr_4_0=0x00010065 +psu_status.len_4_0=1 +psu_status.bit_offset_4_0=0 + +psu_status.mode_4_1=config +psu_status.src_4_1=cpld +psu_status.frmt_4_1=bit +psu_status.pola_4_1=positive +psu_status.addr_4_1=0x00010065 +psu_status.len_4_1=1 +psu_status.bit_offset_4_1=1 + +psu_status.mode_4_2=config +psu_status.src_4_2=cpld +psu_status.frmt_4_2=bit +psu_status.pola_4_2=positive +psu_status.addr_4_2=0x00010065 +psu_status.len_4_2=1 +psu_status.bit_offset_4_2=2 + +# 0:None 1:in_vol 2:in_curr 3:in_power 4:out_vol 5:out_curr 6:out_power 7:fan +# psu1 in_vol +hwmon_psu.mode_1_1=config +hwmon_psu.int_cons_1_1=0 +hwmon_psu.src_1_1=file +hwmon_psu.frmt_1_1=buf +hwmon_psu.fpath_1_1=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_1=0 +hwmon_psu.len_1_1=8 +hwmon_psu.bit_offset_1_1= +hwmon_psu.str_cons_1_1=in1_input + +# psu1 in_curr +hwmon_psu.mode_1_2=config +hwmon_psu.int_cons_1_2=0 +hwmon_psu.src_1_2=file +hwmon_psu.frmt_1_2=buf +hwmon_psu.fpath_1_2=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_2=0 +hwmon_psu.len_1_2=8 +hwmon_psu.bit_offset_1_2= +hwmon_psu.str_cons_1_2=curr1_input + +# psu1 in_power +hwmon_psu.mode_1_3=config +hwmon_psu.int_cons_1_3=0 +hwmon_psu.src_1_3=file +hwmon_psu.frmt_1_3=buf +hwmon_psu.fpath_1_3=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_3=0 +hwmon_psu.len_1_3=16 +hwmon_psu.bit_offset_1_3=0 +hwmon_psu.str_cons_1_3=power1_input + +# psu1 out_vol +hwmon_psu.mode_1_4=config +hwmon_psu.int_cons_1_4=0 +hwmon_psu.src_1_4=file +hwmon_psu.frmt_1_4=buf +hwmon_psu.fpath_1_4=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_4=0 +hwmon_psu.len_1_4=8 +hwmon_psu.bit_offset_1_4= +hwmon_psu.str_cons_1_4=in2_input + +# psu1 out_curr +hwmon_psu.mode_1_5=config +hwmon_psu.int_cons_1_5=0 +hwmon_psu.src_1_5=file +hwmon_psu.frmt_1_5=buf +hwmon_psu.fpath_1_5=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_5=0 +hwmon_psu.len_1_5=8 +hwmon_psu.bit_offset_1_5= +hwmon_psu.str_cons_1_5=curr2_input + +# psu1 out_power +hwmon_psu.mode_1_6=config +hwmon_psu.int_cons_1_6=0 +hwmon_psu.src_1_6=file +hwmon_psu.frmt_1_6=buf +hwmon_psu.fpath_1_6=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_6=0 +hwmon_psu.len_1_6=16 +hwmon_psu.bit_offset_1_6=0 +hwmon_psu.str_cons_1_6=power2_input + +# psu1 fan +hwmon_psu.mode_1_7=config +hwmon_psu.int_cons_1_7= +hwmon_psu.src_1_7=file +hwmon_psu.frmt_1_7=buf +hwmon_psu.fpath_1_7=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_psu.addr_1_7=0 +hwmon_psu.len_1_7=8 +hwmon_psu.bit_offset_1_7= +hwmon_psu.str_cons_1_7=fan1_input + +# psu2 in_vol +hwmon_psu.mode_2_1=config +hwmon_psu.int_cons_2_1=0 +hwmon_psu.src_2_1=file +hwmon_psu.frmt_2_1=buf +hwmon_psu.fpath_2_1=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_1=0 +hwmon_psu.len_2_1=8 +hwmon_psu.bit_offset_2_1= +hwmon_psu.str_cons_2_1=in1_input + +# psu2 in_curr +hwmon_psu.mode_2_2=config +hwmon_psu.int_cons_2_2=0 +hwmon_psu.src_2_2=file +hwmon_psu.frmt_2_2=buf +hwmon_psu.fpath_2_2=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_2=0 +hwmon_psu.len_2_2=8 +hwmon_psu.bit_offset_2_2= +hwmon_psu.str_cons_2_2=curr1_input + +# psu2 in_power +hwmon_psu.mode_2_3=config +hwmon_psu.int_cons_2_3=0 +hwmon_psu.src_2_3=file +hwmon_psu.frmt_2_3=buf +hwmon_psu.fpath_2_3=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_3=0 +hwmon_psu.len_2_3=16 +hwmon_psu.bit_offset_2_3=0 +hwmon_psu.str_cons_2_3=power1_input + +# psu2 out_vol +hwmon_psu.mode_2_4=config +hwmon_psu.int_cons_2_4=0 +hwmon_psu.src_2_4=file +hwmon_psu.frmt_2_4=buf +hwmon_psu.fpath_2_4=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_4=0 +hwmon_psu.len_2_4=8 +hwmon_psu.bit_offset_2_4= +hwmon_psu.str_cons_2_4=in2_input + +# psu2 out_curr +hwmon_psu.mode_2_5=config +hwmon_psu.int_cons_2_5=0 +hwmon_psu.src_2_5=file +hwmon_psu.frmt_2_5=buf +hwmon_psu.fpath_2_5=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_5=0 +hwmon_psu.len_2_5=8 +hwmon_psu.bit_offset_2_5= +hwmon_psu.str_cons_2_5=curr2_input + +# psu2 out_power +hwmon_psu.mode_2_6=config +hwmon_psu.int_cons_2_6=0 +hwmon_psu.src_2_6=file +hwmon_psu.frmt_2_6=buf +hwmon_psu.fpath_2_6=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_6=0 +hwmon_psu.len_2_6=16 +hwmon_psu.bit_offset_2_6=0 +hwmon_psu.str_cons_2_6=power2_input + +# psu2 fan +hwmon_psu.mode_2_7=config +hwmon_psu.int_cons_2_7= +hwmon_psu.src_2_7=file +hwmon_psu.frmt_2_7=buf +hwmon_psu.fpath_2_7=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_psu.addr_2_7=0 +hwmon_psu.len_2_7=8 +hwmon_psu.bit_offset_2_7= +hwmon_psu.str_cons_2_7=fan1_input + +# psu3 in_vol +hwmon_psu.mode_3_1=config +hwmon_psu.int_cons_3_1=0 +hwmon_psu.src_3_1=file +hwmon_psu.frmt_3_1=buf +hwmon_psu.fpath_3_1=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_1=0 +hwmon_psu.len_3_1=8 +hwmon_psu.bit_offset_3_1= +hwmon_psu.str_cons_3_1=in1_input + +# psu3 in_curr +hwmon_psu.mode_3_2=config +hwmon_psu.int_cons_3_2=0 +hwmon_psu.src_3_2=file +hwmon_psu.frmt_3_2=buf +hwmon_psu.fpath_3_2=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_2=0 +hwmon_psu.len_3_2=8 +hwmon_psu.bit_offset_3_2= +hwmon_psu.str_cons_3_2=curr1_input + +# psu3 in_power +hwmon_psu.mode_3_3=config +hwmon_psu.int_cons_3_3=0 +hwmon_psu.src_3_3=file +hwmon_psu.frmt_3_3=buf +hwmon_psu.fpath_3_3=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_3=0 +hwmon_psu.len_3_3=16 +hwmon_psu.bit_offset_3_3=0 +hwmon_psu.str_cons_3_3=power1_input + +# psu3 out_vol +hwmon_psu.mode_3_4=config +hwmon_psu.int_cons_3_4=0 +hwmon_psu.src_3_4=file +hwmon_psu.frmt_3_4=buf +hwmon_psu.fpath_3_4=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_4=0 +hwmon_psu.len_3_4=8 +hwmon_psu.bit_offset_3_4= +hwmon_psu.str_cons_3_4=in2_input + +# psu3 out_curr +hwmon_psu.mode_3_5=config +hwmon_psu.int_cons_3_5=0 +hwmon_psu.src_3_5=file +hwmon_psu.frmt_3_5=buf +hwmon_psu.fpath_3_5=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_5=0 +hwmon_psu.len_3_5=8 +hwmon_psu.bit_offset_3_5= +hwmon_psu.str_cons_3_5=curr2_input + +# psu3 out_power +hwmon_psu.mode_3_6=config +hwmon_psu.int_cons_3_6=0 +hwmon_psu.src_3_6=file +hwmon_psu.frmt_3_6=buf +hwmon_psu.fpath_3_6=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_6=0 +hwmon_psu.len_3_6=16 +hwmon_psu.bit_offset_3_6=0 +hwmon_psu.str_cons_3_6=power2_input + +# psu3 fan +hwmon_psu.mode_3_7=config +hwmon_psu.int_cons_3_7= +hwmon_psu.src_3_7=file +hwmon_psu.frmt_3_7=buf +hwmon_psu.fpath_3_7=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_psu.addr_3_7=0 +hwmon_psu.len_3_7=8 +hwmon_psu.bit_offset_3_7= +hwmon_psu.str_cons_3_7=fan1_input + +# psu4 in_vol +hwmon_psu.mode_4_1=config +hwmon_psu.int_cons_4_1=0 +hwmon_psu.src_4_1=file +hwmon_psu.frmt_4_1=buf +hwmon_psu.fpath_4_1=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_1=0 +hwmon_psu.len_4_1=8 +hwmon_psu.bit_offset_4_1= +hwmon_psu.str_cons_4_1=in1_input + +# psu4 in_curr +hwmon_psu.mode_4_2=config +hwmon_psu.int_cons_4_2=0 +hwmon_psu.src_4_2=file +hwmon_psu.frmt_4_2=buf +hwmon_psu.fpath_4_2=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_2=0 +hwmon_psu.len_4_2=8 +hwmon_psu.bit_offset_4_2= +hwmon_psu.str_cons_4_2=curr1_input + +# psu4 in_power +hwmon_psu.mode_4_3=config +hwmon_psu.int_cons_4_3=0 +hwmon_psu.src_4_3=file +hwmon_psu.frmt_4_3=buf +hwmon_psu.fpath_4_3=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_3=0 +hwmon_psu.len_4_3=16 +hwmon_psu.bit_offset_4_3=0 +hwmon_psu.str_cons_4_3=power1_input + +# psu4 out_vol +hwmon_psu.mode_4_4=config +hwmon_psu.int_cons_4_4=0 +hwmon_psu.src_4_4=file +hwmon_psu.frmt_4_4=buf +hwmon_psu.fpath_4_4=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_4=0 +hwmon_psu.len_4_4=8 +hwmon_psu.bit_offset_4_4= +hwmon_psu.str_cons_4_4=in2_input + +# psu4 out_curr +hwmon_psu.mode_4_5=config +hwmon_psu.int_cons_4_5=0 +hwmon_psu.src_4_5=file +hwmon_psu.frmt_4_5=buf +hwmon_psu.fpath_4_5=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_5=0 +hwmon_psu.len_4_5=8 +hwmon_psu.bit_offset_4_5= +hwmon_psu.str_cons_4_5=curr2_input + +# psu4 out_power +hwmon_psu.mode_4_6=config +hwmon_psu.int_cons_4_6=0 +hwmon_psu.src_4_6=file +hwmon_psu.frmt_4_6=buf +hwmon_psu.fpath_4_6=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_6=0 +hwmon_psu.len_4_6=16 +hwmon_psu.bit_offset_4_6=0 +hwmon_psu.str_cons_4_6=power2_input + +# psu4 fan +hwmon_psu.mode_4_7=config +hwmon_psu.int_cons_4_7= +hwmon_psu.src_4_7=file +hwmon_psu.frmt_4_7=buf +hwmon_psu.fpath_4_7=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_psu.addr_4_7=0 +hwmon_psu.len_4_7=8 +hwmon_psu.bit_offset_4_7= +hwmon_psu.str_cons_4_7=fan1_input +# 2:type 3:max 4:max_hyst 5:min 6:crit + +# psu1 temp1 input +hwmon_temp.mode_0x0101_0x20=config +hwmon_temp.int_cons_0x0101_0x20=0 +hwmon_temp.src_0x0101_0x20=file +hwmon_temp.frmt_0x0101_0x20=buf +hwmon_temp.fpath_0x0101_0x20=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_temp.addr_0x0101_0x20=0 +hwmon_temp.len_0x0101_0x20=8 +hwmon_temp.bit_offset_0x0101_0x20= +hwmon_temp.str_cons_0x0101_0x20=temp1_input + +# psu1 temp1 alias +hwmon_temp.mode_0x0101_0x21=str_constant +hwmon_temp.str_cons_0x0101_0x21=temp1 + +# psu1 temp2 input +hwmon_temp.mode_0x0102_0x20=config +hwmon_temp.int_cons_0x0102_0x20=0 +hwmon_temp.src_0x0102_0x20=file +hwmon_temp.frmt_0x0102_0x20=buf +hwmon_temp.fpath_0x0102_0x20=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_temp.addr_0x0102_0x20=0 +hwmon_temp.len_0x0102_0x20=8 +hwmon_temp.bit_offset_0x0102_0x20= +hwmon_temp.str_cons_0x0102_0x20=temp2_input + +# psu1 temp2 alias +hwmon_temp.mode_0x0102_0x21=str_constant +hwmon_temp.str_cons_0x0102_0x21=temp2 + +# psu1 temp3 input +hwmon_temp.mode_0x0103_0x20=config +hwmon_temp.int_cons_0x0103_0x20=0 +hwmon_temp.src_0x0103_0x20=file +hwmon_temp.frmt_0x0103_0x20=buf +hwmon_temp.fpath_0x0103_0x20=/sys/bus/i2c/devices/79-0058/hwmon/ +hwmon_temp.addr_0x0103_0x20=0 +hwmon_temp.len_0x0103_0x20=8 +hwmon_temp.bit_offset_0x0103_0x20= +hwmon_temp.str_cons_0x0103_0x20=temp3_input + +# psu1 temp3 alias +hwmon_temp.mode_0x0103_0x21=str_constant +hwmon_temp.str_cons_0x0103_0x21=temp3 + +# psu2 temp1 input +hwmon_temp.mode_0x0201_0x20=config +hwmon_temp.int_cons_0x0201_0x20=0 +hwmon_temp.src_0x0201_0x20=file +hwmon_temp.frmt_0x0201_0x20=buf +hwmon_temp.fpath_0x0201_0x20=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_temp.addr_0x0201_0x20=0 +hwmon_temp.len_0x0201_0x20=8 +hwmon_temp.bit_offset_0x0201_0x20= +hwmon_temp.str_cons_0x0201_0x20=temp1_input + +# psu2 temp1 alias +hwmon_temp.mode_0x0201_0x21=str_constant +hwmon_temp.str_cons_0x0201_0x21=temp1 + +# psu2 temp2 input +hwmon_temp.mode_0x0202_0x20=config +hwmon_temp.int_cons_0x0202_0x20=0 +hwmon_temp.src_0x0202_0x20=file +hwmon_temp.frmt_0x0202_0x20=buf +hwmon_temp.fpath_0x0202_0x20=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_temp.addr_0x0202_0x20=0 +hwmon_temp.len_0x0202_0x20=8 +hwmon_temp.bit_offset_0x0202_0x20= +hwmon_temp.str_cons_0x0202_0x20=temp2_input + +# psu2 temp2 alias +hwmon_temp.mode_0x0202_0x21=str_constant +hwmon_temp.str_cons_0x0202_0x21=temp2 + +# psu2 temp3 input +hwmon_temp.mode_0x0203_0x20=config +hwmon_temp.int_cons_0x0203_0x20=0 +hwmon_temp.src_0x0203_0x20=file +hwmon_temp.frmt_0x0203_0x20=buf +hwmon_temp.fpath_0x0203_0x20=/sys/bus/i2c/devices/80-0058/hwmon/ +hwmon_temp.addr_0x0203_0x20=0 +hwmon_temp.len_0x0203_0x20=8 +hwmon_temp.bit_offset_0x0203_0x20= +hwmon_temp.str_cons_0x0203_0x20=temp3_input + +# psu2 temp3 alias +hwmon_temp.mode_0x0203_0x21=str_constant +hwmon_temp.str_cons_0x0203_0x21=temp3 + +# psu3 temp1 input +hwmon_temp.mode_0x0301_0x20=config +hwmon_temp.int_cons_0x0301_0x20=0 +hwmon_temp.src_0x0301_0x20=file +hwmon_temp.frmt_0x0301_0x20=buf +hwmon_temp.fpath_0x0301_0x20=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_temp.addr_0x0301_0x20=0 +hwmon_temp.len_0x0301_0x20=8 +hwmon_temp.bit_offset_0x0301_0x20= +hwmon_temp.str_cons_0x0301_0x20=temp1_input + +# psu3 temp1 alias +hwmon_temp.mode_0x0301_0x21=str_constant +hwmon_temp.str_cons_0x0301_0x21=temp1 + +# psu3 temp2 input +hwmon_temp.mode_0x0302_0x20=config +hwmon_temp.int_cons_0x0302_0x20=0 +hwmon_temp.src_0x0302_0x20=file +hwmon_temp.frmt_0x0302_0x20=buf +hwmon_temp.fpath_0x0302_0x20=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_temp.addr_0x0302_0x20=0 +hwmon_temp.len_0x0302_0x20=8 +hwmon_temp.bit_offset_0x0302_0x20= +hwmon_temp.str_cons_0x0302_0x20=temp2_input + +# psu3 temp2 alias +hwmon_temp.mode_0x0302_0x21=str_constant +hwmon_temp.str_cons_0x0302_0x21=temp2 + +# psu3 temp3 input +hwmon_temp.mode_0x0303_0x20=config +hwmon_temp.int_cons_0x0303_0x20=0 +hwmon_temp.src_0x0303_0x20=file +hwmon_temp.frmt_0x0303_0x20=buf +hwmon_temp.fpath_0x0303_0x20=/sys/bus/i2c/devices/82-0058/hwmon/ +hwmon_temp.addr_0x0303_0x20=0 +hwmon_temp.len_0x0303_0x20=8 +hwmon_temp.bit_offset_0x0303_0x20= +hwmon_temp.str_cons_0x0303_0x20=temp3_input + +# psu3 temp3 alias +hwmon_temp.mode_0x0303_0x21=str_constant +hwmon_temp.str_cons_0x0303_0x21=temp3 + +# psu4 temp1 input +hwmon_temp.mode_0x0401_0x20=config +hwmon_temp.int_cons_0x0401_0x20=0 +hwmon_temp.src_0x0401_0x20=file +hwmon_temp.frmt_0x0401_0x20=buf +hwmon_temp.fpath_0x0401_0x20=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_temp.addr_0x0401_0x20=0 +hwmon_temp.len_0x0401_0x20=8 +hwmon_temp.bit_offset_0x0401_0x20= +hwmon_temp.str_cons_0x0401_0x20=temp1_input + +# psu4 temp1 alias +hwmon_temp.mode_0x0401_0x21=str_constant +hwmon_temp.str_cons_0x0401_0x21=temp1 + +# psu4 temp2 input +hwmon_temp.mode_0x0402_0x20=config +hwmon_temp.int_cons_0x0402_0x20=0 +hwmon_temp.src_0x0402_0x20=file +hwmon_temp.frmt_0x0402_0x20=buf +hwmon_temp.fpath_0x0402_0x20=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_temp.addr_0x0402_0x20=0 +hwmon_temp.len_0x0402_0x20=8 +hwmon_temp.bit_offset_0x0402_0x20= +hwmon_temp.str_cons_0x0402_0x20=temp2_input + +# psu4 temp2 alias +hwmon_temp.mode_0x0402_0x21=str_constant +hwmon_temp.str_cons_0x0402_0x21=temp2 + +# psu4 temp3 input +hwmon_temp.mode_0x0403_0x20=config +hwmon_temp.int_cons_0x0403_0x20=0 +hwmon_temp.src_0x0403_0x20=file +hwmon_temp.frmt_0x0403_0x20=buf +hwmon_temp.fpath_0x0403_0x20=/sys/bus/i2c/devices/81-0058/hwmon/ +hwmon_temp.addr_0x0403_0x20=0 +hwmon_temp.len_0x0403_0x20=8 +hwmon_temp.bit_offset_0x0403_0x20= +hwmon_temp.str_cons_0x0403_0x20=temp3_input + +# psu4 temp3 alias +hwmon_temp.mode_0x0403_0x21=str_constant +hwmon_temp.str_cons_0x0403_0x21=temp3 + +# display psu name number +dev_num_2_6=2 + +power_name_1_1=DPS-1300AB-6 +power_name_1_2=GW-CRPS1300D +power_name_2_1=DPS-1300AB-11 +power_name_2_2=CRPS1300D3R + +decode_power_name_1=PSA1300CRPS-F +decode_power_name_2=PSA1300CRPS-R + +power_rate_supply_1=1300000000 +power_rate_supply_2=1300000000 + +decode_power_fan_dir_1=0 +decode_power_fan_dir_2=1 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SENSOR.cfg new file mode 100755 index 000000000000..ab6cbc7bac24 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SENSOR.cfg @@ -0,0 +1,2402 @@ +# temp sensor number +dev_num_0_1=34 + +# voltage sensor number +dev_num_0_2=56 + +# current sensor number +dev_num_0_3=7 + +# sensor temp1 input +hwmon_temp.mode_0x0001_0x00=config +hwmon_temp.int_cons_0x0001_0x00=0 +hwmon_temp.src_0x0001_0x00=file +hwmon_temp.frmt_0x0001_0x00=buf +hwmon_temp.fpath_0x0001_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x00=0 +hwmon_temp.len_0x0001_0x00=8 +hwmon_temp.bit_offset_0x0001_0x00= +hwmon_temp.str_cons_0x0001_0x00=temp1_input + +# sensor temp1 alias +hwmon_temp.mode_0x0001_0x01=config +hwmon_temp.int_cons_0x0001_0x01= +hwmon_temp.src_0x0001_0x01=file +hwmon_temp.frmt_0x0001_0x01=buf +hwmon_temp.fpath_0x0001_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x01=0 +hwmon_temp.len_0x0001_0x01=16 +hwmon_temp.bit_offset_0x0001_0x01= +hwmon_temp.str_cons_0x0001_0x01=temp1_label + +hwmon_temp.mode_0x0001_0x02=str_constant +hwmon_temp.str_cons_0x0001_0x02=cpu + +# sensor temp1 max +hwmon_temp.mode_0x0001_0x03=config +hwmon_temp.int_cons_0x0001_0x03=0 +hwmon_temp.src_0x0001_0x03=file +hwmon_temp.frmt_0x0001_0x03=buf +hwmon_temp.fpath_0x0001_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x03=0 +hwmon_temp.len_0x0001_0x03=8 +hwmon_temp.bit_offset_0x0001_0x03= +hwmon_temp.str_cons_0x0001_0x03=temp1_max + + +# sensor temp2 input +hwmon_temp.mode_0x0002_0x00=config +hwmon_temp.int_cons_0x0002_0x00=0 +hwmon_temp.src_0x0002_0x00=file +hwmon_temp.frmt_0x0002_0x00=buf +hwmon_temp.fpath_0x0002_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x00=0 +hwmon_temp.len_0x0002_0x00=8 +hwmon_temp.bit_offset_0x0002_0x00= +hwmon_temp.str_cons_0x0002_0x00=temp2_input + +# sensor temp2 alias +hwmon_temp.mode_0x0002_0x01=config +hwmon_temp.int_cons_0x0002_0x01= +hwmon_temp.src_0x0002_0x01=file +hwmon_temp.frmt_0x0002_0x01=buf +hwmon_temp.fpath_0x0002_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x01=0 +hwmon_temp.len_0x0002_0x01=16 +hwmon_temp.bit_offset_0x0002_0x01= +hwmon_temp.str_cons_0x0002_0x01=temp2_label + +hwmon_temp.mode_0x0002_0x02=str_constant +hwmon_temp.str_cons_0x0002_0x02=cpu + +# sensor temp2 max +hwmon_temp.mode_0x0002_0x03=config +hwmon_temp.int_cons_0x0002_0x03=0 +hwmon_temp.src_0x0002_0x03=file +hwmon_temp.frmt_0x0002_0x03=buf +hwmon_temp.fpath_0x0002_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x03=0 +hwmon_temp.len_0x0002_0x03=8 +hwmon_temp.bit_offset_0x0002_0x03= +hwmon_temp.str_cons_0x0002_0x03=temp2_max + + +# sensor temp3 input +hwmon_temp.mode_0x0003_0x00=config +hwmon_temp.int_cons_0x0003_0x00=0 +hwmon_temp.src_0x0003_0x00=file +hwmon_temp.frmt_0x0003_0x00=buf +hwmon_temp.fpath_0x0003_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x00=0 +hwmon_temp.len_0x0003_0x00=8 +hwmon_temp.bit_offset_0x0003_0x00= +hwmon_temp.str_cons_0x0003_0x00=temp3_input + +# sensor temp3 alias +hwmon_temp.mode_0x0003_0x01=config +hwmon_temp.int_cons_0x0003_0x01= +hwmon_temp.src_0x0003_0x01=file +hwmon_temp.frmt_0x0003_0x01=buf +hwmon_temp.fpath_0x0003_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x01=0 +hwmon_temp.len_0x0003_0x01=16 +hwmon_temp.bit_offset_0x0003_0x01= +hwmon_temp.str_cons_0x0003_0x01=temp3_label + +hwmon_temp.mode_0x0003_0x02=str_constant +hwmon_temp.str_cons_0x0003_0x02=cpu + +# sensor temp3 max +hwmon_temp.mode_0x0003_0x03=config +hwmon_temp.int_cons_0x0003_0x03=0 +hwmon_temp.src_0x0003_0x03=file +hwmon_temp.frmt_0x0003_0x03=buf +hwmon_temp.fpath_0x0003_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x03=0 +hwmon_temp.len_0x0003_0x03=8 +hwmon_temp.bit_offset_0x0003_0x03= +hwmon_temp.str_cons_0x0003_0x03=temp3_max + + +# sensor temp4 input +hwmon_temp.mode_0x0004_0x00=config +hwmon_temp.int_cons_0x0004_0x00=0 +hwmon_temp.src_0x0004_0x00=file +hwmon_temp.frmt_0x0004_0x00=buf +hwmon_temp.fpath_0x0004_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x00=0 +hwmon_temp.len_0x0004_0x00=8 +hwmon_temp.bit_offset_0x0004_0x00= +hwmon_temp.str_cons_0x0004_0x00=temp4_input + +# sensor temp4 alias +hwmon_temp.mode_0x0004_0x01=config +hwmon_temp.int_cons_0x0004_0x01= +hwmon_temp.src_0x0004_0x01=file +hwmon_temp.frmt_0x0004_0x01=buf +hwmon_temp.fpath_0x0004_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x01=0 +hwmon_temp.len_0x0004_0x01=16 +hwmon_temp.bit_offset_0x0004_0x01= +hwmon_temp.str_cons_0x0004_0x01=temp4_label + +hwmon_temp.mode_0x0004_0x02=str_constant +hwmon_temp.str_cons_0x0004_0x02=cpu + +# sensor temp4 max +hwmon_temp.mode_0x0004_0x03=config +hwmon_temp.int_cons_0x0004_0x03=0 +hwmon_temp.src_0x0004_0x03=file +hwmon_temp.frmt_0x0004_0x03=buf +hwmon_temp.fpath_0x0004_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x03=0 +hwmon_temp.len_0x0004_0x03=8 +hwmon_temp.bit_offset_0x0004_0x03= +hwmon_temp.str_cons_0x0004_0x03=temp4_max + + +# sensor temp5 input +hwmon_temp.mode_0x0005_0x00=config +hwmon_temp.int_cons_0x0005_0x00=0 +hwmon_temp.src_0x0005_0x00=file +hwmon_temp.frmt_0x0005_0x00=buf +hwmon_temp.fpath_0x0005_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x00=0 +hwmon_temp.len_0x0005_0x00=8 +hwmon_temp.bit_offset_0x0005_0x00= +hwmon_temp.str_cons_0x0005_0x00=temp5_input + +# sensor temp5 alias +hwmon_temp.mode_0x0005_0x01=config +hwmon_temp.int_cons_0x0005_0x01= +hwmon_temp.src_0x0005_0x01=file +hwmon_temp.frmt_0x0005_0x01=buf +hwmon_temp.fpath_0x0005_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x01=0 +hwmon_temp.len_0x0005_0x01=16 +hwmon_temp.bit_offset_0x0005_0x01= +hwmon_temp.str_cons_0x0005_0x01=temp5_label + +hwmon_temp.mode_0x0005_0x02=str_constant +hwmon_temp.str_cons_0x0005_0x02=cpu + +# sensor temp5 max +hwmon_temp.mode_0x0005_0x03=config +hwmon_temp.int_cons_0x0005_0x03=0 +hwmon_temp.src_0x0005_0x03=file +hwmon_temp.frmt_0x0005_0x03=buf +hwmon_temp.fpath_0x0005_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x03=0 +hwmon_temp.len_0x0005_0x03=8 +hwmon_temp.bit_offset_0x0005_0x03= +hwmon_temp.str_cons_0x0005_0x03=temp5_max + +# sensor temp6 input +hwmon_temp.mode_0x0006_0x00=config +hwmon_temp.int_cons_0x0006_0x00=0 +hwmon_temp.src_0x0006_0x00=file +hwmon_temp.frmt_0x0006_0x00=buf +hwmon_temp.fpath_0x0006_0x00=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x00=0 +hwmon_temp.len_0x0006_0x00=8 +hwmon_temp.bit_offset_0x0006_0x00= +hwmon_temp.str_cons_0x0006_0x00=temp1_input + +hwmon_temp.mode_0x0006_0x01=str_constant +hwmon_temp.str_cons_0x0006_0x01=air_inlet + +hwmon_temp.mode_0x0006_0x02=str_constant +hwmon_temp.str_cons_0x0006_0x02=lm75 + +hwmon_temp.mode_0x0006_0x03=config +hwmon_temp.int_cons_0x0006_0x03=0 +hwmon_temp.src_0x0006_0x03=file +hwmon_temp.frmt_0x0006_0x03=buf +hwmon_temp.fpath_0x0006_0x03=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x03=0 +hwmon_temp.len_0x0006_0x03=8 +hwmon_temp.bit_offset_0x0006_0x03= +hwmon_temp.str_cons_0x0006_0x03=temp1_max + +hwmon_temp.mode_0x0006_0x04=config +hwmon_temp.int_cons_0x0006_0x04=0 +hwmon_temp.src_0x0006_0x04=file +hwmon_temp.frmt_0x0006_0x04=buf +hwmon_temp.fpath_0x0006_0x04=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x04=0 +hwmon_temp.len_0x0006_0x04=8 +hwmon_temp.bit_offset_0x0006_0x04= +hwmon_temp.str_cons_0x0006_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0007_0x00=config +hwmon_temp.int_cons_0x0007_0x00=0 +hwmon_temp.src_0x0007_0x00=file +hwmon_temp.frmt_0x0007_0x00=buf +hwmon_temp.fpath_0x0007_0x00=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x00=0 +hwmon_temp.len_0x0007_0x00=8 +hwmon_temp.bit_offset_0x0007_0x00= +hwmon_temp.str_cons_0x0007_0x00=temp1_input + +hwmon_temp.mode_0x0007_0x01=str_constant +hwmon_temp.str_cons_0x0007_0x01=Uport_air_inlet_L + +hwmon_temp.mode_0x0007_0x02=str_constant +hwmon_temp.str_cons_0x0007_0x02=lm75 + +hwmon_temp.mode_0x0007_0x03=config +hwmon_temp.int_cons_0x0007_0x03=0 +hwmon_temp.src_0x0007_0x03=file +hwmon_temp.frmt_0x0007_0x03=buf +hwmon_temp.fpath_0x0007_0x03=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x03=0 +hwmon_temp.len_0x0007_0x03=8 +hwmon_temp.bit_offset_0x0007_0x03= +hwmon_temp.str_cons_0x0007_0x03=temp1_max + +hwmon_temp.mode_0x0007_0x04=config +hwmon_temp.int_cons_0x0007_0x04=0 +hwmon_temp.src_0x0007_0x04=file +hwmon_temp.frmt_0x0007_0x04=buf +hwmon_temp.fpath_0x0007_0x04=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x04=0 +hwmon_temp.len_0x0007_0x04=8 +hwmon_temp.bit_offset_0x0007_0x04= +hwmon_temp.str_cons_0x0007_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0008_0x00=config +hwmon_temp.int_cons_0x0008_0x00=0 +hwmon_temp.src_0x0008_0x00=file +hwmon_temp.frmt_0x0008_0x00=buf +hwmon_temp.fpath_0x0008_0x00=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x00=0 +hwmon_temp.len_0x0008_0x00=8 +hwmon_temp.bit_offset_0x0008_0x00= +hwmon_temp.str_cons_0x0008_0x00=temp1_input + +hwmon_temp.mode_0x0008_0x01=str_constant +hwmon_temp.str_cons_0x0008_0x01=Uport_air_inlet_R + +hwmon_temp.mode_0x0008_0x02=str_constant +hwmon_temp.str_cons_0x0008_0x02=lm75 + +hwmon_temp.mode_0x0008_0x03=config +hwmon_temp.int_cons_0x0008_0x03=0 +hwmon_temp.src_0x0008_0x03=file +hwmon_temp.frmt_0x0008_0x03=buf +hwmon_temp.fpath_0x0008_0x03=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x03=0 +hwmon_temp.len_0x0008_0x03=8 +hwmon_temp.bit_offset_0x0008_0x03= +hwmon_temp.str_cons_0x0008_0x03=temp1_max + +hwmon_temp.mode_0x0008_0x04=config +hwmon_temp.int_cons_0x0008_0x04=0 +hwmon_temp.src_0x0008_0x04=file +hwmon_temp.frmt_0x0008_0x04=buf +hwmon_temp.fpath_0x0008_0x04=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x04=0 +hwmon_temp.len_0x0008_0x04=8 +hwmon_temp.bit_offset_0x0008_0x04= +hwmon_temp.str_cons_0x0008_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0009_0x00=config +hwmon_temp.int_cons_0x0009_0x00=0 +hwmon_temp.src_0x0009_0x00=file +hwmon_temp.frmt_0x0009_0x00=buf +hwmon_temp.fpath_0x0009_0x00=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x00=0 +hwmon_temp.len_0x0009_0x00=8 +hwmon_temp.bit_offset_0x0009_0x00= +hwmon_temp.str_cons_0x0009_0x00=temp1_input + +hwmon_temp.mode_0x0009_0x01=str_constant +hwmon_temp.str_cons_0x0009_0x01=Dport_air_inlet_L + +hwmon_temp.mode_0x0009_0x02=str_constant +hwmon_temp.str_cons_0x0009_0x02=lm75 + +hwmon_temp.mode_0x0009_0x03=config +hwmon_temp.int_cons_0x0009_0x03=0 +hwmon_temp.src_0x0009_0x03=file +hwmon_temp.frmt_0x0009_0x03=buf +hwmon_temp.fpath_0x0009_0x03=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x03=0 +hwmon_temp.len_0x0009_0x03=8 +hwmon_temp.bit_offset_0x0009_0x03= +hwmon_temp.str_cons_0x0009_0x03=temp1_max + +hwmon_temp.mode_0x0009_0x04=config +hwmon_temp.int_cons_0x0009_0x04=0 +hwmon_temp.src_0x0009_0x04=file +hwmon_temp.frmt_0x0009_0x04=buf +hwmon_temp.fpath_0x0009_0x04=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x04=0 +hwmon_temp.len_0x0009_0x04=8 +hwmon_temp.bit_offset_0x0009_0x04= +hwmon_temp.str_cons_0x0009_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000a_0x00=config +hwmon_temp.int_cons_0x000a_0x00=0 +hwmon_temp.src_0x000a_0x00=file +hwmon_temp.frmt_0x000a_0x00=buf +hwmon_temp.fpath_0x000a_0x00=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x00=0 +hwmon_temp.len_0x000a_0x00=8 +hwmon_temp.bit_offset_0x000a_0x00= +hwmon_temp.str_cons_0x000a_0x00=temp1_input + +hwmon_temp.mode_0x000a_0x01=str_constant +hwmon_temp.str_cons_0x000a_0x01=Dport_air_inlet_R + +hwmon_temp.mode_0x000a_0x02=str_constant +hwmon_temp.str_cons_0x000a_0x02=lm75 + +hwmon_temp.mode_0x000a_0x03=config +hwmon_temp.int_cons_0x000a_0x03=0 +hwmon_temp.src_0x000a_0x03=file +hwmon_temp.frmt_0x000a_0x03=buf +hwmon_temp.fpath_0x000a_0x03=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x03=0 +hwmon_temp.len_0x000a_0x03=8 +hwmon_temp.bit_offset_0x000a_0x03= +hwmon_temp.str_cons_0x000a_0x03=temp1_max + +hwmon_temp.mode_0x000a_0x04=config +hwmon_temp.int_cons_0x000a_0x04=0 +hwmon_temp.src_0x000a_0x04=file +hwmon_temp.frmt_0x000a_0x04=buf +hwmon_temp.fpath_0x000a_0x04=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x04=0 +hwmon_temp.len_0x000a_0x04=8 +hwmon_temp.bit_offset_0x000a_0x04= +hwmon_temp.str_cons_0x000a_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000b_0x00=config +hwmon_temp.int_cons_0x000b_0x00=0 +hwmon_temp.src_0x000b_0x00=file +hwmon_temp.frmt_0x000b_0x00=buf +hwmon_temp.fpath_0x000b_0x00=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x00=0 +hwmon_temp.len_0x000b_0x00=8 +hwmon_temp.bit_offset_0x000b_0x00= +hwmon_temp.str_cons_0x000b_0x00=temp1_input + +hwmon_temp.mode_0x000b_0x01=str_constant +hwmon_temp.str_cons_0x000b_0x01=MAC_air_inlet + +hwmon_temp.mode_0x000b_0x02=str_constant +hwmon_temp.str_cons_0x000b_0x02=lm75 + +hwmon_temp.mode_0x000b_0x03=config +hwmon_temp.int_cons_0x000b_0x03=0 +hwmon_temp.src_0x000b_0x03=file +hwmon_temp.frmt_0x000b_0x03=buf +hwmon_temp.fpath_0x000b_0x03=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x03=0 +hwmon_temp.len_0x000b_0x03=8 +hwmon_temp.bit_offset_0x000b_0x03= +hwmon_temp.str_cons_0x000b_0x03=temp1_max + +hwmon_temp.mode_0x000b_0x04=config +hwmon_temp.int_cons_0x000b_0x04=0 +hwmon_temp.src_0x000b_0x04=file +hwmon_temp.frmt_0x000b_0x04=buf +hwmon_temp.fpath_0x000b_0x04=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x04=0 +hwmon_temp.len_0x000b_0x04=8 +hwmon_temp.bit_offset_0x000b_0x04= +hwmon_temp.str_cons_0x000b_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000c_0x00=config +hwmon_temp.int_cons_0x000c_0x00=0 +hwmon_temp.src_0x000c_0x00=file +hwmon_temp.frmt_0x000c_0x00=buf +hwmon_temp.fpath_0x000c_0x00=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x00=0 +hwmon_temp.len_0x000c_0x00=8 +hwmon_temp.bit_offset_0x000c_0x00= +hwmon_temp.str_cons_0x000c_0x00=temp1_input + +hwmon_temp.mode_0x000c_0x01=str_constant +hwmon_temp.str_cons_0x000c_0x01=Base_air_inlet + +hwmon_temp.mode_0x000c_0x02=str_constant +hwmon_temp.str_cons_0x000c_0x02=lm75 + +hwmon_temp.mode_0x000c_0x03=config +hwmon_temp.int_cons_0x000c_0x03=0 +hwmon_temp.src_0x000c_0x03=file +hwmon_temp.frmt_0x000c_0x03=buf +hwmon_temp.fpath_0x000c_0x03=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x03=0 +hwmon_temp.len_0x000c_0x03=8 +hwmon_temp.bit_offset_0x000c_0x03= +hwmon_temp.str_cons_0x000c_0x03=temp1_max + +hwmon_temp.mode_0x000c_0x04=config +hwmon_temp.int_cons_0x000c_0x04=0 +hwmon_temp.src_0x000c_0x04=file +hwmon_temp.frmt_0x000c_0x04=buf +hwmon_temp.fpath_0x000c_0x04=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x04=0 +hwmon_temp.len_0x000c_0x04=8 +hwmon_temp.bit_offset_0x000c_0x04= +hwmon_temp.str_cons_0x000c_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000d_0x00=config +hwmon_temp.int_cons_0x000d_0x00=0 +hwmon_temp.src_0x000d_0x00=file +hwmon_temp.frmt_0x000d_0x00=buf +hwmon_temp.fpath_0x000d_0x00=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x00=0 +hwmon_temp.len_0x000d_0x00=8 +hwmon_temp.bit_offset_0x000d_0x00= +hwmon_temp.str_cons_0x000d_0x00=temp1_input + +hwmon_temp.mode_0x000d_0x01=str_constant +hwmon_temp.str_cons_0x000d_0x01=MAC_air_outlet + +hwmon_temp.mode_0x000d_0x02=str_constant +hwmon_temp.str_cons_0x000d_0x02=lm75 + +hwmon_temp.mode_0x000d_0x03=config +hwmon_temp.int_cons_0x000d_0x03=0 +hwmon_temp.src_0x000d_0x03=file +hwmon_temp.frmt_0x000d_0x03=buf +hwmon_temp.fpath_0x000d_0x03=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x03=0 +hwmon_temp.len_0x000d_0x03=8 +hwmon_temp.bit_offset_0x000d_0x03= +hwmon_temp.str_cons_0x000d_0x03=temp1_max + +hwmon_temp.mode_0x000d_0x04=config +hwmon_temp.int_cons_0x000d_0x04=0 +hwmon_temp.src_0x000d_0x04=file +hwmon_temp.frmt_0x000d_0x04=buf +hwmon_temp.fpath_0x000d_0x04=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x04=0 +hwmon_temp.len_0x000d_0x04=8 +hwmon_temp.bit_offset_0x000d_0x04= +hwmon_temp.str_cons_0x000d_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000e_0x00=config +hwmon_temp.int_cons_0x000e_0x00=0 +hwmon_temp.src_0x000e_0x00=file +hwmon_temp.frmt_0x000e_0x00=buf +hwmon_temp.fpath_0x000e_0x00=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x00=0 +hwmon_temp.len_0x000e_0x00=8 +hwmon_temp.bit_offset_0x000e_0x00= +hwmon_temp.str_cons_0x000e_0x00=temp2_input + +hwmon_temp.mode_0x000e_0x01=str_constant +hwmon_temp.str_cons_0x000e_0x01=MAC_TEMPDIODE0 + +hwmon_temp.mode_0x000e_0x02=str_constant +hwmon_temp.str_cons_0x000e_0x02=tmp411 + +hwmon_temp.mode_0x000e_0x03=config +hwmon_temp.int_cons_0x000e_0x03=0 +hwmon_temp.src_0x000e_0x03=file +hwmon_temp.frmt_0x000e_0x03=buf +hwmon_temp.fpath_0x000e_0x03=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x03=0 +hwmon_temp.len_0x000e_0x03=8 +hwmon_temp.bit_offset_0x000e_0x03= +hwmon_temp.str_cons_0x000e_0x03=temp2_max + +hwmon_temp.mode_0x000e_0x04=config +hwmon_temp.int_cons_0x000e_0x04=0 +hwmon_temp.src_0x000e_0x04=file +hwmon_temp.frmt_0x000e_0x04=buf +hwmon_temp.fpath_0x000e_0x04=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x04=0 +hwmon_temp.len_0x000e_0x04=8 +hwmon_temp.bit_offset_0x000e_0x04= +hwmon_temp.str_cons_0x000e_0x04=temp2_max_hyst + +hwmon_temp.mode_0x000f_0x00=config +hwmon_temp.int_cons_0x000f_0x00=0 +hwmon_temp.src_0x000f_0x00=file +hwmon_temp.frmt_0x000f_0x00=buf +hwmon_temp.fpath_0x000f_0x00=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x00=0 +hwmon_temp.len_0x000f_0x00=8 +hwmon_temp.bit_offset_0x000f_0x00= +hwmon_temp.str_cons_0x000f_0x00=temp2_input + +hwmon_temp.mode_0x000f_0x01=str_constant +hwmon_temp.str_cons_0x000f_0x01=MAC_TEMPDIODE1 + +hwmon_temp.mode_0x000f_0x02=str_constant +hwmon_temp.str_cons_0x000f_0x02=tmp411 + +hwmon_temp.mode_0x000f_0x03=config +hwmon_temp.int_cons_0x000f_0x03=0 +hwmon_temp.src_0x000f_0x03=file +hwmon_temp.frmt_0x000f_0x03=buf +hwmon_temp.fpath_0x000f_0x03=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x03=0 +hwmon_temp.len_0x000f_0x03=8 +hwmon_temp.bit_offset_0x000f_0x03= +hwmon_temp.str_cons_0x000f_0x03=temp2_max + +hwmon_temp.mode_0x000f_0x04=config +hwmon_temp.int_cons_0x000f_0x04=0 +hwmon_temp.src_0x000f_0x04=file +hwmon_temp.frmt_0x000f_0x04=buf +hwmon_temp.fpath_0x000f_0x04=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x04=0 +hwmon_temp.len_0x000f_0x04=8 +hwmon_temp.bit_offset_0x000f_0x04= +hwmon_temp.str_cons_0x000f_0x04=temp2_max_hyst + +hwmon_temp.mode_0x0010_0x00=config +hwmon_temp.int_cons_0x0010_0x00=0 +hwmon_temp.src_0x0010_0x00=file +hwmon_temp.frmt_0x0010_0x00=buf +hwmon_temp.fpath_0x0010_0x00=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x00=0 +hwmon_temp.len_0x0010_0x00=8 +hwmon_temp.bit_offset_0x0010_0x00= +hwmon_temp.str_cons_0x0010_0x00=temp1_input + +hwmon_temp.mode_0x0010_0x01=str_constant +hwmon_temp.str_cons_0x0010_0x01=FCB_air_outlet_UL + +hwmon_temp.mode_0x0010_0x02=str_constant +hwmon_temp.str_cons_0x0010_0x02=lm75 + +hwmon_temp.mode_0x0010_0x03=config +hwmon_temp.int_cons_0x0010_0x03=0 +hwmon_temp.src_0x0010_0x03=file +hwmon_temp.frmt_0x0010_0x03=buf +hwmon_temp.fpath_0x0010_0x03=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x03=0 +hwmon_temp.len_0x0010_0x03=8 +hwmon_temp.bit_offset_0x0010_0x03= +hwmon_temp.str_cons_0x0010_0x03=temp1_max + +hwmon_temp.mode_0x0010_0x04=config +hwmon_temp.int_cons_0x0010_0x04=0 +hwmon_temp.src_0x0010_0x04=file +hwmon_temp.frmt_0x0010_0x04=buf +hwmon_temp.fpath_0x0010_0x04=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x04=0 +hwmon_temp.len_0x0010_0x04=8 +hwmon_temp.bit_offset_0x0010_0x04= +hwmon_temp.str_cons_0x0010_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0011_0x00=config +hwmon_temp.int_cons_0x0011_0x00=0 +hwmon_temp.src_0x0011_0x00=file +hwmon_temp.frmt_0x0011_0x00=buf +hwmon_temp.fpath_0x0011_0x00=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x00=0 +hwmon_temp.len_0x0011_0x00=8 +hwmon_temp.bit_offset_0x0011_0x00= +hwmon_temp.str_cons_0x0011_0x00=temp1_input + +hwmon_temp.mode_0x0011_0x01=str_constant +hwmon_temp.str_cons_0x0011_0x01=FCB_air_outlet_UR + +hwmon_temp.mode_0x0011_0x02=str_constant +hwmon_temp.str_cons_0x0011_0x02=lm75 + +hwmon_temp.mode_0x0011_0x03=config +hwmon_temp.int_cons_0x0011_0x03=0 +hwmon_temp.src_0x0011_0x03=file +hwmon_temp.frmt_0x0011_0x03=buf +hwmon_temp.fpath_0x0011_0x03=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x03=0 +hwmon_temp.len_0x0011_0x03=8 +hwmon_temp.bit_offset_0x0011_0x03= +hwmon_temp.str_cons_0x0011_0x03=temp1_max + +hwmon_temp.mode_0x0011_0x04=config +hwmon_temp.int_cons_0x0011_0x04=0 +hwmon_temp.src_0x0011_0x04=file +hwmon_temp.frmt_0x0011_0x04=buf +hwmon_temp.fpath_0x0011_0x04=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x04=0 +hwmon_temp.len_0x0011_0x04=8 +hwmon_temp.bit_offset_0x0011_0x04= +hwmon_temp.str_cons_0x0011_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0012_0x00=config +hwmon_temp.int_cons_0x0012_0x00=0 +hwmon_temp.src_0x0012_0x00=file +hwmon_temp.frmt_0x0012_0x00=buf +hwmon_temp.fpath_0x0012_0x00=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x00=0 +hwmon_temp.len_0x0012_0x00=8 +hwmon_temp.bit_offset_0x0012_0x00= +hwmon_temp.str_cons_0x0012_0x00=temp1_input + +hwmon_temp.mode_0x0012_0x01=str_constant +hwmon_temp.str_cons_0x0012_0x01=FCB_air_outlet_DL + +hwmon_temp.mode_0x0012_0x02=str_constant +hwmon_temp.str_cons_0x0012_0x02=lm75 + +hwmon_temp.mode_0x0012_0x03=config +hwmon_temp.int_cons_0x0012_0x03=0 +hwmon_temp.src_0x0012_0x03=file +hwmon_temp.frmt_0x0012_0x03=buf +hwmon_temp.fpath_0x0012_0x03=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x03=0 +hwmon_temp.len_0x0012_0x03=8 +hwmon_temp.bit_offset_0x0012_0x03= +hwmon_temp.str_cons_0x0012_0x03=temp1_max + +hwmon_temp.mode_0x0012_0x04=config +hwmon_temp.int_cons_0x0012_0x04=0 +hwmon_temp.src_0x0012_0x04=file +hwmon_temp.frmt_0x0012_0x04=buf +hwmon_temp.fpath_0x0012_0x04=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x04=0 +hwmon_temp.len_0x0012_0x04=8 +hwmon_temp.bit_offset_0x0012_0x04= +hwmon_temp.str_cons_0x0012_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0013_0x00=config +hwmon_temp.int_cons_0x0013_0x00=0 +hwmon_temp.src_0x0013_0x00=file +hwmon_temp.frmt_0x0013_0x00=buf +hwmon_temp.fpath_0x0013_0x00=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x00=0 +hwmon_temp.len_0x0013_0x00=8 +hwmon_temp.bit_offset_0x0013_0x00= +hwmon_temp.str_cons_0x0013_0x00=temp1_input + +hwmon_temp.mode_0x0013_0x01=str_constant +hwmon_temp.str_cons_0x0013_0x01=FCB_air_outlet_DR + +hwmon_temp.mode_0x0013_0x02=str_constant +hwmon_temp.str_cons_0x0013_0x02=lm75 + +hwmon_temp.mode_0x0013_0x03=config +hwmon_temp.int_cons_0x0013_0x03=0 +hwmon_temp.src_0x0013_0x03=file +hwmon_temp.frmt_0x0013_0x03=buf +hwmon_temp.fpath_0x0013_0x03=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x03=0 +hwmon_temp.len_0x0013_0x03=8 +hwmon_temp.bit_offset_0x0013_0x03= +hwmon_temp.str_cons_0x0013_0x03=temp1_max + +hwmon_temp.mode_0x0013_0x04=config +hwmon_temp.int_cons_0x0013_0x04=0 +hwmon_temp.src_0x0013_0x04=file +hwmon_temp.frmt_0x0013_0x04=buf +hwmon_temp.fpath_0x0013_0x04=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x04=0 +hwmon_temp.len_0x0013_0x04=8 +hwmon_temp.bit_offset_0x0013_0x04= +hwmon_temp.str_cons_0x0013_0x04=temp1_max_hyst + + +# sensor temp20 input +hwmon_temp.mode_0x0014_0x00=config +hwmon_temp.int_cons_0x0014_0x00=0 +hwmon_temp.src_0x0014_0x00=file +hwmon_temp.frmt_0x0014_0x00=buf +hwmon_temp.fpath_0x0014_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0014_0x00=0 +hwmon_temp.len_0x0014_0x00=16 +hwmon_temp.bit_offset_0x0014_0x00= +hwmon_temp.str_cons_0x0014_0x00=temp1_input + +# sensor temp20 alias +hwmon_temp.mode_0x0014_0x01=str_constant +hwmon_temp.str_cons_0x0014_0x01=MAC_DIE_0 + +# sensor temp20 type +hwmon_temp.mode_0x0014_0x02=str_constant +hwmon_temp.str_cons_0x0014_0x02=mac_bsc + + +# sensor temp21 input +hwmon_temp.mode_0x0015_0x00=config +hwmon_temp.int_cons_0x0015_0x00=0 +hwmon_temp.src_0x0015_0x00=file +hwmon_temp.frmt_0x0015_0x00=buf +hwmon_temp.fpath_0x0015_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0015_0x00=0 +hwmon_temp.len_0x0015_0x00=16 +hwmon_temp.bit_offset_0x0015_0x00= +hwmon_temp.str_cons_0x0015_0x00=temp2_input + +# sensor temp21 alias +hwmon_temp.mode_0x0015_0x01=str_constant +hwmon_temp.str_cons_0x0015_0x01=MAC_DIE_1 + +# sensor temp21 type +hwmon_temp.mode_0x0015_0x02=str_constant +hwmon_temp.str_cons_0x0015_0x02=mac_bsc + + +# sensor temp22 input +hwmon_temp.mode_0x0016_0x00=config +hwmon_temp.int_cons_0x0016_0x00=0 +hwmon_temp.src_0x0016_0x00=file +hwmon_temp.frmt_0x0016_0x00=buf +hwmon_temp.fpath_0x0016_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0016_0x00=0 +hwmon_temp.len_0x0016_0x00=16 +hwmon_temp.bit_offset_0x0016_0x00= +hwmon_temp.str_cons_0x0016_0x00=temp3_input + +# sensor temp22 alias +hwmon_temp.mode_0x0016_0x01=str_constant +hwmon_temp.str_cons_0x0016_0x01=MAC_DIE_2 + +# sensor temp22 type +hwmon_temp.mode_0x0016_0x02=str_constant +hwmon_temp.str_cons_0x0016_0x02=mac_bsc + + +# sensor temp23 input +hwmon_temp.mode_0x0017_0x00=config +hwmon_temp.int_cons_0x0017_0x00=0 +hwmon_temp.src_0x0017_0x00=file +hwmon_temp.frmt_0x0017_0x00=buf +hwmon_temp.fpath_0x0017_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0017_0x00=0 +hwmon_temp.len_0x0017_0x00=16 +hwmon_temp.bit_offset_0x0017_0x00= +hwmon_temp.str_cons_0x0017_0x00=temp4_input + +# sensor temp23 alias +hwmon_temp.mode_0x0017_0x01=str_constant +hwmon_temp.str_cons_0x0017_0x01=MAC_DIE_3 + +# sensor temp23 type +hwmon_temp.mode_0x0017_0x02=str_constant +hwmon_temp.str_cons_0x0017_0x02=mac_bsc + + +# sensor temp24 input +hwmon_temp.mode_0x0018_0x00=config +hwmon_temp.int_cons_0x0018_0x00=0 +hwmon_temp.src_0x0018_0x00=file +hwmon_temp.frmt_0x0018_0x00=buf +hwmon_temp.fpath_0x0018_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0018_0x00=0 +hwmon_temp.len_0x0018_0x00=16 +hwmon_temp.bit_offset_0x0018_0x00= +hwmon_temp.str_cons_0x0018_0x00=temp5_input + +# sensor temp24 alias +hwmon_temp.mode_0x0018_0x01=str_constant +hwmon_temp.str_cons_0x0018_0x01=MAC_DIE_4 + +# sensor temp24 type +hwmon_temp.mode_0x0018_0x02=str_constant +hwmon_temp.str_cons_0x0018_0x02=mac_bsc + + +# sensor temp25 input +hwmon_temp.mode_0x0019_0x00=config +hwmon_temp.int_cons_0x0019_0x00=0 +hwmon_temp.src_0x0019_0x00=file +hwmon_temp.frmt_0x0019_0x00=buf +hwmon_temp.fpath_0x0019_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0019_0x00=0 +hwmon_temp.len_0x0019_0x00=16 +hwmon_temp.bit_offset_0x0019_0x00= +hwmon_temp.str_cons_0x0019_0x00=temp6_input + +# sensor temp25 alias +hwmon_temp.mode_0x0019_0x01=str_constant +hwmon_temp.str_cons_0x0019_0x01=MAC_DIE_5 + +# sensor temp25 type +hwmon_temp.mode_0x0019_0x02=str_constant +hwmon_temp.str_cons_0x0019_0x02=mac_bsc + + +# sensor temp26 input +hwmon_temp.mode_0x001a_0x00=config +hwmon_temp.int_cons_0x001a_0x00=0 +hwmon_temp.src_0x001a_0x00=file +hwmon_temp.frmt_0x001a_0x00=buf +hwmon_temp.fpath_0x001a_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001a_0x00=0 +hwmon_temp.len_0x001a_0x00=16 +hwmon_temp.bit_offset_0x001a_0x00= +hwmon_temp.str_cons_0x001a_0x00=temp7_input + +# sensor temp26 alias +hwmon_temp.mode_0x001a_0x01=str_constant +hwmon_temp.str_cons_0x001a_0x01=MAC_DIE_6 + +# sensor temp26 type +hwmon_temp.mode_0x001a_0x02=str_constant +hwmon_temp.str_cons_0x001a_0x02=mac_bsc + + +# sensor temp27 input +hwmon_temp.mode_0x001b_0x00=config +hwmon_temp.int_cons_0x001b_0x00=0 +hwmon_temp.src_0x001b_0x00=file +hwmon_temp.frmt_0x001b_0x00=buf +hwmon_temp.fpath_0x001b_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001b_0x00=0 +hwmon_temp.len_0x001b_0x00=16 +hwmon_temp.bit_offset_0x001b_0x00= +hwmon_temp.str_cons_0x001b_0x00=temp8_input + +# sensor temp27 alias +hwmon_temp.mode_0x001b_0x01=str_constant +hwmon_temp.str_cons_0x001b_0x01=MAC_DIE_7 + +# sensor temp27 type +hwmon_temp.mode_0x001b_0x02=str_constant +hwmon_temp.str_cons_0x001b_0x02=mac_bsc + + +# sensor temp28 input +hwmon_temp.mode_0x001c_0x00=config +hwmon_temp.int_cons_0x001c_0x00=0 +hwmon_temp.src_0x001c_0x00=file +hwmon_temp.frmt_0x001c_0x00=buf +hwmon_temp.fpath_0x001c_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001c_0x00=0 +hwmon_temp.len_0x001c_0x00=16 +hwmon_temp.bit_offset_0x001c_0x00= +hwmon_temp.str_cons_0x001c_0x00=temp9_input + +# sensor temp28 alias +hwmon_temp.mode_0x001c_0x01=str_constant +hwmon_temp.str_cons_0x001c_0x01=MAC_DIE_8 + +# sensor temp28 type +hwmon_temp.mode_0x001c_0x02=str_constant +hwmon_temp.str_cons_0x001c_0x02=mac_bsc + + +# sensor temp29 input +hwmon_temp.mode_0x001d_0x00=config +hwmon_temp.int_cons_0x001d_0x00=0 +hwmon_temp.src_0x001d_0x00=file +hwmon_temp.frmt_0x001d_0x00=buf +hwmon_temp.fpath_0x001d_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001d_0x00=0 +hwmon_temp.len_0x001d_0x00=16 +hwmon_temp.bit_offset_0x001d_0x00= +hwmon_temp.str_cons_0x001d_0x00=temp10_input + +# sensor temp29 alias +hwmon_temp.mode_0x001d_0x01=str_constant +hwmon_temp.str_cons_0x001d_0x01=MAC_DIE_9 + +# sensor temp29 type +hwmon_temp.mode_0x001d_0x02=str_constant +hwmon_temp.str_cons_0x001d_0x02=mac_bsc + + +# sensor temp30 input +hwmon_temp.mode_0x001e_0x00=config +hwmon_temp.int_cons_0x001e_0x00=0 +hwmon_temp.src_0x001e_0x00=file +hwmon_temp.frmt_0x001e_0x00=buf +hwmon_temp.fpath_0x001e_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001e_0x00=0 +hwmon_temp.len_0x001e_0x00=16 +hwmon_temp.bit_offset_0x001e_0x00= +hwmon_temp.str_cons_0x001e_0x00=temp11_input + +# sensor temp30 alias +hwmon_temp.mode_0x001e_0x01=str_constant +hwmon_temp.str_cons_0x001e_0x01=MAC_DIE_10 + +# sensor temp30 type +hwmon_temp.mode_0x001e_0x02=str_constant +hwmon_temp.str_cons_0x001e_0x02=mac_bsc + + +# sensor temp31 input +hwmon_temp.mode_0x001f_0x00=config +hwmon_temp.int_cons_0x001f_0x00=0 +hwmon_temp.src_0x001f_0x00=file +hwmon_temp.frmt_0x001f_0x00=buf +hwmon_temp.fpath_0x001f_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001f_0x00=0 +hwmon_temp.len_0x001f_0x00=16 +hwmon_temp.bit_offset_0x001f_0x00= +hwmon_temp.str_cons_0x001f_0x00=temp12_input + +# sensor temp31 alias +hwmon_temp.mode_0x001f_0x01=str_constant +hwmon_temp.str_cons_0x001f_0x01=MAC_DIE_11 + +# sensor temp31 type +hwmon_temp.mode_0x001f_0x02=str_constant +hwmon_temp.str_cons_0x001f_0x02=mac_bsc + + +# sensor temp32 input +hwmon_temp.mode_0x0020_0x00=config +hwmon_temp.int_cons_0x0020_0x00=0 +hwmon_temp.src_0x0020_0x00=file +hwmon_temp.frmt_0x0020_0x00=buf +hwmon_temp.fpath_0x0020_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0020_0x00=0 +hwmon_temp.len_0x0020_0x00=16 +hwmon_temp.bit_offset_0x0020_0x00= +hwmon_temp.str_cons_0x0020_0x00=temp13_input + +# sensor temp32 alias +hwmon_temp.mode_0x0020_0x01=str_constant +hwmon_temp.str_cons_0x0020_0x01=MAC_DIE_12 + +# sensor temp32 type +hwmon_temp.mode_0x0020_0x02=str_constant +hwmon_temp.str_cons_0x0020_0x02=mac_bsc + + +# sensor temp33 input +hwmon_temp.mode_0x0021_0x00=config +hwmon_temp.int_cons_0x0021_0x00=0 +hwmon_temp.src_0x0021_0x00=file +hwmon_temp.frmt_0x0021_0x00=buf +hwmon_temp.fpath_0x0021_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0021_0x00=0 +hwmon_temp.len_0x0021_0x00=16 +hwmon_temp.bit_offset_0x0021_0x00= +hwmon_temp.str_cons_0x0021_0x00=temp14_input + +# sensor temp33 alias +hwmon_temp.mode_0x0021_0x01=str_constant +hwmon_temp.str_cons_0x0021_0x01=MAC_DIE_13 + +# sensor temp33 type +hwmon_temp.mode_0x0021_0x02=str_constant +hwmon_temp.str_cons_0x0021_0x02=mac_bsc + + +# sensor temp34 input +hwmon_temp.mode_0x0022_0x00=config +hwmon_temp.int_cons_0x0022_0x00=0 +hwmon_temp.src_0x0022_0x00=file +hwmon_temp.frmt_0x0022_0x00=buf +hwmon_temp.fpath_0x0022_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0022_0x00=0 +hwmon_temp.len_0x0022_0x00=16 +hwmon_temp.bit_offset_0x0022_0x00= +hwmon_temp.str_cons_0x0022_0x00=temp15_input + +# sensor temp34 alias +hwmon_temp.mode_0x0022_0x01=str_constant +hwmon_temp.str_cons_0x0022_0x01=MAC_DIE_14 + +# sensor temp34 type +hwmon_temp.mode_0x0022_0x02=str_constant +hwmon_temp.str_cons_0x0022_0x02=mac_bsc + + +# sensor vol +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=0 +hwmon_in.src_0x0001_0x00=file +hwmon_in.frmt_0x0001_0x00=buf +hwmon_in.fpath_0x0001_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0001_0x00=0 +hwmon_in.len_0x0001_0x00=8 +hwmon_in.bit_offset_0x0001_0x00= +hwmon_in.str_cons_0x0001_0x00=in1_input + +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_VDD_ANALOG1 + +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=ucd90160 + +hwmon_in.mode_0x0001_0x03=constant +hwmon_in.int_cons_0x0001_0x03=809 + +hwmon_in.mode_0x0001_0x05=constant +hwmon_in.int_cons_0x0001_0x05=731 + +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=0 +hwmon_in.src_0x0002_0x00=file +hwmon_in.frmt_0x0002_0x00=buf +hwmon_in.fpath_0x0002_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0002_0x00=0 +hwmon_in.len_0x0002_0x00=8 +hwmon_in.bit_offset_0x0002_0x00= +hwmon_in.str_cons_0x0002_0x00=in2_input + +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_VDD12V + +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=ucd90160 + +hwmon_in.mode_0x0002_0x03=constant +hwmon_in.int_cons_0x0002_0x03=12600 + +hwmon_in.mode_0x0002_0x05=constant +hwmon_in.int_cons_0x0002_0x05=11400 + +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=0 +hwmon_in.src_0x0003_0x00=file +hwmon_in.frmt_0x0003_0x00=buf +hwmon_in.fpath_0x0003_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0003_0x00=0 +hwmon_in.len_0x0003_0x00=8 +hwmon_in.bit_offset_0x0003_0x00= +hwmon_in.str_cons_0x0003_0x00=in3_input + +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_VDD1.0V_FPGA + +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=ucd90160 + +hwmon_in.mode_0x0003_0x03=constant +hwmon_in.int_cons_0x0003_0x03=1071 + +hwmon_in.mode_0x0003_0x05=constant +hwmon_in.int_cons_0x0003_0x05=969 + +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=0 +hwmon_in.src_0x0004_0x00=file +hwmon_in.frmt_0x0004_0x00=buf +hwmon_in.fpath_0x0004_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0004_0x00=0 +hwmon_in.len_0x0004_0x00=8 +hwmon_in.bit_offset_0x0004_0x00= +hwmon_in.str_cons_0x0004_0x00=in4_input + +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_VDD1.8V_FPGA + +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=ucd90160 + +hwmon_in.mode_0x0004_0x03=constant +hwmon_in.int_cons_0x0004_0x03=1890 + +hwmon_in.mode_0x0004_0x05=constant +hwmon_in.int_cons_0x0004_0x05=1710 + +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=0 +hwmon_in.src_0x0005_0x00=file +hwmon_in.frmt_0x0005_0x00=buf +hwmon_in.fpath_0x0005_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0005_0x00=0 +hwmon_in.len_0x0005_0x00=8 +hwmon_in.bit_offset_0x0005_0x00= +hwmon_in.str_cons_0x0005_0x00=in5_input + +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_VDD1.2V_FPGA + +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=ucd90160 + +hwmon_in.mode_0x0005_0x03=constant +hwmon_in.int_cons_0x0005_0x03=1260 + +hwmon_in.mode_0x0005_0x05=constant +hwmon_in.int_cons_0x0005_0x05=1140 + +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=0 +hwmon_in.src_0x0006_0x00=file +hwmon_in.frmt_0x0006_0x00=buf +hwmon_in.fpath_0x0006_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0006_0x00=0 +hwmon_in.len_0x0006_0x00=8 +hwmon_in.bit_offset_0x0006_0x00= +hwmon_in.str_cons_0x0006_0x00=in6_input + +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_VDD3.3V + +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=ucd90160 + +hwmon_in.mode_0x0006_0x03=constant +hwmon_in.int_cons_0x0006_0x03=3465 + +hwmon_in.mode_0x0006_0x05=constant +hwmon_in.int_cons_0x0006_0x05=3135 + +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=0 +hwmon_in.src_0x0007_0x00=file +hwmon_in.frmt_0x0007_0x00=buf +hwmon_in.fpath_0x0007_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0007_0x00=0 +hwmon_in.len_0x0007_0x00=8 +hwmon_in.bit_offset_0x0007_0x00= +hwmon_in.str_cons_0x0007_0x00=in7_input + +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_SW_VDD1.2V + +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=ucd90160 + +hwmon_in.mode_0x0007_0x03=constant +hwmon_in.int_cons_0x0007_0x03=1260 + +hwmon_in.mode_0x0007_0x05=constant +hwmon_in.int_cons_0x0007_0x05=1140 + +hwmon_in.mode_0x0008_0x00=config +hwmon_in.int_cons_0x0008_0x00=0 +hwmon_in.src_0x0008_0x00=file +hwmon_in.frmt_0x0008_0x00=buf +hwmon_in.fpath_0x0008_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0008_0x00=0 +hwmon_in.len_0x0008_0x00=8 +hwmon_in.bit_offset_0x0008_0x00= +hwmon_in.str_cons_0x0008_0x00=in8_input + +hwmon_in.mode_0x0008_0x01=str_constant +hwmon_in.str_cons_0x0008_0x01=MAC_VDD5V_CLK_MCU + +hwmon_in.mode_0x0008_0x02=str_constant +hwmon_in.str_cons_0x0008_0x02=ucd90160 + +hwmon_in.mode_0x0008_0x03=constant +hwmon_in.int_cons_0x0008_0x03=5334 + +hwmon_in.mode_0x0008_0x05=constant +hwmon_in.int_cons_0x0008_0x05=4826 + +hwmon_in.mode_0x0009_0x00=config +hwmon_in.int_cons_0x0009_0x00=0 +hwmon_in.src_0x0009_0x00=file +hwmon_in.frmt_0x0009_0x00=buf +hwmon_in.fpath_0x0009_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0009_0x00=0 +hwmon_in.len_0x0009_0x00=8 +hwmon_in.bit_offset_0x0009_0x00= +hwmon_in.str_cons_0x0009_0x00=in9_input + +hwmon_in.mode_0x0009_0x01=str_constant +hwmon_in.str_cons_0x0009_0x01=MAC_VDD5V_VR + +hwmon_in.mode_0x0009_0x02=str_constant +hwmon_in.str_cons_0x0009_0x02=ucd90160 + +hwmon_in.mode_0x0009_0x03=constant +hwmon_in.int_cons_0x0009_0x03=5334 + +hwmon_in.mode_0x0009_0x05=constant +hwmon_in.int_cons_0x0009_0x05=4826 + +hwmon_in.mode_0x000a_0x00=config +hwmon_in.int_cons_0x000a_0x00=0 +hwmon_in.src_0x000a_0x00=file +hwmon_in.frmt_0x000a_0x00=buf +hwmon_in.fpath_0x000a_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000a_0x00=0 +hwmon_in.len_0x000a_0x00=8 +hwmon_in.bit_offset_0x000a_0x00= +hwmon_in.str_cons_0x000a_0x00=in10_input + +hwmon_in.mode_0x000a_0x01=str_constant +hwmon_in.str_cons_0x000a_0x01=MAC_VDD3.3_CLK + +hwmon_in.mode_0x000a_0x02=str_constant +hwmon_in.str_cons_0x000a_0x02=ucd90160 + +hwmon_in.mode_0x000a_0x03=constant +hwmon_in.int_cons_0x000a_0x03=3486 + +hwmon_in.mode_0x000a_0x05=constant +hwmon_in.int_cons_0x000a_0x05=3154 + +hwmon_in.mode_0x000b_0x00=config +hwmon_in.int_cons_0x000b_0x00=0 +hwmon_in.src_0x000b_0x00=file +hwmon_in.frmt_0x000b_0x00=buf +hwmon_in.fpath_0x000b_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000b_0x00=0 +hwmon_in.len_0x000b_0x00=8 +hwmon_in.bit_offset_0x000b_0x00= +hwmon_in.str_cons_0x000b_0x00=in11_input + +hwmon_in.mode_0x000b_0x01=str_constant +hwmon_in.str_cons_0x000b_0x01=MAC_VDDO1.8V + +hwmon_in.mode_0x000b_0x02=str_constant +hwmon_in.str_cons_0x000b_0x02=ucd90160 + +hwmon_in.mode_0x000b_0x03=constant +hwmon_in.int_cons_0x000b_0x03=1901 + +hwmon_in.mode_0x000b_0x05=constant +hwmon_in.int_cons_0x000b_0x05=1719 + +hwmon_in.mode_0x000c_0x00=config +hwmon_in.int_cons_0x000c_0x00=0 +hwmon_in.src_0x000c_0x00=file +hwmon_in.frmt_0x000c_0x00=buf +hwmon_in.fpath_0x000c_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000c_0x00=0 +hwmon_in.len_0x000c_0x00=8 +hwmon_in.bit_offset_0x000c_0x00= +hwmon_in.str_cons_0x000c_0x00=in12_input + +hwmon_in.mode_0x000c_0x01=str_constant +hwmon_in.str_cons_0x000c_0x01=MAC_VDDO1.2V + +hwmon_in.mode_0x000c_0x02=str_constant +hwmon_in.str_cons_0x000c_0x02=ucd90160 + +hwmon_in.mode_0x000c_0x03=constant +hwmon_in.int_cons_0x000c_0x03=1260 + +hwmon_in.mode_0x000c_0x05=constant +hwmon_in.int_cons_0x000c_0x05=1140 + +hwmon_in.mode_0x000d_0x00=config +hwmon_in.int_cons_0x000d_0x00=0 +hwmon_in.src_0x000d_0x00=file +hwmon_in.frmt_0x000d_0x00=buf +hwmon_in.fpath_0x000d_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000d_0x00=0 +hwmon_in.len_0x000d_0x00=8 +hwmon_in.bit_offset_0x000d_0x00= +hwmon_in.str_cons_0x000d_0x00=in13_input + +hwmon_in.mode_0x000d_0x01=str_constant +hwmon_in.str_cons_0x000d_0x01=MAC_VDD_CORE + +hwmon_in.mode_0x000d_0x02=str_constant +hwmon_in.str_cons_0x000d_0x02=ucd90160 + +hwmon_in.mode_0x000d_0x03=constant +hwmon_in.int_cons_0x000d_0x03=950 + +hwmon_in.mode_0x000d_0x05=constant +hwmon_in.int_cons_0x000d_0x05=700 + +hwmon_in.mode_0x000e_0x00=config +hwmon_in.int_cons_0x000e_0x00=0 +hwmon_in.src_0x000e_0x00=file +hwmon_in.frmt_0x000e_0x00=buf +hwmon_in.fpath_0x000e_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000e_0x00=0 +hwmon_in.len_0x000e_0x00=8 +hwmon_in.bit_offset_0x000e_0x00= +hwmon_in.str_cons_0x000e_0x00=in14_input + +hwmon_in.mode_0x000e_0x01=str_constant +hwmon_in.str_cons_0x000e_0x01=MAC_VDD_ANALOG + +hwmon_in.mode_0x000e_0x02=str_constant +hwmon_in.str_cons_0x000e_0x02=ucd90160 + +hwmon_in.mode_0x000e_0x03=constant +hwmon_in.int_cons_0x000e_0x03=809 + +hwmon_in.mode_0x000e_0x05=constant +hwmon_in.int_cons_0x000e_0x05=731 + +hwmon_in.mode_0x000f_0x00=config +hwmon_in.int_cons_0x000f_0x00=0 +hwmon_in.src_0x000f_0x00=file +hwmon_in.frmt_0x000f_0x00=buf +hwmon_in.fpath_0x000f_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000f_0x00=0 +hwmon_in.len_0x000f_0x00=8 +hwmon_in.bit_offset_0x000f_0x00= +hwmon_in.str_cons_0x000f_0x00=in15_input + +hwmon_in.mode_0x000f_0x01=str_constant +hwmon_in.str_cons_0x000f_0x01=MAC_VDD1.2V_MAC + +hwmon_in.mode_0x000f_0x02=str_constant +hwmon_in.str_cons_0x000f_0x02=ucd90160 + +hwmon_in.mode_0x000f_0x03=constant +hwmon_in.int_cons_0x000f_0x03=1260 + +hwmon_in.mode_0x000f_0x05=constant +hwmon_in.int_cons_0x000f_0x05=1140 + +hwmon_in.mode_0x0010_0x00=config +hwmon_in.int_cons_0x0010_0x00=0 +hwmon_in.src_0x0010_0x00=file +hwmon_in.frmt_0x0010_0x00=buf +hwmon_in.fpath_0x0010_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0010_0x00=0 +hwmon_in.len_0x0010_0x00=8 +hwmon_in.bit_offset_0x0010_0x00= +hwmon_in.str_cons_0x0010_0x00=in16_input + +hwmon_in.mode_0x0010_0x01=str_constant +hwmon_in.str_cons_0x0010_0x01=MAC_AVDD1.8V + +hwmon_in.mode_0x0010_0x02=str_constant +hwmon_in.str_cons_0x0010_0x02=ucd90160 + +hwmon_in.mode_0x0010_0x03=constant +hwmon_in.int_cons_0x0010_0x03=1890 + +hwmon_in.mode_0x0010_0x05=constant +hwmon_in.int_cons_0x0010_0x05=1710 + +hwmon_in.mode_0x0011_0x00=config +hwmon_in.int_cons_0x0011_0x00=0 +hwmon_in.src_0x0011_0x00=file +hwmon_in.frmt_0x0011_0x00=buf +hwmon_in.fpath_0x0011_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0011_0x00=0 +hwmon_in.len_0x0011_0x00=8 +hwmon_in.bit_offset_0x0011_0x00= +hwmon_in.str_cons_0x0011_0x00=in1_input + +hwmon_in.mode_0x0011_0x01=str_constant +hwmon_in.str_cons_0x0011_0x01=BASE_VDD12V + +hwmon_in.mode_0x0011_0x02=str_constant +hwmon_in.str_cons_0x0011_0x02=ucd90160 + +hwmon_in.mode_0x0011_0x03=constant +hwmon_in.int_cons_0x0011_0x03=12600 + +hwmon_in.mode_0x0011_0x05=constant +hwmon_in.int_cons_0x0011_0x05=11400 + +hwmon_in.mode_0x0012_0x00=config +hwmon_in.int_cons_0x0012_0x00=0 +hwmon_in.src_0x0012_0x00=file +hwmon_in.frmt_0x0012_0x00=buf +hwmon_in.fpath_0x0012_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0012_0x00=0 +hwmon_in.len_0x0012_0x00=8 +hwmon_in.bit_offset_0x0012_0x00= +hwmon_in.str_cons_0x0012_0x00=in2_input + +hwmon_in.mode_0x0012_0x01=str_constant +hwmon_in.str_cons_0x0012_0x01=BASE_SW_VDD1.2V + +hwmon_in.mode_0x0012_0x02=str_constant +hwmon_in.str_cons_0x0012_0x02=ucd90160 + +hwmon_in.mode_0x0012_0x03=constant +hwmon_in.int_cons_0x0012_0x03=1260 + +hwmon_in.mode_0x0012_0x05=constant +hwmon_in.int_cons_0x0012_0x05=1140 + +hwmon_in.mode_0x0013_0x00=config +hwmon_in.int_cons_0x0013_0x00=0 +hwmon_in.src_0x0013_0x00=file +hwmon_in.frmt_0x0013_0x00=buf +hwmon_in.fpath_0x0013_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0013_0x00=0 +hwmon_in.len_0x0013_0x00=8 +hwmon_in.bit_offset_0x0013_0x00= +hwmon_in.str_cons_0x0013_0x00=in3_input + +hwmon_in.mode_0x0013_0x01=str_constant +hwmon_in.str_cons_0x0013_0x01=BASE_VDD2.5V + +hwmon_in.mode_0x0013_0x02=str_constant +hwmon_in.str_cons_0x0013_0x02=ucd90160 + +hwmon_in.mode_0x0013_0x03=constant +hwmon_in.int_cons_0x0013_0x03=2615 + +hwmon_in.mode_0x0013_0x05=constant +hwmon_in.int_cons_0x0013_0x05=2365 + +hwmon_in.mode_0x0014_0x00=config +hwmon_in.int_cons_0x0014_0x00=0 +hwmon_in.src_0x0014_0x00=file +hwmon_in.frmt_0x0014_0x00=buf +hwmon_in.fpath_0x0014_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0014_0x00=0 +hwmon_in.len_0x0014_0x00=8 +hwmon_in.bit_offset_0x0014_0x00= +hwmon_in.str_cons_0x0014_0x00=in4_input + +hwmon_in.mode_0x0014_0x01=str_constant +hwmon_in.str_cons_0x0014_0x01=BASE_VDD3.3V + +hwmon_in.mode_0x0014_0x02=str_constant +hwmon_in.str_cons_0x0014_0x02=ucd90160 + +hwmon_in.mode_0x0014_0x03=constant +hwmon_in.int_cons_0x0014_0x03=3444 + +hwmon_in.mode_0x0014_0x05=constant +hwmon_in.int_cons_0x0014_0x05=3116 + +hwmon_in.mode_0x0015_0x00=config +hwmon_in.int_cons_0x0015_0x00=0 +hwmon_in.src_0x0015_0x00=file +hwmon_in.frmt_0x0015_0x00=buf +hwmon_in.fpath_0x0015_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0015_0x00=0 +hwmon_in.len_0x0015_0x00=8 +hwmon_in.bit_offset_0x0015_0x00= +hwmon_in.str_cons_0x0015_0x00=in5_input + +hwmon_in.mode_0x0015_0x01=str_constant +hwmon_in.str_cons_0x0015_0x01=BASE_SSD_VDD3.3V + +hwmon_in.mode_0x0015_0x02=str_constant +hwmon_in.str_cons_0x0015_0x02=ucd90160 + +hwmon_in.mode_0x0015_0x03=constant +hwmon_in.int_cons_0x0015_0x03=3465 + +hwmon_in.mode_0x0015_0x05=constant +hwmon_in.int_cons_0x0015_0x05=3135 + +hwmon_in.mode_0x0016_0x00=config +hwmon_in.int_cons_0x0016_0x00=0 +hwmon_in.src_0x0016_0x00=file +hwmon_in.frmt_0x0016_0x00=buf +hwmon_in.fpath_0x0016_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_in.addr_0x0016_0x00=0 +hwmon_in.len_0x0016_0x00=8 +hwmon_in.bit_offset_0x0016_0x00= +hwmon_in.str_cons_0x0016_0x00=in3_input + +hwmon_in.mode_0x0016_0x01=str_constant +hwmon_in.str_cons_0x0016_0x01=CPU_VCCIN + +hwmon_in.mode_0x0016_0x02=str_constant +hwmon_in.str_cons_0x0016_0x02=tps53622 + +hwmon_in.mode_0x0016_0x03=constant +hwmon_in.int_cons_0x0016_0x03=1950 + +hwmon_in.mode_0x0016_0x05=constant +hwmon_in.int_cons_0x0016_0x05=1600 + +hwmon_in.mode_0x0017_0x00=config +hwmon_in.int_cons_0x0017_0x00=0 +hwmon_in.src_0x0017_0x00=file +hwmon_in.frmt_0x0017_0x00=buf +hwmon_in.fpath_0x0017_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_in.addr_0x0017_0x00=0 +hwmon_in.len_0x0017_0x00=8 +hwmon_in.bit_offset_0x0017_0x00= +hwmon_in.str_cons_0x0017_0x00=in4_input + +hwmon_in.mode_0x0017_0x01=str_constant +hwmon_in.str_cons_0x0017_0x01=CPU_P1V05 + +hwmon_in.mode_0x0017_0x02=str_constant +hwmon_in.str_cons_0x0017_0x02=tps53622 + +hwmon_in.mode_0x0017_0x03=constant +hwmon_in.int_cons_0x0017_0x03=1100 + +hwmon_in.mode_0x0017_0x05=constant +hwmon_in.int_cons_0x0017_0x05=1000 + +hwmon_in.mode_0x0018_0x00=config +hwmon_in.int_cons_0x0018_0x00=0 +hwmon_in.src_0x0018_0x00=file +hwmon_in.frmt_0x0018_0x00=buf +hwmon_in.fpath_0x0018_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_in.addr_0x0018_0x00=0 +hwmon_in.len_0x0018_0x00=8 +hwmon_in.bit_offset_0x0018_0x00= +hwmon_in.str_cons_0x0018_0x00=in3_input + +hwmon_in.mode_0x0018_0x01=str_constant +hwmon_in.str_cons_0x0018_0x01=CPU_P1V2_VDDQ + +hwmon_in.mode_0x0018_0x02=str_constant +hwmon_in.str_cons_0x0018_0x02=tps53622 + +hwmon_in.mode_0x0018_0x03=constant +hwmon_in.int_cons_0x0018_0x03=1260 + +hwmon_in.mode_0x0018_0x05=constant +hwmon_in.int_cons_0x0018_0x05=1160 + +hwmon_in.mode_0x0019_0x00=config +hwmon_in.int_cons_0x0019_0x00=3 +hwmon_in.src_0x0019_0x00=file +hwmon_in.frmt_0x0019_0x00=buf +hwmon_in.fpath_0x0019_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_in.addr_0x0019_0x00=0 +hwmon_in.len_0x0019_0x00=8 +hwmon_in.bit_offset_0x0019_0x00=0 +hwmon_in.str_cons_0x0019_0x00=in4_input +hwmon_in.int_extra1_0x0019_0x00=1124 + +hwmon_in.mode_0x0019_0x01=str_constant +hwmon_in.str_cons_0x0019_0x01=CPU_P2V5_VPP + +hwmon_in.mode_0x0019_0x02=str_constant +hwmon_in.str_cons_0x0019_0x02=tps53622 + +hwmon_in.mode_0x0019_0x03=constant +hwmon_in.int_cons_0x0019_0x03=2750 + +hwmon_in.mode_0x0019_0x05=constant +hwmon_in.int_cons_0x0019_0x05=2375 + +hwmon_in.mode_0x001a_0x00=config +hwmon_in.int_cons_0x001a_0x00=0 +hwmon_in.src_0x001a_0x00=file +hwmon_in.frmt_0x001a_0x00=buf +hwmon_in.fpath_0x001a_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001a_0x00=0 +hwmon_in.len_0x001a_0x00=8 +hwmon_in.bit_offset_0x001a_0x00= +hwmon_in.str_cons_0x001a_0x00=in1_input + +hwmon_in.mode_0x001a_0x01=str_constant +hwmon_in.str_cons_0x001a_0x01=CPU_P3V3_STBY + +hwmon_in.mode_0x001a_0x02=str_constant +hwmon_in.str_cons_0x001a_0x02=ina3221 + +hwmon_in.mode_0x001a_0x03=constant +hwmon_in.int_cons_0x001a_0x03=3465 + +hwmon_in.mode_0x001a_0x05=constant +hwmon_in.int_cons_0x001a_0x05=3135 + +hwmon_in.mode_0x001b_0x00=config +hwmon_in.int_cons_0x001b_0x00=0 +hwmon_in.src_0x001b_0x00=file +hwmon_in.frmt_0x001b_0x00=buf +hwmon_in.fpath_0x001b_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001b_0x00=0 +hwmon_in.len_0x001b_0x00=8 +hwmon_in.bit_offset_0x001b_0x00= +hwmon_in.str_cons_0x001b_0x00=in2_input + +hwmon_in.mode_0x001b_0x01=str_constant +hwmon_in.str_cons_0x001b_0x01=CPU_P5V_AUX_IN + +hwmon_in.mode_0x001b_0x02=str_constant +hwmon_in.str_cons_0x001b_0x02=ina3221 + +hwmon_in.mode_0x001b_0x03=constant +hwmon_in.int_cons_0x001b_0x03=5500 + +hwmon_in.mode_0x001b_0x05=constant +hwmon_in.int_cons_0x001b_0x05=4250 + +hwmon_in.mode_0x001c_0x00=config +hwmon_in.int_cons_0x001c_0x00=0 +hwmon_in.src_0x001c_0x00=file +hwmon_in.frmt_0x001c_0x00=buf +hwmon_in.fpath_0x001c_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001c_0x00=0 +hwmon_in.len_0x001c_0x00=8 +hwmon_in.bit_offset_0x001c_0x00= +hwmon_in.str_cons_0x001c_0x00=in3_input + +hwmon_in.mode_0x001c_0x01=str_constant +hwmon_in.str_cons_0x001c_0x01=CPU_P1V7_VCCSCFUSESUS_IN + +hwmon_in.mode_0x001c_0x02=str_constant +hwmon_in.str_cons_0x001c_0x02=ina3221 + +hwmon_in.mode_0x001c_0x03=constant +hwmon_in.int_cons_0x001c_0x03=1785 + +hwmon_in.mode_0x001c_0x05=constant +hwmon_in.int_cons_0x001c_0x05=1615 + +hwmon_in.mode_0x001d_0x00=config +hwmon_in.int_cons_0x001d_0x00=0 +hwmon_in.src_0x001d_0x00=file +hwmon_in.frmt_0x001d_0x00=buf +hwmon_in.fpath_0x001d_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001d_0x00=0 +hwmon_in.len_0x001d_0x00=8 +hwmon_in.bit_offset_0x001d_0x00= +hwmon_in.str_cons_0x001d_0x00=in1_input + +hwmon_in.mode_0x001d_0x01=str_constant +hwmon_in.str_cons_0x001d_0x01=UPORT_VDD1.0V_FPGA + +hwmon_in.mode_0x001d_0x02=str_constant +hwmon_in.str_cons_0x001d_0x02=ucd90160 + +hwmon_in.mode_0x001d_0x03=constant +hwmon_in.int_cons_0x001d_0x03=1061 + +hwmon_in.mode_0x001d_0x05=constant +hwmon_in.int_cons_0x001d_0x05=959 + +hwmon_in.mode_0x001e_0x00=config +hwmon_in.int_cons_0x001e_0x00=0 +hwmon_in.src_0x001e_0x00=file +hwmon_in.frmt_0x001e_0x00=buf +hwmon_in.fpath_0x001e_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001e_0x00=0 +hwmon_in.len_0x001e_0x00=8 +hwmon_in.bit_offset_0x001e_0x00= +hwmon_in.str_cons_0x001e_0x00=in2_input + +hwmon_in.mode_0x001e_0x01=str_constant +hwmon_in.str_cons_0x001e_0x01=UPORT_VDD1.8V_FPGA + +hwmon_in.mode_0x001e_0x02=str_constant +hwmon_in.str_cons_0x001e_0x02=ucd90160 + +hwmon_in.mode_0x001e_0x03=constant +hwmon_in.int_cons_0x001e_0x03=1901 + +hwmon_in.mode_0x001e_0x05=constant +hwmon_in.int_cons_0x001e_0x05=1719 + +hwmon_in.mode_0x001f_0x00=config +hwmon_in.int_cons_0x001f_0x00=0 +hwmon_in.src_0x001f_0x00=file +hwmon_in.frmt_0x001f_0x00=buf +hwmon_in.fpath_0x001f_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001f_0x00=0 +hwmon_in.len_0x001f_0x00=8 +hwmon_in.bit_offset_0x001f_0x00= +hwmon_in.str_cons_0x001f_0x00=in3_input + +hwmon_in.mode_0x001f_0x01=str_constant +hwmon_in.str_cons_0x001f_0x01=UPORT_VDD1.2V_FPGA + +hwmon_in.mode_0x001f_0x02=str_constant +hwmon_in.str_cons_0x001f_0x02=ucd90160 + +hwmon_in.mode_0x001f_0x03=constant +hwmon_in.int_cons_0x001f_0x03=1260 + +hwmon_in.mode_0x001f_0x05=constant +hwmon_in.int_cons_0x001f_0x05=1140 + +hwmon_in.mode_0x0020_0x00=config +hwmon_in.int_cons_0x0020_0x00=0 +hwmon_in.src_0x0020_0x00=file +hwmon_in.frmt_0x0020_0x00=buf +hwmon_in.fpath_0x0020_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0020_0x00=0 +hwmon_in.len_0x0020_0x00=8 +hwmon_in.bit_offset_0x0020_0x00= +hwmon_in.str_cons_0x0020_0x00=in4_input + +hwmon_in.mode_0x0020_0x01=str_constant +hwmon_in.str_cons_0x0020_0x01=UPORT_VDD3.3V + +hwmon_in.mode_0x0020_0x02=str_constant +hwmon_in.str_cons_0x0020_0x02=ucd90160 + +hwmon_in.mode_0x0020_0x03=constant +hwmon_in.int_cons_0x0020_0x03=3600 + +hwmon_in.mode_0x0020_0x05=constant +hwmon_in.int_cons_0x0020_0x05=3200 + +hwmon_in.mode_0x0021_0x00=config +hwmon_in.int_cons_0x0021_0x00=0 +hwmon_in.src_0x0021_0x00=file +hwmon_in.frmt_0x0021_0x00=buf +hwmon_in.fpath_0x0021_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0021_0x00=0 +hwmon_in.len_0x0021_0x00=8 +hwmon_in.bit_offset_0x0021_0x00= +hwmon_in.str_cons_0x0021_0x00=in5_input + +hwmon_in.mode_0x0021_0x01=str_constant +hwmon_in.str_cons_0x0021_0x01=UPORT_QSFP56_VDD3.3V_A + +hwmon_in.mode_0x0021_0x02=str_constant +hwmon_in.str_cons_0x0021_0x02=ucd90160 + +hwmon_in.mode_0x0021_0x03=constant +hwmon_in.int_cons_0x0021_0x03=3600 + +hwmon_in.mode_0x0021_0x05=constant +hwmon_in.int_cons_0x0021_0x05=3200 + +hwmon_in.mode_0x0022_0x00=config +hwmon_in.int_cons_0x0022_0x00=0 +hwmon_in.src_0x0022_0x00=file +hwmon_in.frmt_0x0022_0x00=buf +hwmon_in.fpath_0x0022_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0022_0x00=0 +hwmon_in.len_0x0022_0x00=8 +hwmon_in.bit_offset_0x0022_0x00= +hwmon_in.str_cons_0x0022_0x00=in6_input + +hwmon_in.mode_0x0022_0x01=str_constant +hwmon_in.str_cons_0x0022_0x01=UPORT_QSFP56_VDD3.3V_B + +hwmon_in.mode_0x0022_0x02=str_constant +hwmon_in.str_cons_0x0022_0x02=ucd90160 + +hwmon_in.mode_0x0022_0x03=constant +hwmon_in.int_cons_0x0022_0x03=3600 + +hwmon_in.mode_0x0022_0x05=constant +hwmon_in.int_cons_0x0022_0x05=3200 + +hwmon_in.mode_0x0023_0x00=config +hwmon_in.int_cons_0x0023_0x00=0 +hwmon_in.src_0x0023_0x00=file +hwmon_in.frmt_0x0023_0x00=buf +hwmon_in.fpath_0x0023_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0023_0x00=0 +hwmon_in.len_0x0023_0x00=8 +hwmon_in.bit_offset_0x0023_0x00= +hwmon_in.str_cons_0x0023_0x00=in7_input + +hwmon_in.mode_0x0023_0x01=str_constant +hwmon_in.str_cons_0x0023_0x01=UPORT_QSFP56_VDD3.3V_C + +hwmon_in.mode_0x0023_0x02=str_constant +hwmon_in.str_cons_0x0023_0x02=ucd90160 + +hwmon_in.mode_0x0023_0x03=constant +hwmon_in.int_cons_0x0023_0x03=3600 + +hwmon_in.mode_0x0023_0x05=constant +hwmon_in.int_cons_0x0023_0x05=3200 + +hwmon_in.mode_0x0024_0x00=config +hwmon_in.int_cons_0x0024_0x00=0 +hwmon_in.src_0x0024_0x00=file +hwmon_in.frmt_0x0024_0x00=buf +hwmon_in.fpath_0x0024_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0024_0x00=0 +hwmon_in.len_0x0024_0x00=8 +hwmon_in.bit_offset_0x0024_0x00= +hwmon_in.str_cons_0x0024_0x00=in8_input + +hwmon_in.mode_0x0024_0x01=str_constant +hwmon_in.str_cons_0x0024_0x01=UPORT_QSFP56_VDD3.3V_D + +hwmon_in.mode_0x0024_0x02=str_constant +hwmon_in.str_cons_0x0024_0x02=ucd90160 + +hwmon_in.mode_0x0024_0x03=constant +hwmon_in.int_cons_0x0024_0x03=3600 + +hwmon_in.mode_0x0024_0x05=constant +hwmon_in.int_cons_0x0024_0x05=3200 + +hwmon_in.mode_0x0025_0x00=config +hwmon_in.int_cons_0x0025_0x00=0 +hwmon_in.src_0x0025_0x00=file +hwmon_in.frmt_0x0025_0x00=buf +hwmon_in.fpath_0x0025_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0025_0x00=0 +hwmon_in.len_0x0025_0x00=8 +hwmon_in.bit_offset_0x0025_0x00= +hwmon_in.str_cons_0x0025_0x00=in9_input + +hwmon_in.mode_0x0025_0x01=str_constant +hwmon_in.str_cons_0x0025_0x01=UPORT_VDD3.3_MON + +hwmon_in.mode_0x0025_0x02=str_constant +hwmon_in.str_cons_0x0025_0x02=ucd90160 + +hwmon_in.mode_0x0025_0x03=constant +hwmon_in.int_cons_0x0025_0x03=3465 + +hwmon_in.mode_0x0025_0x05=constant +hwmon_in.int_cons_0x0025_0x05=3135 + +hwmon_in.mode_0x0026_0x00=config +hwmon_in.int_cons_0x0026_0x00=0 +hwmon_in.src_0x0026_0x00=file +hwmon_in.frmt_0x0026_0x00=buf +hwmon_in.fpath_0x0026_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0026_0x00=0 +hwmon_in.len_0x0026_0x00=8 +hwmon_in.bit_offset_0x0026_0x00= +hwmon_in.str_cons_0x0026_0x00=in10_input + +hwmon_in.mode_0x0026_0x01=str_constant +hwmon_in.str_cons_0x0026_0x01=UPORT_VDD12V + +hwmon_in.mode_0x0026_0x02=str_constant +hwmon_in.str_cons_0x0026_0x02=ucd90160 + +hwmon_in.mode_0x0026_0x03=constant +hwmon_in.int_cons_0x0026_0x03=12600 + +hwmon_in.mode_0x0026_0x05=constant +hwmon_in.int_cons_0x0026_0x05=11400 + +hwmon_in.mode_0x0027_0x00=config +hwmon_in.int_cons_0x0027_0x00=0 +hwmon_in.src_0x0027_0x00=file +hwmon_in.frmt_0x0027_0x00=buf +hwmon_in.fpath_0x0027_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0027_0x00=0 +hwmon_in.len_0x0027_0x00=8 +hwmon_in.bit_offset_0x0027_0x00= +hwmon_in.str_cons_0x0027_0x00=in1_input + +hwmon_in.mode_0x0027_0x01=str_constant +hwmon_in.str_cons_0x0027_0x01=DPORT_VDD1.0V_FPGA + +hwmon_in.mode_0x0027_0x02=str_constant +hwmon_in.str_cons_0x0027_0x02=ucd90160 + +hwmon_in.mode_0x0027_0x03=constant +hwmon_in.int_cons_0x0027_0x03=1061 + +hwmon_in.mode_0x0027_0x05=constant +hwmon_in.int_cons_0x0027_0x05=959 + +hwmon_in.mode_0x0028_0x00=config +hwmon_in.int_cons_0x0028_0x00=0 +hwmon_in.src_0x0028_0x00=file +hwmon_in.frmt_0x0028_0x00=buf +hwmon_in.fpath_0x0028_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0028_0x00=0 +hwmon_in.len_0x0028_0x00=8 +hwmon_in.bit_offset_0x0028_0x00= +hwmon_in.str_cons_0x0028_0x00=in2_input + +hwmon_in.mode_0x0028_0x01=str_constant +hwmon_in.str_cons_0x0028_0x01=DPORT_VDD1.8V_FPGA + +hwmon_in.mode_0x0028_0x02=str_constant +hwmon_in.str_cons_0x0028_0x02=ucd90160 + +hwmon_in.mode_0x0028_0x03=constant +hwmon_in.int_cons_0x0028_0x03=1901 + +hwmon_in.mode_0x0028_0x05=constant +hwmon_in.int_cons_0x0028_0x05=1719 + +hwmon_in.mode_0x0029_0x00=config +hwmon_in.int_cons_0x0029_0x00=0 +hwmon_in.src_0x0029_0x00=file +hwmon_in.frmt_0x0029_0x00=buf +hwmon_in.fpath_0x0029_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0029_0x00=0 +hwmon_in.len_0x0029_0x00=8 +hwmon_in.bit_offset_0x0029_0x00= +hwmon_in.str_cons_0x0029_0x00=in3_input + +hwmon_in.mode_0x0029_0x01=str_constant +hwmon_in.str_cons_0x0029_0x01=DPORT_VDD1.2V_FPGA + +hwmon_in.mode_0x0029_0x02=str_constant +hwmon_in.str_cons_0x0029_0x02=ucd90160 + +hwmon_in.mode_0x0029_0x03=constant +hwmon_in.int_cons_0x0029_0x03=1260 + +hwmon_in.mode_0x0029_0x05=constant +hwmon_in.int_cons_0x0029_0x05=1140 + +hwmon_in.mode_0x002a_0x00=config +hwmon_in.int_cons_0x002a_0x00=0 +hwmon_in.src_0x002a_0x00=file +hwmon_in.frmt_0x002a_0x00=buf +hwmon_in.fpath_0x002a_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002a_0x00=0 +hwmon_in.len_0x002a_0x00=8 +hwmon_in.bit_offset_0x002a_0x00= +hwmon_in.str_cons_0x002a_0x00=in4_input + +hwmon_in.mode_0x002a_0x01=str_constant +hwmon_in.str_cons_0x002a_0x01=DPORT_VDD3.3V + +hwmon_in.mode_0x002a_0x02=str_constant +hwmon_in.str_cons_0x002a_0x02=ucd90160 + +hwmon_in.mode_0x002a_0x03=constant +hwmon_in.int_cons_0x002a_0x03=3600 + +hwmon_in.mode_0x002a_0x05=constant +hwmon_in.int_cons_0x002a_0x05=3200 + +hwmon_in.mode_0x002b_0x00=config +hwmon_in.int_cons_0x002b_0x00=0 +hwmon_in.src_0x002b_0x00=file +hwmon_in.frmt_0x002b_0x00=buf +hwmon_in.fpath_0x002b_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002b_0x00=0 +hwmon_in.len_0x002b_0x00=8 +hwmon_in.bit_offset_0x002b_0x00= +hwmon_in.str_cons_0x002b_0x00=in5_input + +hwmon_in.mode_0x002b_0x01=str_constant +hwmon_in.str_cons_0x002b_0x01=DPORT_QSFP56_VDD3.3V_A + +hwmon_in.mode_0x002b_0x02=str_constant +hwmon_in.str_cons_0x002b_0x02=ucd90160 + +hwmon_in.mode_0x002b_0x03=constant +hwmon_in.int_cons_0x002b_0x03=3600 + +hwmon_in.mode_0x002b_0x05=constant +hwmon_in.int_cons_0x002b_0x05=3200 + +hwmon_in.mode_0x002c_0x00=config +hwmon_in.int_cons_0x002c_0x00=0 +hwmon_in.src_0x002c_0x00=file +hwmon_in.frmt_0x002c_0x00=buf +hwmon_in.fpath_0x002c_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002c_0x00=0 +hwmon_in.len_0x002c_0x00=8 +hwmon_in.bit_offset_0x002c_0x00= +hwmon_in.str_cons_0x002c_0x00=in6_input + +hwmon_in.mode_0x002c_0x01=str_constant +hwmon_in.str_cons_0x002c_0x01=DPORT_QSFP56_VDD3.3V_B + +hwmon_in.mode_0x002c_0x02=str_constant +hwmon_in.str_cons_0x002c_0x02=ucd90160 + +hwmon_in.mode_0x002c_0x03=constant +hwmon_in.int_cons_0x002c_0x03=3600 + +hwmon_in.mode_0x002c_0x05=constant +hwmon_in.int_cons_0x002c_0x05=3200 + +hwmon_in.mode_0x002d_0x00=config +hwmon_in.int_cons_0x002d_0x00=0 +hwmon_in.src_0x002d_0x00=file +hwmon_in.frmt_0x002d_0x00=buf +hwmon_in.fpath_0x002d_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002d_0x00=0 +hwmon_in.len_0x002d_0x00=8 +hwmon_in.bit_offset_0x002d_0x00= +hwmon_in.str_cons_0x002d_0x00=in7_input + +hwmon_in.mode_0x002d_0x01=str_constant +hwmon_in.str_cons_0x002d_0x01=DPORT_QSFP56_VDD3.3V_C + +hwmon_in.mode_0x002d_0x02=str_constant +hwmon_in.str_cons_0x002d_0x02=ucd90160 + +hwmon_in.mode_0x002d_0x03=constant +hwmon_in.int_cons_0x002d_0x03=3600 + +hwmon_in.mode_0x002d_0x05=constant +hwmon_in.int_cons_0x002d_0x05=3200 + +hwmon_in.mode_0x002e_0x00=config +hwmon_in.int_cons_0x002e_0x00=0 +hwmon_in.src_0x002e_0x00=file +hwmon_in.frmt_0x002e_0x00=buf +hwmon_in.fpath_0x002e_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002e_0x00=0 +hwmon_in.len_0x002e_0x00=8 +hwmon_in.bit_offset_0x002e_0x00= +hwmon_in.str_cons_0x002e_0x00=in8_input + +hwmon_in.mode_0x002e_0x01=str_constant +hwmon_in.str_cons_0x002e_0x01=DPORT_QSFP56_VDD3.3V_D + +hwmon_in.mode_0x002e_0x02=str_constant +hwmon_in.str_cons_0x002e_0x02=ucd90160 + +hwmon_in.mode_0x002e_0x03=constant +hwmon_in.int_cons_0x002e_0x03=3600 + +hwmon_in.mode_0x002e_0x05=constant +hwmon_in.int_cons_0x002e_0x05=3200 + +hwmon_in.mode_0x002f_0x00=config +hwmon_in.int_cons_0x002f_0x00=0 +hwmon_in.src_0x002f_0x00=file +hwmon_in.frmt_0x002f_0x00=buf +hwmon_in.fpath_0x002f_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002f_0x00=0 +hwmon_in.len_0x002f_0x00=8 +hwmon_in.bit_offset_0x002f_0x00= +hwmon_in.str_cons_0x002f_0x00=in9_input + +hwmon_in.mode_0x002f_0x01=str_constant +hwmon_in.str_cons_0x002f_0x01=DPORT_VDD3.3_MON + +hwmon_in.mode_0x002f_0x02=str_constant +hwmon_in.str_cons_0x002f_0x02=ucd90160 + +hwmon_in.mode_0x002f_0x03=constant +hwmon_in.int_cons_0x002f_0x03=3465 + +hwmon_in.mode_0x002f_0x05=constant +hwmon_in.int_cons_0x002f_0x05=3135 + +hwmon_in.mode_0x0030_0x00=config +hwmon_in.int_cons_0x0030_0x00=0 +hwmon_in.src_0x0030_0x00=file +hwmon_in.frmt_0x0030_0x00=buf +hwmon_in.fpath_0x0030_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0030_0x00=0 +hwmon_in.len_0x0030_0x00=8 +hwmon_in.bit_offset_0x0030_0x00= +hwmon_in.str_cons_0x0030_0x00=in10_input + +hwmon_in.mode_0x0030_0x01=str_constant +hwmon_in.str_cons_0x0030_0x01=DPORT_VDD12V + +hwmon_in.mode_0x0030_0x02=str_constant +hwmon_in.str_cons_0x0030_0x02=ucd90160 + +hwmon_in.mode_0x0030_0x03=constant +hwmon_in.int_cons_0x0030_0x03=12600 + +hwmon_in.mode_0x0030_0x05=constant +hwmon_in.int_cons_0x0030_0x05=11400 + + +# MAC_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x0031_0x00=config +hwmon_in.int_cons_0x0031_0x00=0 +hwmon_in.src_0x0031_0x00=cpld +hwmon_in.frmt_0x0031_0x00=num_bytes +hwmon_in.addr_0x0031_0x00=0x00050030 +hwmon_in.len_0x0031_0x00=2 +hwmon_in.int_extra1_0x0031_0x00=0x00050030 +hwmon_in.int_extra2_0x0031_0x00=2000 + +hwmon_in.mode_0x0031_0x01=str_constant +hwmon_in.str_cons_0x0031_0x01=MAC_QSFPDD_VDD3.3V_A + +hwmon_in.mode_0x0031_0x02=str_constant +hwmon_in.str_cons_0x0031_0x02=cpld + +hwmon_in.mode_0x0031_0x03=constant +hwmon_in.int_cons_0x0031_0x03=3600 + +hwmon_in.mode_0x0031_0x05=constant +hwmon_in.int_cons_0x0031_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0032_0x00=config +hwmon_in.int_cons_0x0032_0x00=0 +hwmon_in.src_0x0032_0x00=cpld +hwmon_in.frmt_0x0032_0x00=num_bytes +hwmon_in.addr_0x0032_0x00=0x00050032 +hwmon_in.len_0x0032_0x00=2 +hwmon_in.int_extra1_0x0032_0x00=0x00050032 +hwmon_in.int_extra2_0x0032_0x00=2000 + +hwmon_in.mode_0x0032_0x01=str_constant +hwmon_in.str_cons_0x0032_0x01=MAC_QSFPDD_VDD3.3V_B + +hwmon_in.mode_0x0032_0x02=str_constant +hwmon_in.str_cons_0x0032_0x02=cpld + +hwmon_in.mode_0x0032_0x03=constant +hwmon_in.int_cons_0x0032_0x03=3600 + +hwmon_in.mode_0x0032_0x05=constant +hwmon_in.int_cons_0x0032_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_C +hwmon_in.mode_0x0033_0x00=config +hwmon_in.int_cons_0x0033_0x00=0 +hwmon_in.src_0x0033_0x00=cpld +hwmon_in.frmt_0x0033_0x00=num_bytes +hwmon_in.addr_0x0033_0x00=0x00050034 +hwmon_in.len_0x0033_0x00=2 +hwmon_in.int_extra1_0x0033_0x00=0x00050034 +hwmon_in.int_extra2_0x0033_0x00=2000 + +hwmon_in.mode_0x0033_0x01=str_constant +hwmon_in.str_cons_0x0033_0x01=MAC_QSFPDD_VDD3.3V_C + +hwmon_in.mode_0x0033_0x02=str_constant +hwmon_in.str_cons_0x0033_0x02=cpld + +hwmon_in.mode_0x0033_0x03=constant +hwmon_in.int_cons_0x0033_0x03=3600 + +hwmon_in.mode_0x0033_0x05=constant +hwmon_in.int_cons_0x0033_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_D +hwmon_in.mode_0x0034_0x00=config +hwmon_in.int_cons_0x0034_0x00=0 +hwmon_in.src_0x0034_0x00=cpld +hwmon_in.frmt_0x0034_0x00=num_bytes +hwmon_in.addr_0x0034_0x00=0x00050036 +hwmon_in.len_0x0034_0x00=2 +hwmon_in.int_extra1_0x0034_0x00=0x00050036 +hwmon_in.int_extra2_0x0034_0x00=2000 + +hwmon_in.mode_0x0034_0x01=str_constant +hwmon_in.str_cons_0x0034_0x01=MAC_QSFPDD_VDD3.3V_D + +hwmon_in.mode_0x0034_0x02=str_constant +hwmon_in.str_cons_0x0034_0x02=cpld + +hwmon_in.mode_0x0034_0x03=constant +hwmon_in.int_cons_0x0034_0x03=3600 + +hwmon_in.mode_0x0034_0x05=constant +hwmon_in.int_cons_0x0034_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_E +hwmon_in.mode_0x0035_0x00=config +hwmon_in.int_cons_0x0035_0x00=0 +hwmon_in.src_0x0035_0x00=cpld +hwmon_in.frmt_0x0035_0x00=num_bytes +hwmon_in.addr_0x0035_0x00=0x00050038 +hwmon_in.len_0x0035_0x00=2 +hwmon_in.int_extra1_0x0035_0x00=0x00050038 +hwmon_in.int_extra2_0x0035_0x00=2000 + +hwmon_in.mode_0x0035_0x01=str_constant +hwmon_in.str_cons_0x0035_0x01=MAC_QSFPDD_VDD3.3V_E + +hwmon_in.mode_0x0035_0x02=str_constant +hwmon_in.str_cons_0x0035_0x02=cpld + +hwmon_in.mode_0x0035_0x03=constant +hwmon_in.int_cons_0x0035_0x03=3600 + +hwmon_in.mode_0x0035_0x05=constant +hwmon_in.int_cons_0x0035_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_F +hwmon_in.mode_0x0036_0x00=config +hwmon_in.int_cons_0x0036_0x00=0 +hwmon_in.src_0x0036_0x00=cpld +hwmon_in.frmt_0x0036_0x00=num_bytes +hwmon_in.addr_0x0036_0x00=0x0005003a +hwmon_in.len_0x0036_0x00=2 +hwmon_in.int_extra1_0x0036_0x00=0x0005003a +hwmon_in.int_extra2_0x0036_0x00=2000 + +hwmon_in.mode_0x0036_0x01=str_constant +hwmon_in.str_cons_0x0036_0x01=MAC_QSFPDD_VDD3.3V_F + +hwmon_in.mode_0x0036_0x02=str_constant +hwmon_in.str_cons_0x0036_0x02=cpld + +hwmon_in.mode_0x0036_0x03=constant +hwmon_in.int_cons_0x0036_0x03=3600 + +hwmon_in.mode_0x0036_0x05=constant +hwmon_in.int_cons_0x0036_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_G +hwmon_in.mode_0x0037_0x00=config +hwmon_in.int_cons_0x0037_0x00=0 +hwmon_in.src_0x0037_0x00=cpld +hwmon_in.frmt_0x0037_0x00=num_bytes +hwmon_in.addr_0x0037_0x00=0x0005003c +hwmon_in.len_0x0037_0x00=2 +hwmon_in.int_extra1_0x0037_0x00=0x0005003c +hwmon_in.int_extra2_0x0037_0x00=2000 + +hwmon_in.mode_0x0037_0x01=str_constant +hwmon_in.str_cons_0x0037_0x01=MAC_QSFPDD_VDD3.3V_G + +hwmon_in.mode_0x0037_0x02=str_constant +hwmon_in.str_cons_0x0037_0x02=cpld + +hwmon_in.mode_0x0037_0x03=constant +hwmon_in.int_cons_0x0037_0x03=3600 + +hwmon_in.mode_0x0037_0x05=constant +hwmon_in.int_cons_0x0037_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_H +hwmon_in.mode_0x0038_0x00=config +hwmon_in.int_cons_0x0038_0x00=0 +hwmon_in.src_0x0038_0x00=cpld +hwmon_in.frmt_0x0038_0x00=num_bytes +hwmon_in.addr_0x0038_0x00=0x0005003e +hwmon_in.len_0x0038_0x00=2 +hwmon_in.int_extra1_0x0038_0x00=0x0005003e +hwmon_in.int_extra2_0x0038_0x00=2000 + +hwmon_in.mode_0x0038_0x01=str_constant +hwmon_in.str_cons_0x0038_0x01=MAC_QSFPDD_VDD3.3V_H + +hwmon_in.mode_0x0038_0x02=str_constant +hwmon_in.str_cons_0x0038_0x02=cpld + +hwmon_in.mode_0x0038_0x03=constant +hwmon_in.int_cons_0x0038_0x03=3600 + +hwmon_in.mode_0x0038_0x05=constant +hwmon_in.int_cons_0x0038_0x05=3200 + + +# curr1 +hwmon_curr.mode_0x0001_0x00=config +hwmon_curr.int_cons_0x0001_0x00=0 +hwmon_curr.src_0x0001_0x00=file +hwmon_curr.frmt_0x0001_0x00=buf +hwmon_curr.fpath_0x0001_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_curr.addr_0x0001_0x00=0 +hwmon_curr.len_0x0001_0x00=8 +hwmon_curr.bit_offset_0x0001_0x00= +hwmon_curr.str_cons_0x0001_0x00=curr1_input + +hwmon_curr.mode_0x0001_0x01=str_constant +hwmon_curr.str_cons_0x0001_0x01=CPU_VCCIN_C + +hwmon_curr.mode_0x0001_0x02=str_constant +hwmon_curr.str_cons_0x0001_0x02=tps53622 + +hwmon_curr.mode_0x0001_0x03=constant +hwmon_curr.int_cons_0x0001_0x03=47300 + +hwmon_curr.mode_0x0001_0x05=constant +hwmon_curr.int_cons_0x0001_0x05=0 + +# curr2 +hwmon_curr.mode_0x0002_0x00=config +hwmon_curr.int_cons_0x0002_0x00=0 +hwmon_curr.src_0x0002_0x00=file +hwmon_curr.frmt_0x0002_0x00=buf +hwmon_curr.fpath_0x0002_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_curr.addr_0x0002_0x00=0 +hwmon_curr.len_0x0002_0x00=8 +hwmon_curr.bit_offset_0x0002_0x00= +hwmon_curr.str_cons_0x0002_0x00=curr2_input + +hwmon_curr.mode_0x0002_0x01=str_constant +hwmon_curr.str_cons_0x0002_0x01=CPU_P1V05_C + +hwmon_curr.mode_0x0002_0x02=str_constant +hwmon_curr.str_cons_0x0002_0x02=tps53622 + +hwmon_curr.mode_0x0002_0x03=constant +hwmon_curr.int_cons_0x0002_0x03=15400 + +hwmon_curr.mode_0x0002_0x05=constant +hwmon_curr.int_cons_0x0002_0x05=0 + +# curr3 +hwmon_curr.mode_0x0003_0x00=config +hwmon_curr.int_cons_0x0003_0x00=0 +hwmon_curr.src_0x0003_0x00=file +hwmon_curr.frmt_0x0003_0x00=buf +hwmon_curr.fpath_0x0003_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_curr.addr_0x0003_0x00=0 +hwmon_curr.len_0x0003_0x00=8 +hwmon_curr.bit_offset_0x0003_0x00= +hwmon_curr.str_cons_0x0003_0x00=curr1_input + +hwmon_curr.mode_0x0003_0x01=str_constant +hwmon_curr.str_cons_0x0003_0x01=CPU_P1V2_VDDQ_C + +hwmon_curr.mode_0x0003_0x02=str_constant +hwmon_curr.str_cons_0x0003_0x02=tps53622 + +hwmon_curr.mode_0x0003_0x03=constant +hwmon_curr.int_cons_0x0003_0x03=9900 + +hwmon_curr.mode_0x0003_0x05=constant +hwmon_curr.int_cons_0x0003_0x05=0 + +# curr4 +hwmon_curr.mode_0x0004_0x00=config +hwmon_curr.int_cons_0x0004_0x00=0 +hwmon_curr.src_0x0004_0x00=file +hwmon_curr.frmt_0x0004_0x00=buf +hwmon_curr.fpath_0x0004_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_curr.addr_0x0004_0x00=0 +hwmon_curr.len_0x0004_0x00=8 +hwmon_curr.bit_offset_0x0004_0x00= +hwmon_curr.str_cons_0x0004_0x00=curr2_input + +hwmon_curr.mode_0x0004_0x01=str_constant +hwmon_curr.str_cons_0x0004_0x01=CPU_P2V5_VPP_C + +hwmon_curr.mode_0x0004_0x02=str_constant +hwmon_curr.str_cons_0x0004_0x02=tps53622 + +hwmon_curr.mode_0x0004_0x03=constant +hwmon_curr.int_cons_0x0004_0x03=2200 + +hwmon_curr.mode_0x0004_0x05=constant +hwmon_curr.int_cons_0x0004_0x05=0 + +# curr5 +hwmon_curr.mode_0x0005_0x00=config +hwmon_curr.int_cons_0x0005_0x00=0 +hwmon_curr.src_0x0005_0x00=file +hwmon_curr.frmt_0x0005_0x00=buf +hwmon_curr.fpath_0x0005_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0005_0x00=0 +hwmon_curr.len_0x0005_0x00=8 +hwmon_curr.bit_offset_0x0005_0x00= +hwmon_curr.str_cons_0x0005_0x00=curr1_input + +hwmon_curr.mode_0x0005_0x01=str_constant +hwmon_curr.str_cons_0x0005_0x01=CPU_P3V3_STBY_C + +hwmon_curr.mode_0x0005_0x02=str_constant +hwmon_curr.str_cons_0x0005_0x02=ina3221 + +hwmon_curr.mode_0x0005_0x03=constant +hwmon_curr.int_cons_0x0005_0x03=4686 + +hwmon_curr.mode_0x0005_0x05=constant +hwmon_curr.int_cons_0x0005_0x05=0 + +# curr6 +hwmon_curr.mode_0x0006_0x00=config +hwmon_curr.int_cons_0x0006_0x00=0 +hwmon_curr.src_0x0006_0x00=file +hwmon_curr.frmt_0x0006_0x00=buf +hwmon_curr.fpath_0x0006_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0006_0x00=0 +hwmon_curr.len_0x0006_0x00=8 +hwmon_curr.bit_offset_0x0006_0x00= +hwmon_curr.str_cons_0x0006_0x00=curr2_input + +hwmon_curr.mode_0x0006_0x01=str_constant +hwmon_curr.str_cons_0x0006_0x01=CPU_P5V_AUX_IN_C + +hwmon_curr.mode_0x0006_0x02=str_constant +hwmon_curr.str_cons_0x0006_0x02=ina3221 + +hwmon_curr.mode_0x0006_0x03=constant +hwmon_curr.int_cons_0x0006_0x03=2200 + +hwmon_curr.mode_0x0006_0x05=constant +hwmon_curr.int_cons_0x0006_0x05=0 + +# curr7 +hwmon_curr.mode_0x0007_0x00=config +hwmon_curr.int_cons_0x0007_0x00=0 +hwmon_curr.src_0x0007_0x00=file +hwmon_curr.frmt_0x0007_0x00=buf +hwmon_curr.fpath_0x0007_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0007_0x00=0 +hwmon_curr.len_0x0007_0x00=8 +hwmon_curr.bit_offset_0x0007_0x00= +hwmon_curr.str_cons_0x0007_0x00=curr3_input + +hwmon_curr.mode_0x0007_0x01=str_constant +hwmon_curr.str_cons_0x0007_0x01=CPU_P1V7_VCCSCFUSESUS_IN_C + +hwmon_curr.mode_0x0007_0x02=str_constant +hwmon_curr.str_cons_0x0007_0x02=ina3221 + +hwmon_curr.mode_0x0007_0x03=constant +hwmon_curr.int_cons_0x0007_0x03=2200 + +hwmon_curr.mode_0x0007_0x05=constant +hwmon_curr.int_cons_0x0007_0x05=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SFF.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SFF.cfg new file mode 100755 index 000000000000..fa3f2e60364d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-SFF.cfg @@ -0,0 +1,4233 @@ +# sff number +dev_num_3_0=128 + +eeprom_size_3_1=0x8180 +eeprom_size_3_2=0x8180 +eeprom_size_3_3=0x8180 +eeprom_size_3_4=0x8180 +eeprom_size_3_5=0x8180 +eeprom_size_3_6=0x8180 +eeprom_size_3_7=0x8180 +eeprom_size_3_8=0x8180 +eeprom_size_3_9=0x8180 +eeprom_size_3_10=0x8180 +eeprom_size_3_11=0x8180 +eeprom_size_3_12=0x8180 +eeprom_size_3_13=0x8180 +eeprom_size_3_14=0x8180 +eeprom_size_3_15=0x8180 +eeprom_size_3_16=0x8180 +eeprom_size_3_17=0x8180 +eeprom_size_3_18=0x8180 +eeprom_size_3_19=0x8180 +eeprom_size_3_20=0x8180 +eeprom_size_3_21=0x8180 +eeprom_size_3_22=0x8180 +eeprom_size_3_23=0x8180 +eeprom_size_3_24=0x8180 +eeprom_size_3_25=0x8180 +eeprom_size_3_26=0x8180 +eeprom_size_3_27=0x8180 +eeprom_size_3_28=0x8180 +eeprom_size_3_29=0x8180 +eeprom_size_3_30=0x8180 +eeprom_size_3_31=0x8180 +eeprom_size_3_32=0x8180 +eeprom_size_3_33=0x8180 +eeprom_size_3_34=0x8180 +eeprom_size_3_35=0x8180 +eeprom_size_3_36=0x8180 +eeprom_size_3_37=0x8180 +eeprom_size_3_38=0x8180 +eeprom_size_3_39=0x8180 +eeprom_size_3_40=0x8180 +eeprom_size_3_41=0x8180 +eeprom_size_3_42=0x8180 +eeprom_size_3_43=0x8180 +eeprom_size_3_44=0x8180 +eeprom_size_3_45=0x8180 +eeprom_size_3_46=0x8180 +eeprom_size_3_47=0x8180 +eeprom_size_3_48=0x8180 +eeprom_size_3_49=0x8180 +eeprom_size_3_50=0x8180 +eeprom_size_3_51=0x8180 +eeprom_size_3_52=0x8180 +eeprom_size_3_53=0x8180 +eeprom_size_3_54=0x8180 +eeprom_size_3_55=0x8180 +eeprom_size_3_56=0x8180 +eeprom_size_3_57=0x8180 +eeprom_size_3_58=0x8180 +eeprom_size_3_59=0x8180 +eeprom_size_3_60=0x8180 +eeprom_size_3_61=0x8180 +eeprom_size_3_62=0x8180 +eeprom_size_3_63=0x8180 +eeprom_size_3_64=0x8180 +eeprom_size_3_65=0x8180 +eeprom_size_3_66=0x8180 +eeprom_size_3_67=0x8180 +eeprom_size_3_68=0x8180 +eeprom_size_3_69=0x8180 +eeprom_size_3_70=0x8180 +eeprom_size_3_71=0x8180 +eeprom_size_3_72=0x8180 +eeprom_size_3_73=0x8180 +eeprom_size_3_74=0x8180 +eeprom_size_3_75=0x8180 +eeprom_size_3_76=0x8180 +eeprom_size_3_77=0x8180 +eeprom_size_3_78=0x8180 +eeprom_size_3_79=0x8180 +eeprom_size_3_80=0x8180 +eeprom_size_3_81=0x8180 +eeprom_size_3_82=0x8180 +eeprom_size_3_83=0x8180 +eeprom_size_3_84=0x8180 +eeprom_size_3_85=0x8180 +eeprom_size_3_86=0x8180 +eeprom_size_3_87=0x8180 +eeprom_size_3_88=0x8180 +eeprom_size_3_89=0x8180 +eeprom_size_3_90=0x8180 +eeprom_size_3_91=0x8180 +eeprom_size_3_92=0x8180 +eeprom_size_3_93=0x8180 +eeprom_size_3_94=0x8180 +eeprom_size_3_95=0x8180 +eeprom_size_3_96=0x8180 +eeprom_size_3_97=0x8180 +eeprom_size_3_98=0x8180 +eeprom_size_3_99=0x8180 +eeprom_size_3_100=0x8180 +eeprom_size_3_101=0x8180 +eeprom_size_3_102=0x8180 +eeprom_size_3_103=0x8180 +eeprom_size_3_104=0x8180 +eeprom_size_3_105=0x8180 +eeprom_size_3_106=0x8180 +eeprom_size_3_107=0x8180 +eeprom_size_3_108=0x8180 +eeprom_size_3_109=0x8180 +eeprom_size_3_110=0x8180 +eeprom_size_3_111=0x8180 +eeprom_size_3_112=0x8180 +eeprom_size_3_113=0x8180 +eeprom_size_3_114=0x8180 +eeprom_size_3_115=0x8180 +eeprom_size_3_116=0x8180 +eeprom_size_3_117=0x8180 +eeprom_size_3_118=0x8180 +eeprom_size_3_119=0x8180 +eeprom_size_3_120=0x8180 +eeprom_size_3_121=0x8180 +eeprom_size_3_122=0x8180 +eeprom_size_3_123=0x8180 +eeprom_size_3_124=0x8180 +eeprom_size_3_125=0x8180 +eeprom_size_3_126=0x8180 +eeprom_size_3_127=0x8180 +eeprom_size_3_128=0x8180 + + +eeprom_path_3_1=/sys/bus/i2c/devices/124-0050/eeprom +eeprom_path_3_2=/sys/bus/i2c/devices/125-0050/eeprom +eeprom_path_3_3=/sys/bus/i2c/devices/126-0050/eeprom +eeprom_path_3_4=/sys/bus/i2c/devices/127-0050/eeprom +eeprom_path_3_5=/sys/bus/i2c/devices/128-0050/eeprom +eeprom_path_3_6=/sys/bus/i2c/devices/129-0050/eeprom +eeprom_path_3_7=/sys/bus/i2c/devices/130-0050/eeprom +eeprom_path_3_8=/sys/bus/i2c/devices/131-0050/eeprom +eeprom_path_3_9=/sys/bus/i2c/devices/132-0050/eeprom +eeprom_path_3_10=/sys/bus/i2c/devices/133-0050/eeprom +eeprom_path_3_11=/sys/bus/i2c/devices/134-0050/eeprom +eeprom_path_3_12=/sys/bus/i2c/devices/135-0050/eeprom +eeprom_path_3_13=/sys/bus/i2c/devices/136-0050/eeprom +eeprom_path_3_14=/sys/bus/i2c/devices/137-0050/eeprom +eeprom_path_3_15=/sys/bus/i2c/devices/138-0050/eeprom +eeprom_path_3_16=/sys/bus/i2c/devices/139-0050/eeprom +eeprom_path_3_17=/sys/bus/i2c/devices/140-0050/eeprom +eeprom_path_3_18=/sys/bus/i2c/devices/141-0050/eeprom +eeprom_path_3_19=/sys/bus/i2c/devices/142-0050/eeprom +eeprom_path_3_20=/sys/bus/i2c/devices/143-0050/eeprom +eeprom_path_3_21=/sys/bus/i2c/devices/144-0050/eeprom +eeprom_path_3_22=/sys/bus/i2c/devices/145-0050/eeprom +eeprom_path_3_23=/sys/bus/i2c/devices/146-0050/eeprom +eeprom_path_3_24=/sys/bus/i2c/devices/147-0050/eeprom +eeprom_path_3_25=/sys/bus/i2c/devices/148-0050/eeprom +eeprom_path_3_26=/sys/bus/i2c/devices/149-0050/eeprom +eeprom_path_3_27=/sys/bus/i2c/devices/150-0050/eeprom +eeprom_path_3_28=/sys/bus/i2c/devices/151-0050/eeprom +eeprom_path_3_29=/sys/bus/i2c/devices/152-0050/eeprom +eeprom_path_3_30=/sys/bus/i2c/devices/153-0050/eeprom +eeprom_path_3_31=/sys/bus/i2c/devices/154-0050/eeprom +eeprom_path_3_32=/sys/bus/i2c/devices/155-0050/eeprom +eeprom_path_3_33=/sys/bus/i2c/devices/156-0050/eeprom +eeprom_path_3_34=/sys/bus/i2c/devices/157-0050/eeprom +eeprom_path_3_35=/sys/bus/i2c/devices/158-0050/eeprom +eeprom_path_3_36=/sys/bus/i2c/devices/159-0050/eeprom +eeprom_path_3_37=/sys/bus/i2c/devices/160-0050/eeprom +eeprom_path_3_38=/sys/bus/i2c/devices/161-0050/eeprom +eeprom_path_3_39=/sys/bus/i2c/devices/162-0050/eeprom +eeprom_path_3_40=/sys/bus/i2c/devices/163-0050/eeprom +eeprom_path_3_41=/sys/bus/i2c/devices/164-0050/eeprom +eeprom_path_3_42=/sys/bus/i2c/devices/165-0050/eeprom +eeprom_path_3_43=/sys/bus/i2c/devices/166-0050/eeprom +eeprom_path_3_44=/sys/bus/i2c/devices/167-0050/eeprom +eeprom_path_3_45=/sys/bus/i2c/devices/168-0050/eeprom +eeprom_path_3_46=/sys/bus/i2c/devices/169-0050/eeprom +eeprom_path_3_47=/sys/bus/i2c/devices/170-0050/eeprom +eeprom_path_3_48=/sys/bus/i2c/devices/171-0050/eeprom +eeprom_path_3_49=/sys/bus/i2c/devices/172-0050/eeprom +eeprom_path_3_50=/sys/bus/i2c/devices/173-0050/eeprom +eeprom_path_3_51=/sys/bus/i2c/devices/174-0050/eeprom +eeprom_path_3_52=/sys/bus/i2c/devices/175-0050/eeprom +eeprom_path_3_53=/sys/bus/i2c/devices/176-0050/eeprom +eeprom_path_3_54=/sys/bus/i2c/devices/177-0050/eeprom +eeprom_path_3_55=/sys/bus/i2c/devices/178-0050/eeprom +eeprom_path_3_56=/sys/bus/i2c/devices/179-0050/eeprom +eeprom_path_3_57=/sys/bus/i2c/devices/180-0050/eeprom +eeprom_path_3_58=/sys/bus/i2c/devices/181-0050/eeprom +eeprom_path_3_59=/sys/bus/i2c/devices/182-0050/eeprom +eeprom_path_3_60=/sys/bus/i2c/devices/183-0050/eeprom +eeprom_path_3_61=/sys/bus/i2c/devices/184-0050/eeprom +eeprom_path_3_62=/sys/bus/i2c/devices/185-0050/eeprom +eeprom_path_3_63=/sys/bus/i2c/devices/186-0050/eeprom +eeprom_path_3_64=/sys/bus/i2c/devices/187-0050/eeprom +eeprom_path_3_65=/sys/bus/i2c/devices/188-0050/eeprom +eeprom_path_3_66=/sys/bus/i2c/devices/189-0050/eeprom +eeprom_path_3_67=/sys/bus/i2c/devices/190-0050/eeprom +eeprom_path_3_68=/sys/bus/i2c/devices/191-0050/eeprom +eeprom_path_3_69=/sys/bus/i2c/devices/192-0050/eeprom +eeprom_path_3_70=/sys/bus/i2c/devices/193-0050/eeprom +eeprom_path_3_71=/sys/bus/i2c/devices/194-0050/eeprom +eeprom_path_3_72=/sys/bus/i2c/devices/195-0050/eeprom +eeprom_path_3_73=/sys/bus/i2c/devices/196-0050/eeprom +eeprom_path_3_74=/sys/bus/i2c/devices/197-0050/eeprom +eeprom_path_3_75=/sys/bus/i2c/devices/198-0050/eeprom +eeprom_path_3_76=/sys/bus/i2c/devices/199-0050/eeprom +eeprom_path_3_77=/sys/bus/i2c/devices/200-0050/eeprom +eeprom_path_3_78=/sys/bus/i2c/devices/201-0050/eeprom +eeprom_path_3_79=/sys/bus/i2c/devices/202-0050/eeprom +eeprom_path_3_80=/sys/bus/i2c/devices/203-0050/eeprom +eeprom_path_3_81=/sys/bus/i2c/devices/204-0050/eeprom +eeprom_path_3_82=/sys/bus/i2c/devices/205-0050/eeprom +eeprom_path_3_83=/sys/bus/i2c/devices/206-0050/eeprom +eeprom_path_3_84=/sys/bus/i2c/devices/207-0050/eeprom +eeprom_path_3_85=/sys/bus/i2c/devices/208-0050/eeprom +eeprom_path_3_86=/sys/bus/i2c/devices/209-0050/eeprom +eeprom_path_3_87=/sys/bus/i2c/devices/210-0050/eeprom +eeprom_path_3_88=/sys/bus/i2c/devices/211-0050/eeprom +eeprom_path_3_89=/sys/bus/i2c/devices/212-0050/eeprom +eeprom_path_3_90=/sys/bus/i2c/devices/213-0050/eeprom +eeprom_path_3_91=/sys/bus/i2c/devices/214-0050/eeprom +eeprom_path_3_92=/sys/bus/i2c/devices/215-0050/eeprom +eeprom_path_3_93=/sys/bus/i2c/devices/216-0050/eeprom +eeprom_path_3_94=/sys/bus/i2c/devices/217-0050/eeprom +eeprom_path_3_95=/sys/bus/i2c/devices/218-0050/eeprom +eeprom_path_3_96=/sys/bus/i2c/devices/219-0050/eeprom +eeprom_path_3_97=/sys/bus/i2c/devices/220-0050/eeprom +eeprom_path_3_98=/sys/bus/i2c/devices/221-0050/eeprom +eeprom_path_3_99=/sys/bus/i2c/devices/222-0050/eeprom +eeprom_path_3_100=/sys/bus/i2c/devices/223-0050/eeprom +eeprom_path_3_101=/sys/bus/i2c/devices/224-0050/eeprom +eeprom_path_3_102=/sys/bus/i2c/devices/225-0050/eeprom +eeprom_path_3_103=/sys/bus/i2c/devices/226-0050/eeprom +eeprom_path_3_104=/sys/bus/i2c/devices/227-0050/eeprom +eeprom_path_3_105=/sys/bus/i2c/devices/228-0050/eeprom +eeprom_path_3_106=/sys/bus/i2c/devices/229-0050/eeprom +eeprom_path_3_107=/sys/bus/i2c/devices/230-0050/eeprom +eeprom_path_3_108=/sys/bus/i2c/devices/231-0050/eeprom +eeprom_path_3_109=/sys/bus/i2c/devices/232-0050/eeprom +eeprom_path_3_110=/sys/bus/i2c/devices/233-0050/eeprom +eeprom_path_3_111=/sys/bus/i2c/devices/234-0050/eeprom +eeprom_path_3_112=/sys/bus/i2c/devices/235-0050/eeprom +eeprom_path_3_113=/sys/bus/i2c/devices/236-0050/eeprom +eeprom_path_3_114=/sys/bus/i2c/devices/237-0050/eeprom +eeprom_path_3_115=/sys/bus/i2c/devices/238-0050/eeprom +eeprom_path_3_116=/sys/bus/i2c/devices/239-0050/eeprom +eeprom_path_3_117=/sys/bus/i2c/devices/240-0050/eeprom +eeprom_path_3_118=/sys/bus/i2c/devices/241-0050/eeprom +eeprom_path_3_119=/sys/bus/i2c/devices/242-0050/eeprom +eeprom_path_3_120=/sys/bus/i2c/devices/243-0050/eeprom +eeprom_path_3_121=/sys/bus/i2c/devices/244-0050/eeprom +eeprom_path_3_122=/sys/bus/i2c/devices/245-0050/eeprom +eeprom_path_3_123=/sys/bus/i2c/devices/246-0050/eeprom +eeprom_path_3_124=/sys/bus/i2c/devices/247-0050/eeprom +eeprom_path_3_125=/sys/bus/i2c/devices/248-0050/eeprom +eeprom_path_3_126=/sys/bus/i2c/devices/249-0050/eeprom +eeprom_path_3_127=/sys/bus/i2c/devices/250-0050/eeprom +eeprom_path_3_128=/sys/bus/i2c/devices/251-0050/eeprom + + + +sff_cpld_reg.mode_1_6=config +sff_cpld_reg.src_1_6=cpld +sff_cpld_reg.frmt_1_6=bit +sff_cpld_reg.pola_1_6=negative +sff_cpld_reg.addr_1_6=0x00020073 +sff_cpld_reg.len_1_6=1 +sff_cpld_reg.bit_offset_1_6=0 + +sff_cpld_reg.mode_2_6=config +sff_cpld_reg.src_2_6=cpld +sff_cpld_reg.frmt_2_6=bit +sff_cpld_reg.pola_2_6=negative +sff_cpld_reg.addr_2_6=0x00020073 +sff_cpld_reg.len_2_6=1 +sff_cpld_reg.bit_offset_2_6=1 + +sff_cpld_reg.mode_3_6=config +sff_cpld_reg.src_3_6=cpld +sff_cpld_reg.frmt_3_6=bit +sff_cpld_reg.pola_3_6=negative +sff_cpld_reg.addr_3_6=0x00020073 +sff_cpld_reg.len_3_6=1 +sff_cpld_reg.bit_offset_3_6=2 + +sff_cpld_reg.mode_4_6=config +sff_cpld_reg.src_4_6=cpld +sff_cpld_reg.frmt_4_6=bit +sff_cpld_reg.pola_4_6=negative +sff_cpld_reg.addr_4_6=0x00020073 +sff_cpld_reg.len_4_6=1 +sff_cpld_reg.bit_offset_4_6=3 + +sff_cpld_reg.mode_5_6=config +sff_cpld_reg.src_5_6=cpld +sff_cpld_reg.frmt_5_6=bit +sff_cpld_reg.pola_5_6=negative +sff_cpld_reg.addr_5_6=0x00020073 +sff_cpld_reg.len_5_6=1 +sff_cpld_reg.bit_offset_5_6=4 + +sff_cpld_reg.mode_6_6=config +sff_cpld_reg.src_6_6=cpld +sff_cpld_reg.frmt_6_6=bit +sff_cpld_reg.pola_6_6=negative +sff_cpld_reg.addr_6_6=0x00020073 +sff_cpld_reg.len_6_6=1 +sff_cpld_reg.bit_offset_6_6=5 + +sff_cpld_reg.mode_7_6=config +sff_cpld_reg.src_7_6=cpld +sff_cpld_reg.frmt_7_6=bit +sff_cpld_reg.pola_7_6=negative +sff_cpld_reg.addr_7_6=0x00020073 +sff_cpld_reg.len_7_6=1 +sff_cpld_reg.bit_offset_7_6=6 + +sff_cpld_reg.mode_8_6=config +sff_cpld_reg.src_8_6=cpld +sff_cpld_reg.frmt_8_6=bit +sff_cpld_reg.pola_8_6=negative +sff_cpld_reg.addr_8_6=0x00020073 +sff_cpld_reg.len_8_6=1 +sff_cpld_reg.bit_offset_8_6=7 + +sff_cpld_reg.mode_9_6=config +sff_cpld_reg.src_9_6=cpld +sff_cpld_reg.frmt_9_6=bit +sff_cpld_reg.pola_9_6=negative +sff_cpld_reg.addr_9_6=0x00020072 +sff_cpld_reg.len_9_6=1 +sff_cpld_reg.bit_offset_9_6=0 + +sff_cpld_reg.mode_10_6=config +sff_cpld_reg.src_10_6=cpld +sff_cpld_reg.frmt_10_6=bit +sff_cpld_reg.pola_10_6=negative +sff_cpld_reg.addr_10_6=0x00020072 +sff_cpld_reg.len_10_6=1 +sff_cpld_reg.bit_offset_10_6=1 + +sff_cpld_reg.mode_11_6=config +sff_cpld_reg.src_11_6=cpld +sff_cpld_reg.frmt_11_6=bit +sff_cpld_reg.pola_11_6=negative +sff_cpld_reg.addr_11_6=0x00020072 +sff_cpld_reg.len_11_6=1 +sff_cpld_reg.bit_offset_11_6=2 + +sff_cpld_reg.mode_12_6=config +sff_cpld_reg.src_12_6=cpld +sff_cpld_reg.frmt_12_6=bit +sff_cpld_reg.pola_12_6=negative +sff_cpld_reg.addr_12_6=0x00020072 +sff_cpld_reg.len_12_6=1 +sff_cpld_reg.bit_offset_12_6=3 + +sff_cpld_reg.mode_13_6=config +sff_cpld_reg.src_13_6=cpld +sff_cpld_reg.frmt_13_6=bit +sff_cpld_reg.pola_13_6=negative +sff_cpld_reg.addr_13_6=0x00020072 +sff_cpld_reg.len_13_6=1 +sff_cpld_reg.bit_offset_13_6=4 + +sff_cpld_reg.mode_14_6=config +sff_cpld_reg.src_14_6=cpld +sff_cpld_reg.frmt_14_6=bit +sff_cpld_reg.pola_14_6=negative +sff_cpld_reg.addr_14_6=0x00020072 +sff_cpld_reg.len_14_6=1 +sff_cpld_reg.bit_offset_14_6=5 + +sff_cpld_reg.mode_15_6=config +sff_cpld_reg.src_15_6=cpld +sff_cpld_reg.frmt_15_6=bit +sff_cpld_reg.pola_15_6=negative +sff_cpld_reg.addr_15_6=0x00020072 +sff_cpld_reg.len_15_6=1 +sff_cpld_reg.bit_offset_15_6=6 + +sff_cpld_reg.mode_16_6=config +sff_cpld_reg.src_16_6=cpld +sff_cpld_reg.frmt_16_6=bit +sff_cpld_reg.pola_16_6=negative +sff_cpld_reg.addr_16_6=0x00020072 +sff_cpld_reg.len_16_6=1 +sff_cpld_reg.bit_offset_16_6=7 + +sff_cpld_reg.mode_17_6=config +sff_cpld_reg.src_17_6=cpld +sff_cpld_reg.frmt_17_6=bit +sff_cpld_reg.pola_17_6=negative +sff_cpld_reg.addr_17_6=0x00020071 +sff_cpld_reg.len_17_6=1 +sff_cpld_reg.bit_offset_17_6=0 + +sff_cpld_reg.mode_18_6=config +sff_cpld_reg.src_18_6=cpld +sff_cpld_reg.frmt_18_6=bit +sff_cpld_reg.pola_18_6=negative +sff_cpld_reg.addr_18_6=0x00020071 +sff_cpld_reg.len_18_6=1 +sff_cpld_reg.bit_offset_18_6=1 + +sff_cpld_reg.mode_19_6=config +sff_cpld_reg.src_19_6=cpld +sff_cpld_reg.frmt_19_6=bit +sff_cpld_reg.pola_19_6=negative +sff_cpld_reg.addr_19_6=0x00020071 +sff_cpld_reg.len_19_6=1 +sff_cpld_reg.bit_offset_19_6=2 + +sff_cpld_reg.mode_20_6=config +sff_cpld_reg.src_20_6=cpld +sff_cpld_reg.frmt_20_6=bit +sff_cpld_reg.pola_20_6=negative +sff_cpld_reg.addr_20_6=0x00020071 +sff_cpld_reg.len_20_6=1 +sff_cpld_reg.bit_offset_20_6=3 + +sff_cpld_reg.mode_21_6=config +sff_cpld_reg.src_21_6=cpld +sff_cpld_reg.frmt_21_6=bit +sff_cpld_reg.pola_21_6=negative +sff_cpld_reg.addr_21_6=0x00020071 +sff_cpld_reg.len_21_6=1 +sff_cpld_reg.bit_offset_21_6=4 + +sff_cpld_reg.mode_22_6=config +sff_cpld_reg.src_22_6=cpld +sff_cpld_reg.frmt_22_6=bit +sff_cpld_reg.pola_22_6=negative +sff_cpld_reg.addr_22_6=0x00020071 +sff_cpld_reg.len_22_6=1 +sff_cpld_reg.bit_offset_22_6=5 + +sff_cpld_reg.mode_23_6=config +sff_cpld_reg.src_23_6=cpld +sff_cpld_reg.frmt_23_6=bit +sff_cpld_reg.pola_23_6=negative +sff_cpld_reg.addr_23_6=0x00020071 +sff_cpld_reg.len_23_6=1 +sff_cpld_reg.bit_offset_23_6=6 + +sff_cpld_reg.mode_24_6=config +sff_cpld_reg.src_24_6=cpld +sff_cpld_reg.frmt_24_6=bit +sff_cpld_reg.pola_24_6=negative +sff_cpld_reg.addr_24_6=0x00020071 +sff_cpld_reg.len_24_6=1 +sff_cpld_reg.bit_offset_24_6=7 + +sff_cpld_reg.mode_25_6=config +sff_cpld_reg.src_25_6=cpld +sff_cpld_reg.frmt_25_6=bit +sff_cpld_reg.pola_25_6=negative +sff_cpld_reg.addr_25_6=0x00020070 +sff_cpld_reg.len_25_6=1 +sff_cpld_reg.bit_offset_25_6=0 + +sff_cpld_reg.mode_26_6=config +sff_cpld_reg.src_26_6=cpld +sff_cpld_reg.frmt_26_6=bit +sff_cpld_reg.pola_26_6=negative +sff_cpld_reg.addr_26_6=0x00020070 +sff_cpld_reg.len_26_6=1 +sff_cpld_reg.bit_offset_26_6=1 + +sff_cpld_reg.mode_27_6=config +sff_cpld_reg.src_27_6=cpld +sff_cpld_reg.frmt_27_6=bit +sff_cpld_reg.pola_27_6=negative +sff_cpld_reg.addr_27_6=0x00020070 +sff_cpld_reg.len_27_6=1 +sff_cpld_reg.bit_offset_27_6=2 + +sff_cpld_reg.mode_28_6=config +sff_cpld_reg.src_28_6=cpld +sff_cpld_reg.frmt_28_6=bit +sff_cpld_reg.pola_28_6=negative +sff_cpld_reg.addr_28_6=0x00020070 +sff_cpld_reg.len_28_6=1 +sff_cpld_reg.bit_offset_28_6=3 + +sff_cpld_reg.mode_29_6=config +sff_cpld_reg.src_29_6=cpld +sff_cpld_reg.frmt_29_6=bit +sff_cpld_reg.pola_29_6=negative +sff_cpld_reg.addr_29_6=0x00020070 +sff_cpld_reg.len_29_6=1 +sff_cpld_reg.bit_offset_29_6=4 + +sff_cpld_reg.mode_30_6=config +sff_cpld_reg.src_30_6=cpld +sff_cpld_reg.frmt_30_6=bit +sff_cpld_reg.pola_30_6=negative +sff_cpld_reg.addr_30_6=0x00020070 +sff_cpld_reg.len_30_6=1 +sff_cpld_reg.bit_offset_30_6=5 + +sff_cpld_reg.mode_31_6=config +sff_cpld_reg.src_31_6=cpld +sff_cpld_reg.frmt_31_6=bit +sff_cpld_reg.pola_31_6=negative +sff_cpld_reg.addr_31_6=0x00020070 +sff_cpld_reg.len_31_6=1 +sff_cpld_reg.bit_offset_31_6=6 + +sff_cpld_reg.mode_32_6=config +sff_cpld_reg.src_32_6=cpld +sff_cpld_reg.frmt_32_6=bit +sff_cpld_reg.pola_32_6=negative +sff_cpld_reg.addr_32_6=0x00020070 +sff_cpld_reg.len_32_6=1 +sff_cpld_reg.bit_offset_32_6=7 + +sff_cpld_reg.mode_33_6=config +sff_cpld_reg.src_33_6=cpld +sff_cpld_reg.frmt_33_6=bit +sff_cpld_reg.pola_33_6=negative +sff_cpld_reg.addr_33_6=0x00050072 +sff_cpld_reg.len_33_6=1 +sff_cpld_reg.bit_offset_33_6=0 + +sff_cpld_reg.mode_34_6=config +sff_cpld_reg.src_34_6=cpld +sff_cpld_reg.frmt_34_6=bit +sff_cpld_reg.pola_34_6=negative +sff_cpld_reg.addr_34_6=0x00050072 +sff_cpld_reg.len_34_6=1 +sff_cpld_reg.bit_offset_34_6=1 + +sff_cpld_reg.mode_35_6=config +sff_cpld_reg.src_35_6=cpld +sff_cpld_reg.frmt_35_6=bit +sff_cpld_reg.pola_35_6=negative +sff_cpld_reg.addr_35_6=0x00050072 +sff_cpld_reg.len_35_6=1 +sff_cpld_reg.bit_offset_35_6=2 + +sff_cpld_reg.mode_36_6=config +sff_cpld_reg.src_36_6=cpld +sff_cpld_reg.frmt_36_6=bit +sff_cpld_reg.pola_36_6=negative +sff_cpld_reg.addr_36_6=0x00050072 +sff_cpld_reg.len_36_6=1 +sff_cpld_reg.bit_offset_36_6=3 + +sff_cpld_reg.mode_37_6=config +sff_cpld_reg.src_37_6=cpld +sff_cpld_reg.frmt_37_6=bit +sff_cpld_reg.pola_37_6=negative +sff_cpld_reg.addr_37_6=0x00050071 +sff_cpld_reg.len_37_6=1 +sff_cpld_reg.bit_offset_37_6=0 + +sff_cpld_reg.mode_38_6=config +sff_cpld_reg.src_38_6=cpld +sff_cpld_reg.frmt_38_6=bit +sff_cpld_reg.pola_38_6=negative +sff_cpld_reg.addr_38_6=0x00050071 +sff_cpld_reg.len_38_6=1 +sff_cpld_reg.bit_offset_38_6=1 + +sff_cpld_reg.mode_39_6=config +sff_cpld_reg.src_39_6=cpld +sff_cpld_reg.frmt_39_6=bit +sff_cpld_reg.pola_39_6=negative +sff_cpld_reg.addr_39_6=0x00050071 +sff_cpld_reg.len_39_6=1 +sff_cpld_reg.bit_offset_39_6=2 + +sff_cpld_reg.mode_40_6=config +sff_cpld_reg.src_40_6=cpld +sff_cpld_reg.frmt_40_6=bit +sff_cpld_reg.pola_40_6=negative +sff_cpld_reg.addr_40_6=0x00050071 +sff_cpld_reg.len_40_6=1 +sff_cpld_reg.bit_offset_40_6=3 + +sff_cpld_reg.mode_41_6=config +sff_cpld_reg.src_41_6=cpld +sff_cpld_reg.frmt_41_6=bit +sff_cpld_reg.pola_41_6=negative +sff_cpld_reg.addr_41_6=0x00050071 +sff_cpld_reg.len_41_6=1 +sff_cpld_reg.bit_offset_41_6=4 + +sff_cpld_reg.mode_42_6=config +sff_cpld_reg.src_42_6=cpld +sff_cpld_reg.frmt_42_6=bit +sff_cpld_reg.pola_42_6=negative +sff_cpld_reg.addr_42_6=0x00050071 +sff_cpld_reg.len_42_6=1 +sff_cpld_reg.bit_offset_42_6=5 + +sff_cpld_reg.mode_43_6=config +sff_cpld_reg.src_43_6=cpld +sff_cpld_reg.frmt_43_6=bit +sff_cpld_reg.pola_43_6=negative +sff_cpld_reg.addr_43_6=0x00060075 +sff_cpld_reg.len_43_6=1 +sff_cpld_reg.bit_offset_43_6=0 + +sff_cpld_reg.mode_44_6=config +sff_cpld_reg.src_44_6=cpld +sff_cpld_reg.frmt_44_6=bit +sff_cpld_reg.pola_44_6=negative +sff_cpld_reg.addr_44_6=0x00060075 +sff_cpld_reg.len_44_6=1 +sff_cpld_reg.bit_offset_44_6=1 + +sff_cpld_reg.mode_45_6=config +sff_cpld_reg.src_45_6=cpld +sff_cpld_reg.frmt_45_6=bit +sff_cpld_reg.pola_45_6=negative +sff_cpld_reg.addr_45_6=0x00060075 +sff_cpld_reg.len_45_6=1 +sff_cpld_reg.bit_offset_45_6=2 + +sff_cpld_reg.mode_46_6=config +sff_cpld_reg.src_46_6=cpld +sff_cpld_reg.frmt_46_6=bit +sff_cpld_reg.pola_46_6=negative +sff_cpld_reg.addr_46_6=0x00060075 +sff_cpld_reg.len_46_6=1 +sff_cpld_reg.bit_offset_46_6=3 + +sff_cpld_reg.mode_47_6=config +sff_cpld_reg.src_47_6=cpld +sff_cpld_reg.frmt_47_6=bit +sff_cpld_reg.pola_47_6=negative +sff_cpld_reg.addr_47_6=0x00060075 +sff_cpld_reg.len_47_6=1 +sff_cpld_reg.bit_offset_47_6=4 + +sff_cpld_reg.mode_48_6=config +sff_cpld_reg.src_48_6=cpld +sff_cpld_reg.frmt_48_6=bit +sff_cpld_reg.pola_48_6=negative +sff_cpld_reg.addr_48_6=0x00060075 +sff_cpld_reg.len_48_6=1 +sff_cpld_reg.bit_offset_48_6=5 + +sff_cpld_reg.mode_49_6=config +sff_cpld_reg.src_49_6=cpld +sff_cpld_reg.frmt_49_6=bit +sff_cpld_reg.pola_49_6=negative +sff_cpld_reg.addr_49_6=0x00060074 +sff_cpld_reg.len_49_6=1 +sff_cpld_reg.bit_offset_49_6=0 + +sff_cpld_reg.mode_50_6=config +sff_cpld_reg.src_50_6=cpld +sff_cpld_reg.frmt_50_6=bit +sff_cpld_reg.pola_50_6=negative +sff_cpld_reg.addr_50_6=0x00060074 +sff_cpld_reg.len_50_6=1 +sff_cpld_reg.bit_offset_50_6=1 + +sff_cpld_reg.mode_51_6=config +sff_cpld_reg.src_51_6=cpld +sff_cpld_reg.frmt_51_6=bit +sff_cpld_reg.pola_51_6=negative +sff_cpld_reg.addr_51_6=0x00060074 +sff_cpld_reg.len_51_6=1 +sff_cpld_reg.bit_offset_51_6=2 + +sff_cpld_reg.mode_52_6=config +sff_cpld_reg.src_52_6=cpld +sff_cpld_reg.frmt_52_6=bit +sff_cpld_reg.pola_52_6=negative +sff_cpld_reg.addr_52_6=0x00060074 +sff_cpld_reg.len_52_6=1 +sff_cpld_reg.bit_offset_52_6=3 + +sff_cpld_reg.mode_53_6=config +sff_cpld_reg.src_53_6=cpld +sff_cpld_reg.frmt_53_6=bit +sff_cpld_reg.pola_53_6=negative +sff_cpld_reg.addr_53_6=0x00060074 +sff_cpld_reg.len_53_6=1 +sff_cpld_reg.bit_offset_53_6=4 + +sff_cpld_reg.mode_54_6=config +sff_cpld_reg.src_54_6=cpld +sff_cpld_reg.frmt_54_6=bit +sff_cpld_reg.pola_54_6=negative +sff_cpld_reg.addr_54_6=0x00060074 +sff_cpld_reg.len_54_6=1 +sff_cpld_reg.bit_offset_54_6=5 + +sff_cpld_reg.mode_55_6=config +sff_cpld_reg.src_55_6=cpld +sff_cpld_reg.frmt_55_6=bit +sff_cpld_reg.pola_55_6=negative +sff_cpld_reg.addr_55_6=0x00060074 +sff_cpld_reg.len_55_6=1 +sff_cpld_reg.bit_offset_55_6=6 + +sff_cpld_reg.mode_56_6=config +sff_cpld_reg.src_56_6=cpld +sff_cpld_reg.frmt_56_6=bit +sff_cpld_reg.pola_56_6=negative +sff_cpld_reg.addr_56_6=0x00060074 +sff_cpld_reg.len_56_6=1 +sff_cpld_reg.bit_offset_56_6=7 + +sff_cpld_reg.mode_57_6=config +sff_cpld_reg.src_57_6=cpld +sff_cpld_reg.frmt_57_6=bit +sff_cpld_reg.pola_57_6=negative +sff_cpld_reg.addr_57_6=0x00060073 +sff_cpld_reg.len_57_6=1 +sff_cpld_reg.bit_offset_57_6=0 + +sff_cpld_reg.mode_58_6=config +sff_cpld_reg.src_58_6=cpld +sff_cpld_reg.frmt_58_6=bit +sff_cpld_reg.pola_58_6=negative +sff_cpld_reg.addr_58_6=0x00060073 +sff_cpld_reg.len_58_6=1 +sff_cpld_reg.bit_offset_58_6=1 + +sff_cpld_reg.mode_59_6=config +sff_cpld_reg.src_59_6=cpld +sff_cpld_reg.frmt_59_6=bit +sff_cpld_reg.pola_59_6=negative +sff_cpld_reg.addr_59_6=0x00060073 +sff_cpld_reg.len_59_6=1 +sff_cpld_reg.bit_offset_59_6=2 + +sff_cpld_reg.mode_60_6=config +sff_cpld_reg.src_60_6=cpld +sff_cpld_reg.frmt_60_6=bit +sff_cpld_reg.pola_60_6=negative +sff_cpld_reg.addr_60_6=0x00060073 +sff_cpld_reg.len_60_6=1 +sff_cpld_reg.bit_offset_60_6=3 + +sff_cpld_reg.mode_61_6=config +sff_cpld_reg.src_61_6=cpld +sff_cpld_reg.frmt_61_6=bit +sff_cpld_reg.pola_61_6=negative +sff_cpld_reg.addr_61_6=0x00060073 +sff_cpld_reg.len_61_6=1 +sff_cpld_reg.bit_offset_61_6=4 + +sff_cpld_reg.mode_62_6=config +sff_cpld_reg.src_62_6=cpld +sff_cpld_reg.frmt_62_6=bit +sff_cpld_reg.pola_62_6=negative +sff_cpld_reg.addr_62_6=0x00060073 +sff_cpld_reg.len_62_6=1 +sff_cpld_reg.bit_offset_62_6=5 + +sff_cpld_reg.mode_63_6=config +sff_cpld_reg.src_63_6=cpld +sff_cpld_reg.frmt_63_6=bit +sff_cpld_reg.pola_63_6=negative +sff_cpld_reg.addr_63_6=0x00060073 +sff_cpld_reg.len_63_6=1 +sff_cpld_reg.bit_offset_63_6=6 + +sff_cpld_reg.mode_64_6=config +sff_cpld_reg.src_64_6=cpld +sff_cpld_reg.frmt_64_6=bit +sff_cpld_reg.pola_64_6=negative +sff_cpld_reg.addr_64_6=0x00060073 +sff_cpld_reg.len_64_6=1 +sff_cpld_reg.bit_offset_64_6=7 + +sff_cpld_reg.mode_65_6=config +sff_cpld_reg.src_65_6=cpld +sff_cpld_reg.frmt_65_6=bit +sff_cpld_reg.pola_65_6=negative +sff_cpld_reg.addr_65_6=0x00050071 +sff_cpld_reg.len_65_6=1 +sff_cpld_reg.bit_offset_65_6=6 + +sff_cpld_reg.mode_66_6=config +sff_cpld_reg.src_66_6=cpld +sff_cpld_reg.frmt_66_6=bit +sff_cpld_reg.pola_66_6=negative +sff_cpld_reg.addr_66_6=0x00050071 +sff_cpld_reg.len_66_6=1 +sff_cpld_reg.bit_offset_66_6=7 + +sff_cpld_reg.mode_67_6=config +sff_cpld_reg.src_67_6=cpld +sff_cpld_reg.frmt_67_6=bit +sff_cpld_reg.pola_67_6=negative +sff_cpld_reg.addr_67_6=0x00050070 +sff_cpld_reg.len_67_6=1 +sff_cpld_reg.bit_offset_67_6=0 + +sff_cpld_reg.mode_68_6=config +sff_cpld_reg.src_68_6=cpld +sff_cpld_reg.frmt_68_6=bit +sff_cpld_reg.pola_68_6=negative +sff_cpld_reg.addr_68_6=0x00050070 +sff_cpld_reg.len_68_6=1 +sff_cpld_reg.bit_offset_68_6=1 + +sff_cpld_reg.mode_69_6=config +sff_cpld_reg.src_69_6=cpld +sff_cpld_reg.frmt_69_6=bit +sff_cpld_reg.pola_69_6=negative +sff_cpld_reg.addr_69_6=0x00050070 +sff_cpld_reg.len_69_6=1 +sff_cpld_reg.bit_offset_69_6=2 + +sff_cpld_reg.mode_70_6=config +sff_cpld_reg.src_70_6=cpld +sff_cpld_reg.frmt_70_6=bit +sff_cpld_reg.pola_70_6=negative +sff_cpld_reg.addr_70_6=0x00050070 +sff_cpld_reg.len_70_6=1 +sff_cpld_reg.bit_offset_70_6=3 + +sff_cpld_reg.mode_71_6=config +sff_cpld_reg.src_71_6=cpld +sff_cpld_reg.frmt_71_6=bit +sff_cpld_reg.pola_71_6=negative +sff_cpld_reg.addr_71_6=0x00050070 +sff_cpld_reg.len_71_6=1 +sff_cpld_reg.bit_offset_71_6=4 + +sff_cpld_reg.mode_72_6=config +sff_cpld_reg.src_72_6=cpld +sff_cpld_reg.frmt_72_6=bit +sff_cpld_reg.pola_72_6=negative +sff_cpld_reg.addr_72_6=0x00050070 +sff_cpld_reg.len_72_6=1 +sff_cpld_reg.bit_offset_72_6=5 + +sff_cpld_reg.mode_73_6=config +sff_cpld_reg.src_73_6=cpld +sff_cpld_reg.frmt_73_6=bit +sff_cpld_reg.pola_73_6=negative +sff_cpld_reg.addr_73_6=0x00050070 +sff_cpld_reg.len_73_6=1 +sff_cpld_reg.bit_offset_73_6=6 + +sff_cpld_reg.mode_74_6=config +sff_cpld_reg.src_74_6=cpld +sff_cpld_reg.frmt_74_6=bit +sff_cpld_reg.pola_74_6=negative +sff_cpld_reg.addr_74_6=0x00050070 +sff_cpld_reg.len_74_6=1 +sff_cpld_reg.bit_offset_74_6=7 + +sff_cpld_reg.mode_75_6=config +sff_cpld_reg.src_75_6=cpld +sff_cpld_reg.frmt_75_6=bit +sff_cpld_reg.pola_75_6=negative +sff_cpld_reg.addr_75_6=0x00060072 +sff_cpld_reg.len_75_6=1 +sff_cpld_reg.bit_offset_75_6=0 + +sff_cpld_reg.mode_76_6=config +sff_cpld_reg.src_76_6=cpld +sff_cpld_reg.frmt_76_6=bit +sff_cpld_reg.pola_76_6=negative +sff_cpld_reg.addr_76_6=0x00060072 +sff_cpld_reg.len_76_6=1 +sff_cpld_reg.bit_offset_76_6=1 + +sff_cpld_reg.mode_77_6=config +sff_cpld_reg.src_77_6=cpld +sff_cpld_reg.frmt_77_6=bit +sff_cpld_reg.pola_77_6=negative +sff_cpld_reg.addr_77_6=0x00060072 +sff_cpld_reg.len_77_6=1 +sff_cpld_reg.bit_offset_77_6=2 + +sff_cpld_reg.mode_78_6=config +sff_cpld_reg.src_78_6=cpld +sff_cpld_reg.frmt_78_6=bit +sff_cpld_reg.pola_78_6=negative +sff_cpld_reg.addr_78_6=0x00060072 +sff_cpld_reg.len_78_6=1 +sff_cpld_reg.bit_offset_78_6=3 + +sff_cpld_reg.mode_79_6=config +sff_cpld_reg.src_79_6=cpld +sff_cpld_reg.frmt_79_6=bit +sff_cpld_reg.pola_79_6=negative +sff_cpld_reg.addr_79_6=0x00060072 +sff_cpld_reg.len_79_6=1 +sff_cpld_reg.bit_offset_79_6=4 + +sff_cpld_reg.mode_80_6=config +sff_cpld_reg.src_80_6=cpld +sff_cpld_reg.frmt_80_6=bit +sff_cpld_reg.pola_80_6=negative +sff_cpld_reg.addr_80_6=0x00060072 +sff_cpld_reg.len_80_6=1 +sff_cpld_reg.bit_offset_80_6=5 + +sff_cpld_reg.mode_81_6=config +sff_cpld_reg.src_81_6=cpld +sff_cpld_reg.frmt_81_6=bit +sff_cpld_reg.pola_81_6=negative +sff_cpld_reg.addr_81_6=0x00060071 +sff_cpld_reg.len_81_6=1 +sff_cpld_reg.bit_offset_81_6=0 + +sff_cpld_reg.mode_82_6=config +sff_cpld_reg.src_82_6=cpld +sff_cpld_reg.frmt_82_6=bit +sff_cpld_reg.pola_82_6=negative +sff_cpld_reg.addr_82_6=0x00060071 +sff_cpld_reg.len_82_6=1 +sff_cpld_reg.bit_offset_82_6=1 + +sff_cpld_reg.mode_83_6=config +sff_cpld_reg.src_83_6=cpld +sff_cpld_reg.frmt_83_6=bit +sff_cpld_reg.pola_83_6=negative +sff_cpld_reg.addr_83_6=0x00060071 +sff_cpld_reg.len_83_6=1 +sff_cpld_reg.bit_offset_83_6=2 + +sff_cpld_reg.mode_84_6=config +sff_cpld_reg.src_84_6=cpld +sff_cpld_reg.frmt_84_6=bit +sff_cpld_reg.pola_84_6=negative +sff_cpld_reg.addr_84_6=0x00060071 +sff_cpld_reg.len_84_6=1 +sff_cpld_reg.bit_offset_84_6=3 + +sff_cpld_reg.mode_85_6=config +sff_cpld_reg.src_85_6=cpld +sff_cpld_reg.frmt_85_6=bit +sff_cpld_reg.pola_85_6=negative +sff_cpld_reg.addr_85_6=0x00060071 +sff_cpld_reg.len_85_6=1 +sff_cpld_reg.bit_offset_85_6=4 + +sff_cpld_reg.mode_86_6=config +sff_cpld_reg.src_86_6=cpld +sff_cpld_reg.frmt_86_6=bit +sff_cpld_reg.pola_86_6=negative +sff_cpld_reg.addr_86_6=0x00060071 +sff_cpld_reg.len_86_6=1 +sff_cpld_reg.bit_offset_86_6=5 + +sff_cpld_reg.mode_87_6=config +sff_cpld_reg.src_87_6=cpld +sff_cpld_reg.frmt_87_6=bit +sff_cpld_reg.pola_87_6=negative +sff_cpld_reg.addr_87_6=0x00060071 +sff_cpld_reg.len_87_6=1 +sff_cpld_reg.bit_offset_87_6=6 + +sff_cpld_reg.mode_88_6=config +sff_cpld_reg.src_88_6=cpld +sff_cpld_reg.frmt_88_6=bit +sff_cpld_reg.pola_88_6=negative +sff_cpld_reg.addr_88_6=0x00060071 +sff_cpld_reg.len_88_6=1 +sff_cpld_reg.bit_offset_88_6=7 + +sff_cpld_reg.mode_89_6=config +sff_cpld_reg.src_89_6=cpld +sff_cpld_reg.frmt_89_6=bit +sff_cpld_reg.pola_89_6=negative +sff_cpld_reg.addr_89_6=0x00060070 +sff_cpld_reg.len_89_6=1 +sff_cpld_reg.bit_offset_89_6=0 + +sff_cpld_reg.mode_90_6=config +sff_cpld_reg.src_90_6=cpld +sff_cpld_reg.frmt_90_6=bit +sff_cpld_reg.pola_90_6=negative +sff_cpld_reg.addr_90_6=0x00060070 +sff_cpld_reg.len_90_6=1 +sff_cpld_reg.bit_offset_90_6=1 + +sff_cpld_reg.mode_91_6=config +sff_cpld_reg.src_91_6=cpld +sff_cpld_reg.frmt_91_6=bit +sff_cpld_reg.pola_91_6=negative +sff_cpld_reg.addr_91_6=0x00060070 +sff_cpld_reg.len_91_6=1 +sff_cpld_reg.bit_offset_91_6=2 + +sff_cpld_reg.mode_92_6=config +sff_cpld_reg.src_92_6=cpld +sff_cpld_reg.frmt_92_6=bit +sff_cpld_reg.pola_92_6=negative +sff_cpld_reg.addr_92_6=0x00060070 +sff_cpld_reg.len_92_6=1 +sff_cpld_reg.bit_offset_92_6=3 + +sff_cpld_reg.mode_93_6=config +sff_cpld_reg.src_93_6=cpld +sff_cpld_reg.frmt_93_6=bit +sff_cpld_reg.pola_93_6=negative +sff_cpld_reg.addr_93_6=0x00060070 +sff_cpld_reg.len_93_6=1 +sff_cpld_reg.bit_offset_93_6=4 + +sff_cpld_reg.mode_94_6=config +sff_cpld_reg.src_94_6=cpld +sff_cpld_reg.frmt_94_6=bit +sff_cpld_reg.pola_94_6=negative +sff_cpld_reg.addr_94_6=0x00060070 +sff_cpld_reg.len_94_6=1 +sff_cpld_reg.bit_offset_94_6=5 + +sff_cpld_reg.mode_95_6=config +sff_cpld_reg.src_95_6=cpld +sff_cpld_reg.frmt_95_6=bit +sff_cpld_reg.pola_95_6=negative +sff_cpld_reg.addr_95_6=0x00060070 +sff_cpld_reg.len_95_6=1 +sff_cpld_reg.bit_offset_95_6=6 + +sff_cpld_reg.mode_96_6=config +sff_cpld_reg.src_96_6=cpld +sff_cpld_reg.frmt_96_6=bit +sff_cpld_reg.pola_96_6=negative +sff_cpld_reg.addr_96_6=0x00060070 +sff_cpld_reg.len_96_6=1 +sff_cpld_reg.bit_offset_96_6=7 + +sff_cpld_reg.mode_97_6=config +sff_cpld_reg.src_97_6=cpld +sff_cpld_reg.frmt_97_6=bit +sff_cpld_reg.pola_97_6=negative +sff_cpld_reg.addr_97_6=0x00070073 +sff_cpld_reg.len_97_6=1 +sff_cpld_reg.bit_offset_97_6=0 + +sff_cpld_reg.mode_98_6=config +sff_cpld_reg.src_98_6=cpld +sff_cpld_reg.frmt_98_6=bit +sff_cpld_reg.pola_98_6=negative +sff_cpld_reg.addr_98_6=0x00070073 +sff_cpld_reg.len_98_6=1 +sff_cpld_reg.bit_offset_98_6=1 + +sff_cpld_reg.mode_99_6=config +sff_cpld_reg.src_99_6=cpld +sff_cpld_reg.frmt_99_6=bit +sff_cpld_reg.pola_99_6=negative +sff_cpld_reg.addr_99_6=0x00070073 +sff_cpld_reg.len_99_6=1 +sff_cpld_reg.bit_offset_99_6=2 + +sff_cpld_reg.mode_100_6=config +sff_cpld_reg.src_100_6=cpld +sff_cpld_reg.frmt_100_6=bit +sff_cpld_reg.pola_100_6=negative +sff_cpld_reg.addr_100_6=0x00070073 +sff_cpld_reg.len_100_6=1 +sff_cpld_reg.bit_offset_100_6=3 + +sff_cpld_reg.mode_101_6=config +sff_cpld_reg.src_101_6=cpld +sff_cpld_reg.frmt_101_6=bit +sff_cpld_reg.pola_101_6=negative +sff_cpld_reg.addr_101_6=0x00070073 +sff_cpld_reg.len_101_6=1 +sff_cpld_reg.bit_offset_101_6=4 + +sff_cpld_reg.mode_102_6=config +sff_cpld_reg.src_102_6=cpld +sff_cpld_reg.frmt_102_6=bit +sff_cpld_reg.pola_102_6=negative +sff_cpld_reg.addr_102_6=0x00070073 +sff_cpld_reg.len_102_6=1 +sff_cpld_reg.bit_offset_102_6=5 + +sff_cpld_reg.mode_103_6=config +sff_cpld_reg.src_103_6=cpld +sff_cpld_reg.frmt_103_6=bit +sff_cpld_reg.pola_103_6=negative +sff_cpld_reg.addr_103_6=0x00070073 +sff_cpld_reg.len_103_6=1 +sff_cpld_reg.bit_offset_103_6=6 + +sff_cpld_reg.mode_104_6=config +sff_cpld_reg.src_104_6=cpld +sff_cpld_reg.frmt_104_6=bit +sff_cpld_reg.pola_104_6=negative +sff_cpld_reg.addr_104_6=0x00070073 +sff_cpld_reg.len_104_6=1 +sff_cpld_reg.bit_offset_104_6=7 + +sff_cpld_reg.mode_105_6=config +sff_cpld_reg.src_105_6=cpld +sff_cpld_reg.frmt_105_6=bit +sff_cpld_reg.pola_105_6=negative +sff_cpld_reg.addr_105_6=0x00070072 +sff_cpld_reg.len_105_6=1 +sff_cpld_reg.bit_offset_105_6=0 + +sff_cpld_reg.mode_106_6=config +sff_cpld_reg.src_106_6=cpld +sff_cpld_reg.frmt_106_6=bit +sff_cpld_reg.pola_106_6=negative +sff_cpld_reg.addr_106_6=0x00070072 +sff_cpld_reg.len_106_6=1 +sff_cpld_reg.bit_offset_106_6=1 + +sff_cpld_reg.mode_107_6=config +sff_cpld_reg.src_107_6=cpld +sff_cpld_reg.frmt_107_6=bit +sff_cpld_reg.pola_107_6=negative +sff_cpld_reg.addr_107_6=0x00070072 +sff_cpld_reg.len_107_6=1 +sff_cpld_reg.bit_offset_107_6=2 + +sff_cpld_reg.mode_108_6=config +sff_cpld_reg.src_108_6=cpld +sff_cpld_reg.frmt_108_6=bit +sff_cpld_reg.pola_108_6=negative +sff_cpld_reg.addr_108_6=0x00070072 +sff_cpld_reg.len_108_6=1 +sff_cpld_reg.bit_offset_108_6=3 + +sff_cpld_reg.mode_109_6=config +sff_cpld_reg.src_109_6=cpld +sff_cpld_reg.frmt_109_6=bit +sff_cpld_reg.pola_109_6=negative +sff_cpld_reg.addr_109_6=0x00070072 +sff_cpld_reg.len_109_6=1 +sff_cpld_reg.bit_offset_109_6=4 + +sff_cpld_reg.mode_110_6=config +sff_cpld_reg.src_110_6=cpld +sff_cpld_reg.frmt_110_6=bit +sff_cpld_reg.pola_110_6=negative +sff_cpld_reg.addr_110_6=0x00070072 +sff_cpld_reg.len_110_6=1 +sff_cpld_reg.bit_offset_110_6=5 + +sff_cpld_reg.mode_111_6=config +sff_cpld_reg.src_111_6=cpld +sff_cpld_reg.frmt_111_6=bit +sff_cpld_reg.pola_111_6=negative +sff_cpld_reg.addr_111_6=0x00070072 +sff_cpld_reg.len_111_6=1 +sff_cpld_reg.bit_offset_111_6=6 + +sff_cpld_reg.mode_112_6=config +sff_cpld_reg.src_112_6=cpld +sff_cpld_reg.frmt_112_6=bit +sff_cpld_reg.pola_112_6=negative +sff_cpld_reg.addr_112_6=0x00070072 +sff_cpld_reg.len_112_6=1 +sff_cpld_reg.bit_offset_112_6=7 + +sff_cpld_reg.mode_113_6=config +sff_cpld_reg.src_113_6=cpld +sff_cpld_reg.frmt_113_6=bit +sff_cpld_reg.pola_113_6=negative +sff_cpld_reg.addr_113_6=0x00070071 +sff_cpld_reg.len_113_6=1 +sff_cpld_reg.bit_offset_113_6=0 + +sff_cpld_reg.mode_114_6=config +sff_cpld_reg.src_114_6=cpld +sff_cpld_reg.frmt_114_6=bit +sff_cpld_reg.pola_114_6=negative +sff_cpld_reg.addr_114_6=0x00070071 +sff_cpld_reg.len_114_6=1 +sff_cpld_reg.bit_offset_114_6=1 + +sff_cpld_reg.mode_115_6=config +sff_cpld_reg.src_115_6=cpld +sff_cpld_reg.frmt_115_6=bit +sff_cpld_reg.pola_115_6=negative +sff_cpld_reg.addr_115_6=0x00070071 +sff_cpld_reg.len_115_6=1 +sff_cpld_reg.bit_offset_115_6=2 + +sff_cpld_reg.mode_116_6=config +sff_cpld_reg.src_116_6=cpld +sff_cpld_reg.frmt_116_6=bit +sff_cpld_reg.pola_116_6=negative +sff_cpld_reg.addr_116_6=0x00070071 +sff_cpld_reg.len_116_6=1 +sff_cpld_reg.bit_offset_116_6=3 + +sff_cpld_reg.mode_117_6=config +sff_cpld_reg.src_117_6=cpld +sff_cpld_reg.frmt_117_6=bit +sff_cpld_reg.pola_117_6=negative +sff_cpld_reg.addr_117_6=0x00070071 +sff_cpld_reg.len_117_6=1 +sff_cpld_reg.bit_offset_117_6=4 + +sff_cpld_reg.mode_118_6=config +sff_cpld_reg.src_118_6=cpld +sff_cpld_reg.frmt_118_6=bit +sff_cpld_reg.pola_118_6=negative +sff_cpld_reg.addr_118_6=0x00070071 +sff_cpld_reg.len_118_6=1 +sff_cpld_reg.bit_offset_118_6=5 + +sff_cpld_reg.mode_119_6=config +sff_cpld_reg.src_119_6=cpld +sff_cpld_reg.frmt_119_6=bit +sff_cpld_reg.pola_119_6=negative +sff_cpld_reg.addr_119_6=0x00070071 +sff_cpld_reg.len_119_6=1 +sff_cpld_reg.bit_offset_119_6=6 + +sff_cpld_reg.mode_120_6=config +sff_cpld_reg.src_120_6=cpld +sff_cpld_reg.frmt_120_6=bit +sff_cpld_reg.pola_120_6=negative +sff_cpld_reg.addr_120_6=0x00070071 +sff_cpld_reg.len_120_6=1 +sff_cpld_reg.bit_offset_120_6=7 + +sff_cpld_reg.mode_121_6=config +sff_cpld_reg.src_121_6=cpld +sff_cpld_reg.frmt_121_6=bit +sff_cpld_reg.pola_121_6=negative +sff_cpld_reg.addr_121_6=0x00070070 +sff_cpld_reg.len_121_6=1 +sff_cpld_reg.bit_offset_121_6=0 + +sff_cpld_reg.mode_122_6=config +sff_cpld_reg.src_122_6=cpld +sff_cpld_reg.frmt_122_6=bit +sff_cpld_reg.pola_122_6=negative +sff_cpld_reg.addr_122_6=0x00070070 +sff_cpld_reg.len_122_6=1 +sff_cpld_reg.bit_offset_122_6=1 + +sff_cpld_reg.mode_123_6=config +sff_cpld_reg.src_123_6=cpld +sff_cpld_reg.frmt_123_6=bit +sff_cpld_reg.pola_123_6=negative +sff_cpld_reg.addr_123_6=0x00070070 +sff_cpld_reg.len_123_6=1 +sff_cpld_reg.bit_offset_123_6=2 + +sff_cpld_reg.mode_124_6=config +sff_cpld_reg.src_124_6=cpld +sff_cpld_reg.frmt_124_6=bit +sff_cpld_reg.pola_124_6=negative +sff_cpld_reg.addr_124_6=0x00070070 +sff_cpld_reg.len_124_6=1 +sff_cpld_reg.bit_offset_124_6=3 + +sff_cpld_reg.mode_125_6=config +sff_cpld_reg.src_125_6=cpld +sff_cpld_reg.frmt_125_6=bit +sff_cpld_reg.pola_125_6=negative +sff_cpld_reg.addr_125_6=0x00070070 +sff_cpld_reg.len_125_6=1 +sff_cpld_reg.bit_offset_125_6=4 + +sff_cpld_reg.mode_126_6=config +sff_cpld_reg.src_126_6=cpld +sff_cpld_reg.frmt_126_6=bit +sff_cpld_reg.pola_126_6=negative +sff_cpld_reg.addr_126_6=0x00070070 +sff_cpld_reg.len_126_6=1 +sff_cpld_reg.bit_offset_126_6=5 + +sff_cpld_reg.mode_127_6=config +sff_cpld_reg.src_127_6=cpld +sff_cpld_reg.frmt_127_6=bit +sff_cpld_reg.pola_127_6=negative +sff_cpld_reg.addr_127_6=0x00070070 +sff_cpld_reg.len_127_6=1 +sff_cpld_reg.bit_offset_127_6=6 + +sff_cpld_reg.mode_128_6=config +sff_cpld_reg.src_128_6=cpld +sff_cpld_reg.frmt_128_6=bit +sff_cpld_reg.pola_128_6=negative +sff_cpld_reg.addr_128_6=0x00070070 +sff_cpld_reg.len_128_6=1 +sff_cpld_reg.bit_offset_128_6=7 + +sff_cpld_reg.mode_1_7=config +sff_cpld_reg.src_1_7=cpld +sff_cpld_reg.frmt_1_7=bit +sff_cpld_reg.pola_1_7=positive +sff_cpld_reg.addr_1_7=0x0002007B +sff_cpld_reg.len_1_7=1 +sff_cpld_reg.bit_offset_1_7=0 + +sff_cpld_reg.mode_2_7=config +sff_cpld_reg.src_2_7=cpld +sff_cpld_reg.frmt_2_7=bit +sff_cpld_reg.pola_2_7=positive +sff_cpld_reg.addr_2_7=0x0002007B +sff_cpld_reg.len_2_7=1 +sff_cpld_reg.bit_offset_2_7=1 + +sff_cpld_reg.mode_3_7=config +sff_cpld_reg.src_3_7=cpld +sff_cpld_reg.frmt_3_7=bit +sff_cpld_reg.pola_3_7=positive +sff_cpld_reg.addr_3_7=0x0002007B +sff_cpld_reg.len_3_7=1 +sff_cpld_reg.bit_offset_3_7=2 + +sff_cpld_reg.mode_4_7=config +sff_cpld_reg.src_4_7=cpld +sff_cpld_reg.frmt_4_7=bit +sff_cpld_reg.pola_4_7=positive +sff_cpld_reg.addr_4_7=0x0002007B +sff_cpld_reg.len_4_7=1 +sff_cpld_reg.bit_offset_4_7=3 + +sff_cpld_reg.mode_5_7=config +sff_cpld_reg.src_5_7=cpld +sff_cpld_reg.frmt_5_7=bit +sff_cpld_reg.pola_5_7=positive +sff_cpld_reg.addr_5_7=0x0002007B +sff_cpld_reg.len_5_7=1 +sff_cpld_reg.bit_offset_5_7=4 + +sff_cpld_reg.mode_6_7=config +sff_cpld_reg.src_6_7=cpld +sff_cpld_reg.frmt_6_7=bit +sff_cpld_reg.pola_6_7=positive +sff_cpld_reg.addr_6_7=0x0002007B +sff_cpld_reg.len_6_7=1 +sff_cpld_reg.bit_offset_6_7=5 + +sff_cpld_reg.mode_7_7=config +sff_cpld_reg.src_7_7=cpld +sff_cpld_reg.frmt_7_7=bit +sff_cpld_reg.pola_7_7=positive +sff_cpld_reg.addr_7_7=0x0002007B +sff_cpld_reg.len_7_7=1 +sff_cpld_reg.bit_offset_7_7=6 + +sff_cpld_reg.mode_8_7=config +sff_cpld_reg.src_8_7=cpld +sff_cpld_reg.frmt_8_7=bit +sff_cpld_reg.pola_8_7=positive +sff_cpld_reg.addr_8_7=0x0002007B +sff_cpld_reg.len_8_7=1 +sff_cpld_reg.bit_offset_8_7=7 + +sff_cpld_reg.mode_9_7=config +sff_cpld_reg.src_9_7=cpld +sff_cpld_reg.frmt_9_7=bit +sff_cpld_reg.pola_9_7=positive +sff_cpld_reg.addr_9_7=0x0002007A +sff_cpld_reg.len_9_7=1 +sff_cpld_reg.bit_offset_9_7=0 + +sff_cpld_reg.mode_10_7=config +sff_cpld_reg.src_10_7=cpld +sff_cpld_reg.frmt_10_7=bit +sff_cpld_reg.pola_10_7=positive +sff_cpld_reg.addr_10_7=0x0002007A +sff_cpld_reg.len_10_7=1 +sff_cpld_reg.bit_offset_10_7=1 + +sff_cpld_reg.mode_11_7=config +sff_cpld_reg.src_11_7=cpld +sff_cpld_reg.frmt_11_7=bit +sff_cpld_reg.pola_11_7=positive +sff_cpld_reg.addr_11_7=0x0002007A +sff_cpld_reg.len_11_7=1 +sff_cpld_reg.bit_offset_11_7=2 + +sff_cpld_reg.mode_12_7=config +sff_cpld_reg.src_12_7=cpld +sff_cpld_reg.frmt_12_7=bit +sff_cpld_reg.pola_12_7=positive +sff_cpld_reg.addr_12_7=0x0002007A +sff_cpld_reg.len_12_7=1 +sff_cpld_reg.bit_offset_12_7=3 + +sff_cpld_reg.mode_13_7=config +sff_cpld_reg.src_13_7=cpld +sff_cpld_reg.frmt_13_7=bit +sff_cpld_reg.pola_13_7=positive +sff_cpld_reg.addr_13_7=0x0002007A +sff_cpld_reg.len_13_7=1 +sff_cpld_reg.bit_offset_13_7=4 + +sff_cpld_reg.mode_14_7=config +sff_cpld_reg.src_14_7=cpld +sff_cpld_reg.frmt_14_7=bit +sff_cpld_reg.pola_14_7=positive +sff_cpld_reg.addr_14_7=0x0002007A +sff_cpld_reg.len_14_7=1 +sff_cpld_reg.bit_offset_14_7=5 + +sff_cpld_reg.mode_15_7=config +sff_cpld_reg.src_15_7=cpld +sff_cpld_reg.frmt_15_7=bit +sff_cpld_reg.pola_15_7=positive +sff_cpld_reg.addr_15_7=0x0002007A +sff_cpld_reg.len_15_7=1 +sff_cpld_reg.bit_offset_15_7=6 + +sff_cpld_reg.mode_16_7=config +sff_cpld_reg.src_16_7=cpld +sff_cpld_reg.frmt_16_7=bit +sff_cpld_reg.pola_16_7=positive +sff_cpld_reg.addr_16_7=0x0002007A +sff_cpld_reg.len_16_7=1 +sff_cpld_reg.bit_offset_16_7=7 + +sff_cpld_reg.mode_17_7=config +sff_cpld_reg.src_17_7=cpld +sff_cpld_reg.frmt_17_7=bit +sff_cpld_reg.pola_17_7=positive +sff_cpld_reg.addr_17_7=0x00020079 +sff_cpld_reg.len_17_7=1 +sff_cpld_reg.bit_offset_17_7=0 + +sff_cpld_reg.mode_18_7=config +sff_cpld_reg.src_18_7=cpld +sff_cpld_reg.frmt_18_7=bit +sff_cpld_reg.pola_18_7=positive +sff_cpld_reg.addr_18_7=0x00020079 +sff_cpld_reg.len_18_7=1 +sff_cpld_reg.bit_offset_18_7=1 + +sff_cpld_reg.mode_19_7=config +sff_cpld_reg.src_19_7=cpld +sff_cpld_reg.frmt_19_7=bit +sff_cpld_reg.pola_19_7=positive +sff_cpld_reg.addr_19_7=0x00020079 +sff_cpld_reg.len_19_7=1 +sff_cpld_reg.bit_offset_19_7=2 + +sff_cpld_reg.mode_20_7=config +sff_cpld_reg.src_20_7=cpld +sff_cpld_reg.frmt_20_7=bit +sff_cpld_reg.pola_20_7=positive +sff_cpld_reg.addr_20_7=0x00020079 +sff_cpld_reg.len_20_7=1 +sff_cpld_reg.bit_offset_20_7=3 + +sff_cpld_reg.mode_21_7=config +sff_cpld_reg.src_21_7=cpld +sff_cpld_reg.frmt_21_7=bit +sff_cpld_reg.pola_21_7=positive +sff_cpld_reg.addr_21_7=0x00020079 +sff_cpld_reg.len_21_7=1 +sff_cpld_reg.bit_offset_21_7=4 + +sff_cpld_reg.mode_22_7=config +sff_cpld_reg.src_22_7=cpld +sff_cpld_reg.frmt_22_7=bit +sff_cpld_reg.pola_22_7=positive +sff_cpld_reg.addr_22_7=0x00020079 +sff_cpld_reg.len_22_7=1 +sff_cpld_reg.bit_offset_22_7=5 + +sff_cpld_reg.mode_23_7=config +sff_cpld_reg.src_23_7=cpld +sff_cpld_reg.frmt_23_7=bit +sff_cpld_reg.pola_23_7=positive +sff_cpld_reg.addr_23_7=0x00020079 +sff_cpld_reg.len_23_7=1 +sff_cpld_reg.bit_offset_23_7=6 + +sff_cpld_reg.mode_24_7=config +sff_cpld_reg.src_24_7=cpld +sff_cpld_reg.frmt_24_7=bit +sff_cpld_reg.pola_24_7=positive +sff_cpld_reg.addr_24_7=0x00020079 +sff_cpld_reg.len_24_7=1 +sff_cpld_reg.bit_offset_24_7=7 + +sff_cpld_reg.mode_25_7=config +sff_cpld_reg.src_25_7=cpld +sff_cpld_reg.frmt_25_7=bit +sff_cpld_reg.pola_25_7=positive +sff_cpld_reg.addr_25_7=0x00020078 +sff_cpld_reg.len_25_7=1 +sff_cpld_reg.bit_offset_25_7=0 + +sff_cpld_reg.mode_26_7=config +sff_cpld_reg.src_26_7=cpld +sff_cpld_reg.frmt_26_7=bit +sff_cpld_reg.pola_26_7=positive +sff_cpld_reg.addr_26_7=0x00020078 +sff_cpld_reg.len_26_7=1 +sff_cpld_reg.bit_offset_26_7=1 + +sff_cpld_reg.mode_27_7=config +sff_cpld_reg.src_27_7=cpld +sff_cpld_reg.frmt_27_7=bit +sff_cpld_reg.pola_27_7=positive +sff_cpld_reg.addr_27_7=0x00020078 +sff_cpld_reg.len_27_7=1 +sff_cpld_reg.bit_offset_27_7=2 + +sff_cpld_reg.mode_28_7=config +sff_cpld_reg.src_28_7=cpld +sff_cpld_reg.frmt_28_7=bit +sff_cpld_reg.pola_28_7=positive +sff_cpld_reg.addr_28_7=0x00020078 +sff_cpld_reg.len_28_7=1 +sff_cpld_reg.bit_offset_28_7=3 + +sff_cpld_reg.mode_29_7=config +sff_cpld_reg.src_29_7=cpld +sff_cpld_reg.frmt_29_7=bit +sff_cpld_reg.pola_29_7=positive +sff_cpld_reg.addr_29_7=0x00020078 +sff_cpld_reg.len_29_7=1 +sff_cpld_reg.bit_offset_29_7=4 + +sff_cpld_reg.mode_30_7=config +sff_cpld_reg.src_30_7=cpld +sff_cpld_reg.frmt_30_7=bit +sff_cpld_reg.pola_30_7=positive +sff_cpld_reg.addr_30_7=0x00020078 +sff_cpld_reg.len_30_7=1 +sff_cpld_reg.bit_offset_30_7=5 + +sff_cpld_reg.mode_31_7=config +sff_cpld_reg.src_31_7=cpld +sff_cpld_reg.frmt_31_7=bit +sff_cpld_reg.pola_31_7=positive +sff_cpld_reg.addr_31_7=0x00020078 +sff_cpld_reg.len_31_7=1 +sff_cpld_reg.bit_offset_31_7=6 + +sff_cpld_reg.mode_32_7=config +sff_cpld_reg.src_32_7=cpld +sff_cpld_reg.frmt_32_7=bit +sff_cpld_reg.pola_32_7=positive +sff_cpld_reg.addr_32_7=0x00020078 +sff_cpld_reg.len_32_7=1 +sff_cpld_reg.bit_offset_32_7=7 + +sff_cpld_reg.mode_33_7=config +sff_cpld_reg.src_33_7=cpld +sff_cpld_reg.frmt_33_7=bit +sff_cpld_reg.pola_33_7=positive +sff_cpld_reg.addr_33_7=0x00050078 +sff_cpld_reg.len_33_7=1 +sff_cpld_reg.bit_offset_33_7=0 + +sff_cpld_reg.mode_34_7=config +sff_cpld_reg.src_34_7=cpld +sff_cpld_reg.frmt_34_7=bit +sff_cpld_reg.pola_34_7=positive +sff_cpld_reg.addr_34_7=0x00050078 +sff_cpld_reg.len_34_7=1 +sff_cpld_reg.bit_offset_34_7=1 + +sff_cpld_reg.mode_35_7=config +sff_cpld_reg.src_35_7=cpld +sff_cpld_reg.frmt_35_7=bit +sff_cpld_reg.pola_35_7=positive +sff_cpld_reg.addr_35_7=0x00050078 +sff_cpld_reg.len_35_7=1 +sff_cpld_reg.bit_offset_35_7=2 + +sff_cpld_reg.mode_36_7=config +sff_cpld_reg.src_36_7=cpld +sff_cpld_reg.frmt_36_7=bit +sff_cpld_reg.pola_36_7=positive +sff_cpld_reg.addr_36_7=0x00050078 +sff_cpld_reg.len_36_7=1 +sff_cpld_reg.bit_offset_36_7=3 + +sff_cpld_reg.mode_37_7=config +sff_cpld_reg.src_37_7=cpld +sff_cpld_reg.frmt_37_7=bit +sff_cpld_reg.pola_37_7=positive +sff_cpld_reg.addr_37_7=0x00050077 +sff_cpld_reg.len_37_7=1 +sff_cpld_reg.bit_offset_37_7=0 + +sff_cpld_reg.mode_38_7=config +sff_cpld_reg.src_38_7=cpld +sff_cpld_reg.frmt_38_7=bit +sff_cpld_reg.pola_38_7=positive +sff_cpld_reg.addr_38_7=0x00050077 +sff_cpld_reg.len_38_7=1 +sff_cpld_reg.bit_offset_38_7=1 + +sff_cpld_reg.mode_39_7=config +sff_cpld_reg.src_39_7=cpld +sff_cpld_reg.frmt_39_7=bit +sff_cpld_reg.pola_39_7=positive +sff_cpld_reg.addr_39_7=0x00050077 +sff_cpld_reg.len_39_7=1 +sff_cpld_reg.bit_offset_39_7=2 + +sff_cpld_reg.mode_40_7=config +sff_cpld_reg.src_40_7=cpld +sff_cpld_reg.frmt_40_7=bit +sff_cpld_reg.pola_40_7=positive +sff_cpld_reg.addr_40_7=0x00050077 +sff_cpld_reg.len_40_7=1 +sff_cpld_reg.bit_offset_40_7=3 + +sff_cpld_reg.mode_41_7=config +sff_cpld_reg.src_41_7=cpld +sff_cpld_reg.frmt_41_7=bit +sff_cpld_reg.pola_41_7=positive +sff_cpld_reg.addr_41_7=0x00050077 +sff_cpld_reg.len_41_7=1 +sff_cpld_reg.bit_offset_41_7=4 + +sff_cpld_reg.mode_42_7=config +sff_cpld_reg.src_42_7=cpld +sff_cpld_reg.frmt_42_7=bit +sff_cpld_reg.pola_42_7=positive +sff_cpld_reg.addr_42_7=0x00050077 +sff_cpld_reg.len_42_7=1 +sff_cpld_reg.bit_offset_42_7=5 + +sff_cpld_reg.mode_43_7=config +sff_cpld_reg.src_43_7=cpld +sff_cpld_reg.frmt_43_7=bit +sff_cpld_reg.pola_43_7=positive +sff_cpld_reg.addr_43_7=0x00060085 +sff_cpld_reg.len_43_7=1 +sff_cpld_reg.bit_offset_43_7=0 + +sff_cpld_reg.mode_44_7=config +sff_cpld_reg.src_44_7=cpld +sff_cpld_reg.frmt_44_7=bit +sff_cpld_reg.pola_44_7=positive +sff_cpld_reg.addr_44_7=0x00060085 +sff_cpld_reg.len_44_7=1 +sff_cpld_reg.bit_offset_44_7=1 + +sff_cpld_reg.mode_45_7=config +sff_cpld_reg.src_45_7=cpld +sff_cpld_reg.frmt_45_7=bit +sff_cpld_reg.pola_45_7=positive +sff_cpld_reg.addr_45_7=0x00060085 +sff_cpld_reg.len_45_7=1 +sff_cpld_reg.bit_offset_45_7=2 + +sff_cpld_reg.mode_46_7=config +sff_cpld_reg.src_46_7=cpld +sff_cpld_reg.frmt_46_7=bit +sff_cpld_reg.pola_46_7=positive +sff_cpld_reg.addr_46_7=0x00060085 +sff_cpld_reg.len_46_7=1 +sff_cpld_reg.bit_offset_46_7=3 + +sff_cpld_reg.mode_47_7=config +sff_cpld_reg.src_47_7=cpld +sff_cpld_reg.frmt_47_7=bit +sff_cpld_reg.pola_47_7=positive +sff_cpld_reg.addr_47_7=0x00060085 +sff_cpld_reg.len_47_7=1 +sff_cpld_reg.bit_offset_47_7=4 + +sff_cpld_reg.mode_48_7=config +sff_cpld_reg.src_48_7=cpld +sff_cpld_reg.frmt_48_7=bit +sff_cpld_reg.pola_48_7=positive +sff_cpld_reg.addr_48_7=0x00060085 +sff_cpld_reg.len_48_7=1 +sff_cpld_reg.bit_offset_48_7=5 + +sff_cpld_reg.mode_49_7=config +sff_cpld_reg.src_49_7=cpld +sff_cpld_reg.frmt_49_7=bit +sff_cpld_reg.pola_49_7=positive +sff_cpld_reg.addr_49_7=0x00060084 +sff_cpld_reg.len_49_7=1 +sff_cpld_reg.bit_offset_49_7=0 + +sff_cpld_reg.mode_50_7=config +sff_cpld_reg.src_50_7=cpld +sff_cpld_reg.frmt_50_7=bit +sff_cpld_reg.pola_50_7=positive +sff_cpld_reg.addr_50_7=0x00060084 +sff_cpld_reg.len_50_7=1 +sff_cpld_reg.bit_offset_50_7=1 + +sff_cpld_reg.mode_51_7=config +sff_cpld_reg.src_51_7=cpld +sff_cpld_reg.frmt_51_7=bit +sff_cpld_reg.pola_51_7=positive +sff_cpld_reg.addr_51_7=0x00060084 +sff_cpld_reg.len_51_7=1 +sff_cpld_reg.bit_offset_51_7=2 + +sff_cpld_reg.mode_52_7=config +sff_cpld_reg.src_52_7=cpld +sff_cpld_reg.frmt_52_7=bit +sff_cpld_reg.pola_52_7=positive +sff_cpld_reg.addr_52_7=0x00060084 +sff_cpld_reg.len_52_7=1 +sff_cpld_reg.bit_offset_52_7=3 + +sff_cpld_reg.mode_53_7=config +sff_cpld_reg.src_53_7=cpld +sff_cpld_reg.frmt_53_7=bit +sff_cpld_reg.pola_53_7=positive +sff_cpld_reg.addr_53_7=0x00060084 +sff_cpld_reg.len_53_7=1 +sff_cpld_reg.bit_offset_53_7=4 + +sff_cpld_reg.mode_54_7=config +sff_cpld_reg.src_54_7=cpld +sff_cpld_reg.frmt_54_7=bit +sff_cpld_reg.pola_54_7=positive +sff_cpld_reg.addr_54_7=0x00060084 +sff_cpld_reg.len_54_7=1 +sff_cpld_reg.bit_offset_54_7=5 + +sff_cpld_reg.mode_55_7=config +sff_cpld_reg.src_55_7=cpld +sff_cpld_reg.frmt_55_7=bit +sff_cpld_reg.pola_55_7=positive +sff_cpld_reg.addr_55_7=0x00060084 +sff_cpld_reg.len_55_7=1 +sff_cpld_reg.bit_offset_55_7=6 + +sff_cpld_reg.mode_56_7=config +sff_cpld_reg.src_56_7=cpld +sff_cpld_reg.frmt_56_7=bit +sff_cpld_reg.pola_56_7=positive +sff_cpld_reg.addr_56_7=0x00060084 +sff_cpld_reg.len_56_7=1 +sff_cpld_reg.bit_offset_56_7=7 + +sff_cpld_reg.mode_57_7=config +sff_cpld_reg.src_57_7=cpld +sff_cpld_reg.frmt_57_7=bit +sff_cpld_reg.pola_57_7=positive +sff_cpld_reg.addr_57_7=0x00060083 +sff_cpld_reg.len_57_7=1 +sff_cpld_reg.bit_offset_57_7=0 + +sff_cpld_reg.mode_58_7=config +sff_cpld_reg.src_58_7=cpld +sff_cpld_reg.frmt_58_7=bit +sff_cpld_reg.pola_58_7=positive +sff_cpld_reg.addr_58_7=0x00060083 +sff_cpld_reg.len_58_7=1 +sff_cpld_reg.bit_offset_58_7=1 + +sff_cpld_reg.mode_59_7=config +sff_cpld_reg.src_59_7=cpld +sff_cpld_reg.frmt_59_7=bit +sff_cpld_reg.pola_59_7=positive +sff_cpld_reg.addr_59_7=0x00060083 +sff_cpld_reg.len_59_7=1 +sff_cpld_reg.bit_offset_59_7=2 + +sff_cpld_reg.mode_60_7=config +sff_cpld_reg.src_60_7=cpld +sff_cpld_reg.frmt_60_7=bit +sff_cpld_reg.pola_60_7=positive +sff_cpld_reg.addr_60_7=0x00060083 +sff_cpld_reg.len_60_7=1 +sff_cpld_reg.bit_offset_60_7=3 + +sff_cpld_reg.mode_61_7=config +sff_cpld_reg.src_61_7=cpld +sff_cpld_reg.frmt_61_7=bit +sff_cpld_reg.pola_61_7=positive +sff_cpld_reg.addr_61_7=0x00060083 +sff_cpld_reg.len_61_7=1 +sff_cpld_reg.bit_offset_61_7=4 + +sff_cpld_reg.mode_62_7=config +sff_cpld_reg.src_62_7=cpld +sff_cpld_reg.frmt_62_7=bit +sff_cpld_reg.pola_62_7=positive +sff_cpld_reg.addr_62_7=0x00060083 +sff_cpld_reg.len_62_7=1 +sff_cpld_reg.bit_offset_62_7=5 + +sff_cpld_reg.mode_63_7=config +sff_cpld_reg.src_63_7=cpld +sff_cpld_reg.frmt_63_7=bit +sff_cpld_reg.pola_63_7=positive +sff_cpld_reg.addr_63_7=0x00060083 +sff_cpld_reg.len_63_7=1 +sff_cpld_reg.bit_offset_63_7=6 + +sff_cpld_reg.mode_64_7=config +sff_cpld_reg.src_64_7=cpld +sff_cpld_reg.frmt_64_7=bit +sff_cpld_reg.pola_64_7=positive +sff_cpld_reg.addr_64_7=0x00060083 +sff_cpld_reg.len_64_7=1 +sff_cpld_reg.bit_offset_64_7=7 + +sff_cpld_reg.mode_65_7=config +sff_cpld_reg.src_65_7=cpld +sff_cpld_reg.frmt_65_7=bit +sff_cpld_reg.pola_65_7=positive +sff_cpld_reg.addr_65_7=0x00050077 +sff_cpld_reg.len_65_7=1 +sff_cpld_reg.bit_offset_65_7=6 + +sff_cpld_reg.mode_66_7=config +sff_cpld_reg.src_66_7=cpld +sff_cpld_reg.frmt_66_7=bit +sff_cpld_reg.pola_66_7=positive +sff_cpld_reg.addr_66_7=0x00050077 +sff_cpld_reg.len_66_7=1 +sff_cpld_reg.bit_offset_66_7=7 + +sff_cpld_reg.mode_67_7=config +sff_cpld_reg.src_67_7=cpld +sff_cpld_reg.frmt_67_7=bit +sff_cpld_reg.pola_67_7=positive +sff_cpld_reg.addr_67_7=0x00050076 +sff_cpld_reg.len_67_7=1 +sff_cpld_reg.bit_offset_67_7=0 + +sff_cpld_reg.mode_68_7=config +sff_cpld_reg.src_68_7=cpld +sff_cpld_reg.frmt_68_7=bit +sff_cpld_reg.pola_68_7=positive +sff_cpld_reg.addr_68_7=0x00050076 +sff_cpld_reg.len_68_7=1 +sff_cpld_reg.bit_offset_68_7=1 + +sff_cpld_reg.mode_69_7=config +sff_cpld_reg.src_69_7=cpld +sff_cpld_reg.frmt_69_7=bit +sff_cpld_reg.pola_69_7=positive +sff_cpld_reg.addr_69_7=0x00050076 +sff_cpld_reg.len_69_7=1 +sff_cpld_reg.bit_offset_69_7=2 + +sff_cpld_reg.mode_70_7=config +sff_cpld_reg.src_70_7=cpld +sff_cpld_reg.frmt_70_7=bit +sff_cpld_reg.pola_70_7=positive +sff_cpld_reg.addr_70_7=0x00050076 +sff_cpld_reg.len_70_7=1 +sff_cpld_reg.bit_offset_70_7=3 + +sff_cpld_reg.mode_71_7=config +sff_cpld_reg.src_71_7=cpld +sff_cpld_reg.frmt_71_7=bit +sff_cpld_reg.pola_71_7=positive +sff_cpld_reg.addr_71_7=0x00050076 +sff_cpld_reg.len_71_7=1 +sff_cpld_reg.bit_offset_71_7=4 + +sff_cpld_reg.mode_72_7=config +sff_cpld_reg.src_72_7=cpld +sff_cpld_reg.frmt_72_7=bit +sff_cpld_reg.pola_72_7=positive +sff_cpld_reg.addr_72_7=0x00050076 +sff_cpld_reg.len_72_7=1 +sff_cpld_reg.bit_offset_72_7=5 + +sff_cpld_reg.mode_73_7=config +sff_cpld_reg.src_73_7=cpld +sff_cpld_reg.frmt_73_7=bit +sff_cpld_reg.pola_73_7=positive +sff_cpld_reg.addr_73_7=0x00050076 +sff_cpld_reg.len_73_7=1 +sff_cpld_reg.bit_offset_73_7=6 + +sff_cpld_reg.mode_74_7=config +sff_cpld_reg.src_74_7=cpld +sff_cpld_reg.frmt_74_7=bit +sff_cpld_reg.pola_74_7=positive +sff_cpld_reg.addr_74_7=0x00050076 +sff_cpld_reg.len_74_7=1 +sff_cpld_reg.bit_offset_74_7=7 + +sff_cpld_reg.mode_75_7=config +sff_cpld_reg.src_75_7=cpld +sff_cpld_reg.frmt_75_7=bit +sff_cpld_reg.pola_75_7=positive +sff_cpld_reg.addr_75_7=0x00060082 +sff_cpld_reg.len_75_7=1 +sff_cpld_reg.bit_offset_75_7=0 + +sff_cpld_reg.mode_76_7=config +sff_cpld_reg.src_76_7=cpld +sff_cpld_reg.frmt_76_7=bit +sff_cpld_reg.pola_76_7=positive +sff_cpld_reg.addr_76_7=0x00060082 +sff_cpld_reg.len_76_7=1 +sff_cpld_reg.bit_offset_76_7=1 + +sff_cpld_reg.mode_77_7=config +sff_cpld_reg.src_77_7=cpld +sff_cpld_reg.frmt_77_7=bit +sff_cpld_reg.pola_77_7=positive +sff_cpld_reg.addr_77_7=0x00060082 +sff_cpld_reg.len_77_7=1 +sff_cpld_reg.bit_offset_77_7=2 + +sff_cpld_reg.mode_78_7=config +sff_cpld_reg.src_78_7=cpld +sff_cpld_reg.frmt_78_7=bit +sff_cpld_reg.pola_78_7=positive +sff_cpld_reg.addr_78_7=0x00060082 +sff_cpld_reg.len_78_7=1 +sff_cpld_reg.bit_offset_78_7=3 + +sff_cpld_reg.mode_79_7=config +sff_cpld_reg.src_79_7=cpld +sff_cpld_reg.frmt_79_7=bit +sff_cpld_reg.pola_79_7=positive +sff_cpld_reg.addr_79_7=0x00060082 +sff_cpld_reg.len_79_7=1 +sff_cpld_reg.bit_offset_79_7=4 + +sff_cpld_reg.mode_80_7=config +sff_cpld_reg.src_80_7=cpld +sff_cpld_reg.frmt_80_7=bit +sff_cpld_reg.pola_80_7=positive +sff_cpld_reg.addr_80_7=0x00060082 +sff_cpld_reg.len_80_7=1 +sff_cpld_reg.bit_offset_80_7=5 + +sff_cpld_reg.mode_81_7=config +sff_cpld_reg.src_81_7=cpld +sff_cpld_reg.frmt_81_7=bit +sff_cpld_reg.pola_81_7=positive +sff_cpld_reg.addr_81_7=0x00060081 +sff_cpld_reg.len_81_7=1 +sff_cpld_reg.bit_offset_81_7=0 + +sff_cpld_reg.mode_82_7=config +sff_cpld_reg.src_82_7=cpld +sff_cpld_reg.frmt_82_7=bit +sff_cpld_reg.pola_82_7=positive +sff_cpld_reg.addr_82_7=0x00060081 +sff_cpld_reg.len_82_7=1 +sff_cpld_reg.bit_offset_82_7=1 + +sff_cpld_reg.mode_83_7=config +sff_cpld_reg.src_83_7=cpld +sff_cpld_reg.frmt_83_7=bit +sff_cpld_reg.pola_83_7=positive +sff_cpld_reg.addr_83_7=0x00060081 +sff_cpld_reg.len_83_7=1 +sff_cpld_reg.bit_offset_83_7=2 + +sff_cpld_reg.mode_84_7=config +sff_cpld_reg.src_84_7=cpld +sff_cpld_reg.frmt_84_7=bit +sff_cpld_reg.pola_84_7=positive +sff_cpld_reg.addr_84_7=0x00060081 +sff_cpld_reg.len_84_7=1 +sff_cpld_reg.bit_offset_84_7=3 + +sff_cpld_reg.mode_85_7=config +sff_cpld_reg.src_85_7=cpld +sff_cpld_reg.frmt_85_7=bit +sff_cpld_reg.pola_85_7=positive +sff_cpld_reg.addr_85_7=0x00060081 +sff_cpld_reg.len_85_7=1 +sff_cpld_reg.bit_offset_85_7=4 + +sff_cpld_reg.mode_86_7=config +sff_cpld_reg.src_86_7=cpld +sff_cpld_reg.frmt_86_7=bit +sff_cpld_reg.pola_86_7=positive +sff_cpld_reg.addr_86_7=0x00060081 +sff_cpld_reg.len_86_7=1 +sff_cpld_reg.bit_offset_86_7=5 + +sff_cpld_reg.mode_87_7=config +sff_cpld_reg.src_87_7=cpld +sff_cpld_reg.frmt_87_7=bit +sff_cpld_reg.pola_87_7=positive +sff_cpld_reg.addr_87_7=0x00060081 +sff_cpld_reg.len_87_7=1 +sff_cpld_reg.bit_offset_87_7=6 + +sff_cpld_reg.mode_88_7=config +sff_cpld_reg.src_88_7=cpld +sff_cpld_reg.frmt_88_7=bit +sff_cpld_reg.pola_88_7=positive +sff_cpld_reg.addr_88_7=0x00060081 +sff_cpld_reg.len_88_7=1 +sff_cpld_reg.bit_offset_88_7=7 + +sff_cpld_reg.mode_89_7=config +sff_cpld_reg.src_89_7=cpld +sff_cpld_reg.frmt_89_7=bit +sff_cpld_reg.pola_89_7=positive +sff_cpld_reg.addr_89_7=0x00060080 +sff_cpld_reg.len_89_7=1 +sff_cpld_reg.bit_offset_89_7=0 + +sff_cpld_reg.mode_90_7=config +sff_cpld_reg.src_90_7=cpld +sff_cpld_reg.frmt_90_7=bit +sff_cpld_reg.pola_90_7=positive +sff_cpld_reg.addr_90_7=0x00060080 +sff_cpld_reg.len_90_7=1 +sff_cpld_reg.bit_offset_90_7=1 + +sff_cpld_reg.mode_91_7=config +sff_cpld_reg.src_91_7=cpld +sff_cpld_reg.frmt_91_7=bit +sff_cpld_reg.pola_91_7=positive +sff_cpld_reg.addr_91_7=0x00060080 +sff_cpld_reg.len_91_7=1 +sff_cpld_reg.bit_offset_91_7=2 + +sff_cpld_reg.mode_92_7=config +sff_cpld_reg.src_92_7=cpld +sff_cpld_reg.frmt_92_7=bit +sff_cpld_reg.pola_92_7=positive +sff_cpld_reg.addr_92_7=0x00060080 +sff_cpld_reg.len_92_7=1 +sff_cpld_reg.bit_offset_92_7=3 + +sff_cpld_reg.mode_93_7=config +sff_cpld_reg.src_93_7=cpld +sff_cpld_reg.frmt_93_7=bit +sff_cpld_reg.pola_93_7=positive +sff_cpld_reg.addr_93_7=0x00060080 +sff_cpld_reg.len_93_7=1 +sff_cpld_reg.bit_offset_93_7=4 + +sff_cpld_reg.mode_94_7=config +sff_cpld_reg.src_94_7=cpld +sff_cpld_reg.frmt_94_7=bit +sff_cpld_reg.pola_94_7=positive +sff_cpld_reg.addr_94_7=0x00060080 +sff_cpld_reg.len_94_7=1 +sff_cpld_reg.bit_offset_94_7=5 + +sff_cpld_reg.mode_95_7=config +sff_cpld_reg.src_95_7=cpld +sff_cpld_reg.frmt_95_7=bit +sff_cpld_reg.pola_95_7=positive +sff_cpld_reg.addr_95_7=0x00060080 +sff_cpld_reg.len_95_7=1 +sff_cpld_reg.bit_offset_95_7=6 + +sff_cpld_reg.mode_96_7=config +sff_cpld_reg.src_96_7=cpld +sff_cpld_reg.frmt_96_7=bit +sff_cpld_reg.pola_96_7=positive +sff_cpld_reg.addr_96_7=0x00060080 +sff_cpld_reg.len_96_7=1 +sff_cpld_reg.bit_offset_96_7=7 + +sff_cpld_reg.mode_97_7=config +sff_cpld_reg.src_97_7=cpld +sff_cpld_reg.frmt_97_7=bit +sff_cpld_reg.pola_97_7=positive +sff_cpld_reg.addr_97_7=0x0007007B +sff_cpld_reg.len_97_7=1 +sff_cpld_reg.bit_offset_97_7=0 + +sff_cpld_reg.mode_98_7=config +sff_cpld_reg.src_98_7=cpld +sff_cpld_reg.frmt_98_7=bit +sff_cpld_reg.pola_98_7=positive +sff_cpld_reg.addr_98_7=0x0007007B +sff_cpld_reg.len_98_7=1 +sff_cpld_reg.bit_offset_98_7=1 + +sff_cpld_reg.mode_99_7=config +sff_cpld_reg.src_99_7=cpld +sff_cpld_reg.frmt_99_7=bit +sff_cpld_reg.pola_99_7=positive +sff_cpld_reg.addr_99_7=0x0007007B +sff_cpld_reg.len_99_7=1 +sff_cpld_reg.bit_offset_99_7=2 + +sff_cpld_reg.mode_100_7=config +sff_cpld_reg.src_100_7=cpld +sff_cpld_reg.frmt_100_7=bit +sff_cpld_reg.pola_100_7=positive +sff_cpld_reg.addr_100_7=0x0007007B +sff_cpld_reg.len_100_7=1 +sff_cpld_reg.bit_offset_100_7=3 + +sff_cpld_reg.mode_101_7=config +sff_cpld_reg.src_101_7=cpld +sff_cpld_reg.frmt_101_7=bit +sff_cpld_reg.pola_101_7=positive +sff_cpld_reg.addr_101_7=0x0007007B +sff_cpld_reg.len_101_7=1 +sff_cpld_reg.bit_offset_101_7=4 + +sff_cpld_reg.mode_102_7=config +sff_cpld_reg.src_102_7=cpld +sff_cpld_reg.frmt_102_7=bit +sff_cpld_reg.pola_102_7=positive +sff_cpld_reg.addr_102_7=0x0007007B +sff_cpld_reg.len_102_7=1 +sff_cpld_reg.bit_offset_102_7=5 + +sff_cpld_reg.mode_103_7=config +sff_cpld_reg.src_103_7=cpld +sff_cpld_reg.frmt_103_7=bit +sff_cpld_reg.pola_103_7=positive +sff_cpld_reg.addr_103_7=0x0007007B +sff_cpld_reg.len_103_7=1 +sff_cpld_reg.bit_offset_103_7=6 + +sff_cpld_reg.mode_104_7=config +sff_cpld_reg.src_104_7=cpld +sff_cpld_reg.frmt_104_7=bit +sff_cpld_reg.pola_104_7=positive +sff_cpld_reg.addr_104_7=0x0007007B +sff_cpld_reg.len_104_7=1 +sff_cpld_reg.bit_offset_104_7=7 + +sff_cpld_reg.mode_105_7=config +sff_cpld_reg.src_105_7=cpld +sff_cpld_reg.frmt_105_7=bit +sff_cpld_reg.pola_105_7=positive +sff_cpld_reg.addr_105_7=0x0007007A +sff_cpld_reg.len_105_7=1 +sff_cpld_reg.bit_offset_105_7=0 + +sff_cpld_reg.mode_106_7=config +sff_cpld_reg.src_106_7=cpld +sff_cpld_reg.frmt_106_7=bit +sff_cpld_reg.pola_106_7=positive +sff_cpld_reg.addr_106_7=0x0007007A +sff_cpld_reg.len_106_7=1 +sff_cpld_reg.bit_offset_106_7=1 + +sff_cpld_reg.mode_107_7=config +sff_cpld_reg.src_107_7=cpld +sff_cpld_reg.frmt_107_7=bit +sff_cpld_reg.pola_107_7=positive +sff_cpld_reg.addr_107_7=0x0007007A +sff_cpld_reg.len_107_7=1 +sff_cpld_reg.bit_offset_107_7=2 + +sff_cpld_reg.mode_108_7=config +sff_cpld_reg.src_108_7=cpld +sff_cpld_reg.frmt_108_7=bit +sff_cpld_reg.pola_108_7=positive +sff_cpld_reg.addr_108_7=0x0007007A +sff_cpld_reg.len_108_7=1 +sff_cpld_reg.bit_offset_108_7=3 + +sff_cpld_reg.mode_109_7=config +sff_cpld_reg.src_109_7=cpld +sff_cpld_reg.frmt_109_7=bit +sff_cpld_reg.pola_109_7=positive +sff_cpld_reg.addr_109_7=0x0007007A +sff_cpld_reg.len_109_7=1 +sff_cpld_reg.bit_offset_109_7=4 + +sff_cpld_reg.mode_110_7=config +sff_cpld_reg.src_110_7=cpld +sff_cpld_reg.frmt_110_7=bit +sff_cpld_reg.pola_110_7=positive +sff_cpld_reg.addr_110_7=0x0007007A +sff_cpld_reg.len_110_7=1 +sff_cpld_reg.bit_offset_110_7=5 + +sff_cpld_reg.mode_111_7=config +sff_cpld_reg.src_111_7=cpld +sff_cpld_reg.frmt_111_7=bit +sff_cpld_reg.pola_111_7=positive +sff_cpld_reg.addr_111_7=0x0007007A +sff_cpld_reg.len_111_7=1 +sff_cpld_reg.bit_offset_111_7=6 + +sff_cpld_reg.mode_112_7=config +sff_cpld_reg.src_112_7=cpld +sff_cpld_reg.frmt_112_7=bit +sff_cpld_reg.pola_112_7=positive +sff_cpld_reg.addr_112_7=0x0007007A +sff_cpld_reg.len_112_7=1 +sff_cpld_reg.bit_offset_112_7=7 + +sff_cpld_reg.mode_113_7=config +sff_cpld_reg.src_113_7=cpld +sff_cpld_reg.frmt_113_7=bit +sff_cpld_reg.pola_113_7=positive +sff_cpld_reg.addr_113_7=0x00070079 +sff_cpld_reg.len_113_7=1 +sff_cpld_reg.bit_offset_113_7=0 + +sff_cpld_reg.mode_114_7=config +sff_cpld_reg.src_114_7=cpld +sff_cpld_reg.frmt_114_7=bit +sff_cpld_reg.pola_114_7=positive +sff_cpld_reg.addr_114_7=0x00070079 +sff_cpld_reg.len_114_7=1 +sff_cpld_reg.bit_offset_114_7=1 + +sff_cpld_reg.mode_115_7=config +sff_cpld_reg.src_115_7=cpld +sff_cpld_reg.frmt_115_7=bit +sff_cpld_reg.pola_115_7=positive +sff_cpld_reg.addr_115_7=0x00070079 +sff_cpld_reg.len_115_7=1 +sff_cpld_reg.bit_offset_115_7=2 + +sff_cpld_reg.mode_116_7=config +sff_cpld_reg.src_116_7=cpld +sff_cpld_reg.frmt_116_7=bit +sff_cpld_reg.pola_116_7=positive +sff_cpld_reg.addr_116_7=0x00070079 +sff_cpld_reg.len_116_7=1 +sff_cpld_reg.bit_offset_116_7=3 + +sff_cpld_reg.mode_117_7=config +sff_cpld_reg.src_117_7=cpld +sff_cpld_reg.frmt_117_7=bit +sff_cpld_reg.pola_117_7=positive +sff_cpld_reg.addr_117_7=0x00070079 +sff_cpld_reg.len_117_7=1 +sff_cpld_reg.bit_offset_117_7=4 + +sff_cpld_reg.mode_118_7=config +sff_cpld_reg.src_118_7=cpld +sff_cpld_reg.frmt_118_7=bit +sff_cpld_reg.pola_118_7=positive +sff_cpld_reg.addr_118_7=0x00070079 +sff_cpld_reg.len_118_7=1 +sff_cpld_reg.bit_offset_118_7=5 + +sff_cpld_reg.mode_119_7=config +sff_cpld_reg.src_119_7=cpld +sff_cpld_reg.frmt_119_7=bit +sff_cpld_reg.pola_119_7=positive +sff_cpld_reg.addr_119_7=0x00070079 +sff_cpld_reg.len_119_7=1 +sff_cpld_reg.bit_offset_119_7=6 + +sff_cpld_reg.mode_120_7=config +sff_cpld_reg.src_120_7=cpld +sff_cpld_reg.frmt_120_7=bit +sff_cpld_reg.pola_120_7=positive +sff_cpld_reg.addr_120_7=0x00070079 +sff_cpld_reg.len_120_7=1 +sff_cpld_reg.bit_offset_120_7=7 + +sff_cpld_reg.mode_121_7=config +sff_cpld_reg.src_121_7=cpld +sff_cpld_reg.frmt_121_7=bit +sff_cpld_reg.pola_121_7=positive +sff_cpld_reg.addr_121_7=0x00070078 +sff_cpld_reg.len_121_7=1 +sff_cpld_reg.bit_offset_121_7=0 + +sff_cpld_reg.mode_122_7=config +sff_cpld_reg.src_122_7=cpld +sff_cpld_reg.frmt_122_7=bit +sff_cpld_reg.pola_122_7=positive +sff_cpld_reg.addr_122_7=0x00070078 +sff_cpld_reg.len_122_7=1 +sff_cpld_reg.bit_offset_122_7=1 + +sff_cpld_reg.mode_123_7=config +sff_cpld_reg.src_123_7=cpld +sff_cpld_reg.frmt_123_7=bit +sff_cpld_reg.pola_123_7=positive +sff_cpld_reg.addr_123_7=0x00070078 +sff_cpld_reg.len_123_7=1 +sff_cpld_reg.bit_offset_123_7=2 + +sff_cpld_reg.mode_124_7=config +sff_cpld_reg.src_124_7=cpld +sff_cpld_reg.frmt_124_7=bit +sff_cpld_reg.pola_124_7=positive +sff_cpld_reg.addr_124_7=0x00070078 +sff_cpld_reg.len_124_7=1 +sff_cpld_reg.bit_offset_124_7=3 + +sff_cpld_reg.mode_125_7=config +sff_cpld_reg.src_125_7=cpld +sff_cpld_reg.frmt_125_7=bit +sff_cpld_reg.pola_125_7=positive +sff_cpld_reg.addr_125_7=0x00070078 +sff_cpld_reg.len_125_7=1 +sff_cpld_reg.bit_offset_125_7=4 + +sff_cpld_reg.mode_126_7=config +sff_cpld_reg.src_126_7=cpld +sff_cpld_reg.frmt_126_7=bit +sff_cpld_reg.pola_126_7=positive +sff_cpld_reg.addr_126_7=0x00070078 +sff_cpld_reg.len_126_7=1 +sff_cpld_reg.bit_offset_126_7=5 + +sff_cpld_reg.mode_127_7=config +sff_cpld_reg.src_127_7=cpld +sff_cpld_reg.frmt_127_7=bit +sff_cpld_reg.pola_127_7=positive +sff_cpld_reg.addr_127_7=0x00070078 +sff_cpld_reg.len_127_7=1 +sff_cpld_reg.bit_offset_127_7=6 + +sff_cpld_reg.mode_128_7=config +sff_cpld_reg.src_128_7=cpld +sff_cpld_reg.frmt_128_7=bit +sff_cpld_reg.pola_128_7=positive +sff_cpld_reg.addr_128_7=0x00070078 +sff_cpld_reg.len_128_7=1 +sff_cpld_reg.bit_offset_128_7=7 + +sff_cpld_reg.mode_1_8=config +sff_cpld_reg.src_1_8=cpld +sff_cpld_reg.frmt_1_8=bit +sff_cpld_reg.pola_1_8=negative +sff_cpld_reg.addr_1_8=0x00020077 +sff_cpld_reg.len_1_8=1 +sff_cpld_reg.bit_offset_1_8=0 + +sff_cpld_reg.mode_2_8=config +sff_cpld_reg.src_2_8=cpld +sff_cpld_reg.frmt_2_8=bit +sff_cpld_reg.pola_2_8=negative +sff_cpld_reg.addr_2_8=0x00020077 +sff_cpld_reg.len_2_8=1 +sff_cpld_reg.bit_offset_2_8=1 + +sff_cpld_reg.mode_3_8=config +sff_cpld_reg.src_3_8=cpld +sff_cpld_reg.frmt_3_8=bit +sff_cpld_reg.pola_3_8=negative +sff_cpld_reg.addr_3_8=0x00020077 +sff_cpld_reg.len_3_8=1 +sff_cpld_reg.bit_offset_3_8=2 + +sff_cpld_reg.mode_4_8=config +sff_cpld_reg.src_4_8=cpld +sff_cpld_reg.frmt_4_8=bit +sff_cpld_reg.pola_4_8=negative +sff_cpld_reg.addr_4_8=0x00020077 +sff_cpld_reg.len_4_8=1 +sff_cpld_reg.bit_offset_4_8=3 + +sff_cpld_reg.mode_5_8=config +sff_cpld_reg.src_5_8=cpld +sff_cpld_reg.frmt_5_8=bit +sff_cpld_reg.pola_5_8=negative +sff_cpld_reg.addr_5_8=0x00020077 +sff_cpld_reg.len_5_8=1 +sff_cpld_reg.bit_offset_5_8=4 + +sff_cpld_reg.mode_6_8=config +sff_cpld_reg.src_6_8=cpld +sff_cpld_reg.frmt_6_8=bit +sff_cpld_reg.pola_6_8=negative +sff_cpld_reg.addr_6_8=0x00020077 +sff_cpld_reg.len_6_8=1 +sff_cpld_reg.bit_offset_6_8=5 + +sff_cpld_reg.mode_7_8=config +sff_cpld_reg.src_7_8=cpld +sff_cpld_reg.frmt_7_8=bit +sff_cpld_reg.pola_7_8=negative +sff_cpld_reg.addr_7_8=0x00020077 +sff_cpld_reg.len_7_8=1 +sff_cpld_reg.bit_offset_7_8=6 + +sff_cpld_reg.mode_8_8=config +sff_cpld_reg.src_8_8=cpld +sff_cpld_reg.frmt_8_8=bit +sff_cpld_reg.pola_8_8=negative +sff_cpld_reg.addr_8_8=0x00020077 +sff_cpld_reg.len_8_8=1 +sff_cpld_reg.bit_offset_8_8=7 + +sff_cpld_reg.mode_9_8=config +sff_cpld_reg.src_9_8=cpld +sff_cpld_reg.frmt_9_8=bit +sff_cpld_reg.pola_9_8=negative +sff_cpld_reg.addr_9_8=0x00020076 +sff_cpld_reg.len_9_8=1 +sff_cpld_reg.bit_offset_9_8=0 + +sff_cpld_reg.mode_10_8=config +sff_cpld_reg.src_10_8=cpld +sff_cpld_reg.frmt_10_8=bit +sff_cpld_reg.pola_10_8=negative +sff_cpld_reg.addr_10_8=0x00020076 +sff_cpld_reg.len_10_8=1 +sff_cpld_reg.bit_offset_10_8=1 + +sff_cpld_reg.mode_11_8=config +sff_cpld_reg.src_11_8=cpld +sff_cpld_reg.frmt_11_8=bit +sff_cpld_reg.pola_11_8=negative +sff_cpld_reg.addr_11_8=0x00020076 +sff_cpld_reg.len_11_8=1 +sff_cpld_reg.bit_offset_11_8=2 + +sff_cpld_reg.mode_12_8=config +sff_cpld_reg.src_12_8=cpld +sff_cpld_reg.frmt_12_8=bit +sff_cpld_reg.pola_12_8=negative +sff_cpld_reg.addr_12_8=0x00020076 +sff_cpld_reg.len_12_8=1 +sff_cpld_reg.bit_offset_12_8=3 + +sff_cpld_reg.mode_13_8=config +sff_cpld_reg.src_13_8=cpld +sff_cpld_reg.frmt_13_8=bit +sff_cpld_reg.pola_13_8=negative +sff_cpld_reg.addr_13_8=0x00020076 +sff_cpld_reg.len_13_8=1 +sff_cpld_reg.bit_offset_13_8=4 + +sff_cpld_reg.mode_14_8=config +sff_cpld_reg.src_14_8=cpld +sff_cpld_reg.frmt_14_8=bit +sff_cpld_reg.pola_14_8=negative +sff_cpld_reg.addr_14_8=0x00020076 +sff_cpld_reg.len_14_8=1 +sff_cpld_reg.bit_offset_14_8=5 + +sff_cpld_reg.mode_15_8=config +sff_cpld_reg.src_15_8=cpld +sff_cpld_reg.frmt_15_8=bit +sff_cpld_reg.pola_15_8=negative +sff_cpld_reg.addr_15_8=0x00020076 +sff_cpld_reg.len_15_8=1 +sff_cpld_reg.bit_offset_15_8=6 + +sff_cpld_reg.mode_16_8=config +sff_cpld_reg.src_16_8=cpld +sff_cpld_reg.frmt_16_8=bit +sff_cpld_reg.pola_16_8=negative +sff_cpld_reg.addr_16_8=0x00020076 +sff_cpld_reg.len_16_8=1 +sff_cpld_reg.bit_offset_16_8=7 + +sff_cpld_reg.mode_17_8=config +sff_cpld_reg.src_17_8=cpld +sff_cpld_reg.frmt_17_8=bit +sff_cpld_reg.pola_17_8=negative +sff_cpld_reg.addr_17_8=0x00020075 +sff_cpld_reg.len_17_8=1 +sff_cpld_reg.bit_offset_17_8=0 + +sff_cpld_reg.mode_18_8=config +sff_cpld_reg.src_18_8=cpld +sff_cpld_reg.frmt_18_8=bit +sff_cpld_reg.pola_18_8=negative +sff_cpld_reg.addr_18_8=0x00020075 +sff_cpld_reg.len_18_8=1 +sff_cpld_reg.bit_offset_18_8=1 + +sff_cpld_reg.mode_19_8=config +sff_cpld_reg.src_19_8=cpld +sff_cpld_reg.frmt_19_8=bit +sff_cpld_reg.pola_19_8=negative +sff_cpld_reg.addr_19_8=0x00020075 +sff_cpld_reg.len_19_8=1 +sff_cpld_reg.bit_offset_19_8=2 + +sff_cpld_reg.mode_20_8=config +sff_cpld_reg.src_20_8=cpld +sff_cpld_reg.frmt_20_8=bit +sff_cpld_reg.pola_20_8=negative +sff_cpld_reg.addr_20_8=0x00020075 +sff_cpld_reg.len_20_8=1 +sff_cpld_reg.bit_offset_20_8=3 + +sff_cpld_reg.mode_21_8=config +sff_cpld_reg.src_21_8=cpld +sff_cpld_reg.frmt_21_8=bit +sff_cpld_reg.pola_21_8=negative +sff_cpld_reg.addr_21_8=0x00020075 +sff_cpld_reg.len_21_8=1 +sff_cpld_reg.bit_offset_21_8=4 + +sff_cpld_reg.mode_22_8=config +sff_cpld_reg.src_22_8=cpld +sff_cpld_reg.frmt_22_8=bit +sff_cpld_reg.pola_22_8=negative +sff_cpld_reg.addr_22_8=0x00020075 +sff_cpld_reg.len_22_8=1 +sff_cpld_reg.bit_offset_22_8=5 + +sff_cpld_reg.mode_23_8=config +sff_cpld_reg.src_23_8=cpld +sff_cpld_reg.frmt_23_8=bit +sff_cpld_reg.pola_23_8=negative +sff_cpld_reg.addr_23_8=0x00020075 +sff_cpld_reg.len_23_8=1 +sff_cpld_reg.bit_offset_23_8=6 + +sff_cpld_reg.mode_24_8=config +sff_cpld_reg.src_24_8=cpld +sff_cpld_reg.frmt_24_8=bit +sff_cpld_reg.pola_24_8=negative +sff_cpld_reg.addr_24_8=0x00020075 +sff_cpld_reg.len_24_8=1 +sff_cpld_reg.bit_offset_24_8=7 + +sff_cpld_reg.mode_25_8=config +sff_cpld_reg.src_25_8=cpld +sff_cpld_reg.frmt_25_8=bit +sff_cpld_reg.pola_25_8=negative +sff_cpld_reg.addr_25_8=0x00020074 +sff_cpld_reg.len_25_8=1 +sff_cpld_reg.bit_offset_25_8=0 + +sff_cpld_reg.mode_26_8=config +sff_cpld_reg.src_26_8=cpld +sff_cpld_reg.frmt_26_8=bit +sff_cpld_reg.pola_26_8=negative +sff_cpld_reg.addr_26_8=0x00020074 +sff_cpld_reg.len_26_8=1 +sff_cpld_reg.bit_offset_26_8=1 + +sff_cpld_reg.mode_27_8=config +sff_cpld_reg.src_27_8=cpld +sff_cpld_reg.frmt_27_8=bit +sff_cpld_reg.pola_27_8=negative +sff_cpld_reg.addr_27_8=0x00020074 +sff_cpld_reg.len_27_8=1 +sff_cpld_reg.bit_offset_27_8=2 + +sff_cpld_reg.mode_28_8=config +sff_cpld_reg.src_28_8=cpld +sff_cpld_reg.frmt_28_8=bit +sff_cpld_reg.pola_28_8=negative +sff_cpld_reg.addr_28_8=0x00020074 +sff_cpld_reg.len_28_8=1 +sff_cpld_reg.bit_offset_28_8=3 + +sff_cpld_reg.mode_29_8=config +sff_cpld_reg.src_29_8=cpld +sff_cpld_reg.frmt_29_8=bit +sff_cpld_reg.pola_29_8=negative +sff_cpld_reg.addr_29_8=0x00020074 +sff_cpld_reg.len_29_8=1 +sff_cpld_reg.bit_offset_29_8=4 + +sff_cpld_reg.mode_30_8=config +sff_cpld_reg.src_30_8=cpld +sff_cpld_reg.frmt_30_8=bit +sff_cpld_reg.pola_30_8=negative +sff_cpld_reg.addr_30_8=0x00020074 +sff_cpld_reg.len_30_8=1 +sff_cpld_reg.bit_offset_30_8=5 + +sff_cpld_reg.mode_31_8=config +sff_cpld_reg.src_31_8=cpld +sff_cpld_reg.frmt_31_8=bit +sff_cpld_reg.pola_31_8=negative +sff_cpld_reg.addr_31_8=0x00020074 +sff_cpld_reg.len_31_8=1 +sff_cpld_reg.bit_offset_31_8=6 + +sff_cpld_reg.mode_32_8=config +sff_cpld_reg.src_32_8=cpld +sff_cpld_reg.frmt_32_8=bit +sff_cpld_reg.pola_32_8=negative +sff_cpld_reg.addr_32_8=0x00020074 +sff_cpld_reg.len_32_8=1 +sff_cpld_reg.bit_offset_32_8=7 + +sff_cpld_reg.mode_33_8=config +sff_cpld_reg.src_33_8=cpld +sff_cpld_reg.frmt_33_8=bit +sff_cpld_reg.pola_33_8=negative +sff_cpld_reg.addr_33_8=0x00050075 +sff_cpld_reg.len_33_8=1 +sff_cpld_reg.bit_offset_33_8=0 + +sff_cpld_reg.mode_34_8=config +sff_cpld_reg.src_34_8=cpld +sff_cpld_reg.frmt_34_8=bit +sff_cpld_reg.pola_34_8=negative +sff_cpld_reg.addr_34_8=0x00050075 +sff_cpld_reg.len_34_8=1 +sff_cpld_reg.bit_offset_34_8=1 + +sff_cpld_reg.mode_35_8=config +sff_cpld_reg.src_35_8=cpld +sff_cpld_reg.frmt_35_8=bit +sff_cpld_reg.pola_35_8=negative +sff_cpld_reg.addr_35_8=0x00050075 +sff_cpld_reg.len_35_8=1 +sff_cpld_reg.bit_offset_35_8=2 + +sff_cpld_reg.mode_36_8=config +sff_cpld_reg.src_36_8=cpld +sff_cpld_reg.frmt_36_8=bit +sff_cpld_reg.pola_36_8=negative +sff_cpld_reg.addr_36_8=0x00050075 +sff_cpld_reg.len_36_8=1 +sff_cpld_reg.bit_offset_36_8=3 + +sff_cpld_reg.mode_37_8=config +sff_cpld_reg.src_37_8=cpld +sff_cpld_reg.frmt_37_8=bit +sff_cpld_reg.pola_37_8=negative +sff_cpld_reg.addr_37_8=0x00050074 +sff_cpld_reg.len_37_8=1 +sff_cpld_reg.bit_offset_37_8=0 + +sff_cpld_reg.mode_38_8=config +sff_cpld_reg.src_38_8=cpld +sff_cpld_reg.frmt_38_8=bit +sff_cpld_reg.pola_38_8=negative +sff_cpld_reg.addr_38_8=0x00050074 +sff_cpld_reg.len_38_8=1 +sff_cpld_reg.bit_offset_38_8=1 + +sff_cpld_reg.mode_39_8=config +sff_cpld_reg.src_39_8=cpld +sff_cpld_reg.frmt_39_8=bit +sff_cpld_reg.pola_39_8=negative +sff_cpld_reg.addr_39_8=0x00050074 +sff_cpld_reg.len_39_8=1 +sff_cpld_reg.bit_offset_39_8=2 + +sff_cpld_reg.mode_40_8=config +sff_cpld_reg.src_40_8=cpld +sff_cpld_reg.frmt_40_8=bit +sff_cpld_reg.pola_40_8=negative +sff_cpld_reg.addr_40_8=0x00050074 +sff_cpld_reg.len_40_8=1 +sff_cpld_reg.bit_offset_40_8=3 + +sff_cpld_reg.mode_41_8=config +sff_cpld_reg.src_41_8=cpld +sff_cpld_reg.frmt_41_8=bit +sff_cpld_reg.pola_41_8=negative +sff_cpld_reg.addr_41_8=0x00050074 +sff_cpld_reg.len_41_8=1 +sff_cpld_reg.bit_offset_41_8=4 + +sff_cpld_reg.mode_42_8=config +sff_cpld_reg.src_42_8=cpld +sff_cpld_reg.frmt_42_8=bit +sff_cpld_reg.pola_42_8=negative +sff_cpld_reg.addr_42_8=0x00050074 +sff_cpld_reg.len_42_8=1 +sff_cpld_reg.bit_offset_42_8=5 + +sff_cpld_reg.mode_43_8=config +sff_cpld_reg.src_43_8=cpld +sff_cpld_reg.frmt_43_8=bit +sff_cpld_reg.pola_43_8=negative +sff_cpld_reg.addr_43_8=0x0006007B +sff_cpld_reg.len_43_8=1 +sff_cpld_reg.bit_offset_43_8=0 + +sff_cpld_reg.mode_44_8=config +sff_cpld_reg.src_44_8=cpld +sff_cpld_reg.frmt_44_8=bit +sff_cpld_reg.pola_44_8=negative +sff_cpld_reg.addr_44_8=0x0006007B +sff_cpld_reg.len_44_8=1 +sff_cpld_reg.bit_offset_44_8=1 + +sff_cpld_reg.mode_45_8=config +sff_cpld_reg.src_45_8=cpld +sff_cpld_reg.frmt_45_8=bit +sff_cpld_reg.pola_45_8=negative +sff_cpld_reg.addr_45_8=0x0006007B +sff_cpld_reg.len_45_8=1 +sff_cpld_reg.bit_offset_45_8=2 + +sff_cpld_reg.mode_46_8=config +sff_cpld_reg.src_46_8=cpld +sff_cpld_reg.frmt_46_8=bit +sff_cpld_reg.pola_46_8=negative +sff_cpld_reg.addr_46_8=0x0006007B +sff_cpld_reg.len_46_8=1 +sff_cpld_reg.bit_offset_46_8=3 + +sff_cpld_reg.mode_47_8=config +sff_cpld_reg.src_47_8=cpld +sff_cpld_reg.frmt_47_8=bit +sff_cpld_reg.pola_47_8=negative +sff_cpld_reg.addr_47_8=0x0006007B +sff_cpld_reg.len_47_8=1 +sff_cpld_reg.bit_offset_47_8=4 + +sff_cpld_reg.mode_48_8=config +sff_cpld_reg.src_48_8=cpld +sff_cpld_reg.frmt_48_8=bit +sff_cpld_reg.pola_48_8=negative +sff_cpld_reg.addr_48_8=0x0006007B +sff_cpld_reg.len_48_8=1 +sff_cpld_reg.bit_offset_48_8=5 + +sff_cpld_reg.mode_49_8=config +sff_cpld_reg.src_49_8=cpld +sff_cpld_reg.frmt_49_8=bit +sff_cpld_reg.pola_49_8=negative +sff_cpld_reg.addr_49_8=0x0006007A +sff_cpld_reg.len_49_8=1 +sff_cpld_reg.bit_offset_49_8=0 + +sff_cpld_reg.mode_50_8=config +sff_cpld_reg.src_50_8=cpld +sff_cpld_reg.frmt_50_8=bit +sff_cpld_reg.pola_50_8=negative +sff_cpld_reg.addr_50_8=0x0006007A +sff_cpld_reg.len_50_8=1 +sff_cpld_reg.bit_offset_50_8=1 + +sff_cpld_reg.mode_51_8=config +sff_cpld_reg.src_51_8=cpld +sff_cpld_reg.frmt_51_8=bit +sff_cpld_reg.pola_51_8=negative +sff_cpld_reg.addr_51_8=0x0006007A +sff_cpld_reg.len_51_8=1 +sff_cpld_reg.bit_offset_51_8=2 + +sff_cpld_reg.mode_52_8=config +sff_cpld_reg.src_52_8=cpld +sff_cpld_reg.frmt_52_8=bit +sff_cpld_reg.pola_52_8=negative +sff_cpld_reg.addr_52_8=0x0006007A +sff_cpld_reg.len_52_8=1 +sff_cpld_reg.bit_offset_52_8=3 + +sff_cpld_reg.mode_53_8=config +sff_cpld_reg.src_53_8=cpld +sff_cpld_reg.frmt_53_8=bit +sff_cpld_reg.pola_53_8=negative +sff_cpld_reg.addr_53_8=0x0006007A +sff_cpld_reg.len_53_8=1 +sff_cpld_reg.bit_offset_53_8=4 + +sff_cpld_reg.mode_54_8=config +sff_cpld_reg.src_54_8=cpld +sff_cpld_reg.frmt_54_8=bit +sff_cpld_reg.pola_54_8=negative +sff_cpld_reg.addr_54_8=0x0006007A +sff_cpld_reg.len_54_8=1 +sff_cpld_reg.bit_offset_54_8=5 + +sff_cpld_reg.mode_55_8=config +sff_cpld_reg.src_55_8=cpld +sff_cpld_reg.frmt_55_8=bit +sff_cpld_reg.pola_55_8=negative +sff_cpld_reg.addr_55_8=0x0006007A +sff_cpld_reg.len_55_8=1 +sff_cpld_reg.bit_offset_55_8=6 + +sff_cpld_reg.mode_56_8=config +sff_cpld_reg.src_56_8=cpld +sff_cpld_reg.frmt_56_8=bit +sff_cpld_reg.pola_56_8=negative +sff_cpld_reg.addr_56_8=0x0006007A +sff_cpld_reg.len_56_8=1 +sff_cpld_reg.bit_offset_56_8=7 + +sff_cpld_reg.mode_57_8=config +sff_cpld_reg.src_57_8=cpld +sff_cpld_reg.frmt_57_8=bit +sff_cpld_reg.pola_57_8=negative +sff_cpld_reg.addr_57_8=0x00060079 +sff_cpld_reg.len_57_8=1 +sff_cpld_reg.bit_offset_57_8=0 + +sff_cpld_reg.mode_58_8=config +sff_cpld_reg.src_58_8=cpld +sff_cpld_reg.frmt_58_8=bit +sff_cpld_reg.pola_58_8=negative +sff_cpld_reg.addr_58_8=0x00060079 +sff_cpld_reg.len_58_8=1 +sff_cpld_reg.bit_offset_58_8=1 + +sff_cpld_reg.mode_59_8=config +sff_cpld_reg.src_59_8=cpld +sff_cpld_reg.frmt_59_8=bit +sff_cpld_reg.pola_59_8=negative +sff_cpld_reg.addr_59_8=0x00060079 +sff_cpld_reg.len_59_8=1 +sff_cpld_reg.bit_offset_59_8=2 + +sff_cpld_reg.mode_60_8=config +sff_cpld_reg.src_60_8=cpld +sff_cpld_reg.frmt_60_8=bit +sff_cpld_reg.pola_60_8=negative +sff_cpld_reg.addr_60_8=0x00060079 +sff_cpld_reg.len_60_8=1 +sff_cpld_reg.bit_offset_60_8=3 + +sff_cpld_reg.mode_61_8=config +sff_cpld_reg.src_61_8=cpld +sff_cpld_reg.frmt_61_8=bit +sff_cpld_reg.pola_61_8=negative +sff_cpld_reg.addr_61_8=0x00060079 +sff_cpld_reg.len_61_8=1 +sff_cpld_reg.bit_offset_61_8=4 + +sff_cpld_reg.mode_62_8=config +sff_cpld_reg.src_62_8=cpld +sff_cpld_reg.frmt_62_8=bit +sff_cpld_reg.pola_62_8=negative +sff_cpld_reg.addr_62_8=0x00060079 +sff_cpld_reg.len_62_8=1 +sff_cpld_reg.bit_offset_62_8=5 + +sff_cpld_reg.mode_63_8=config +sff_cpld_reg.src_63_8=cpld +sff_cpld_reg.frmt_63_8=bit +sff_cpld_reg.pola_63_8=negative +sff_cpld_reg.addr_63_8=0x00060079 +sff_cpld_reg.len_63_8=1 +sff_cpld_reg.bit_offset_63_8=6 + +sff_cpld_reg.mode_64_8=config +sff_cpld_reg.src_64_8=cpld +sff_cpld_reg.frmt_64_8=bit +sff_cpld_reg.pola_64_8=negative +sff_cpld_reg.addr_64_8=0x00060079 +sff_cpld_reg.len_64_8=1 +sff_cpld_reg.bit_offset_64_8=7 + +sff_cpld_reg.mode_65_8=config +sff_cpld_reg.src_65_8=cpld +sff_cpld_reg.frmt_65_8=bit +sff_cpld_reg.pola_65_8=negative +sff_cpld_reg.addr_65_8=0x00050074 +sff_cpld_reg.len_65_8=1 +sff_cpld_reg.bit_offset_65_8=6 + +sff_cpld_reg.mode_66_8=config +sff_cpld_reg.src_66_8=cpld +sff_cpld_reg.frmt_66_8=bit +sff_cpld_reg.pola_66_8=negative +sff_cpld_reg.addr_66_8=0x00050074 +sff_cpld_reg.len_66_8=1 +sff_cpld_reg.bit_offset_66_8=7 + +sff_cpld_reg.mode_67_8=config +sff_cpld_reg.src_67_8=cpld +sff_cpld_reg.frmt_67_8=bit +sff_cpld_reg.pola_67_8=negative +sff_cpld_reg.addr_67_8=0x00050073 +sff_cpld_reg.len_67_8=1 +sff_cpld_reg.bit_offset_67_8=0 + +sff_cpld_reg.mode_68_8=config +sff_cpld_reg.src_68_8=cpld +sff_cpld_reg.frmt_68_8=bit +sff_cpld_reg.pola_68_8=negative +sff_cpld_reg.addr_68_8=0x00050073 +sff_cpld_reg.len_68_8=1 +sff_cpld_reg.bit_offset_68_8=1 + +sff_cpld_reg.mode_69_8=config +sff_cpld_reg.src_69_8=cpld +sff_cpld_reg.frmt_69_8=bit +sff_cpld_reg.pola_69_8=negative +sff_cpld_reg.addr_69_8=0x00050073 +sff_cpld_reg.len_69_8=1 +sff_cpld_reg.bit_offset_69_8=2 + +sff_cpld_reg.mode_70_8=config +sff_cpld_reg.src_70_8=cpld +sff_cpld_reg.frmt_70_8=bit +sff_cpld_reg.pola_70_8=negative +sff_cpld_reg.addr_70_8=0x00050073 +sff_cpld_reg.len_70_8=1 +sff_cpld_reg.bit_offset_70_8=3 + +sff_cpld_reg.mode_71_8=config +sff_cpld_reg.src_71_8=cpld +sff_cpld_reg.frmt_71_8=bit +sff_cpld_reg.pola_71_8=negative +sff_cpld_reg.addr_71_8=0x00050073 +sff_cpld_reg.len_71_8=1 +sff_cpld_reg.bit_offset_71_8=4 + +sff_cpld_reg.mode_72_8=config +sff_cpld_reg.src_72_8=cpld +sff_cpld_reg.frmt_72_8=bit +sff_cpld_reg.pola_72_8=negative +sff_cpld_reg.addr_72_8=0x00050073 +sff_cpld_reg.len_72_8=1 +sff_cpld_reg.bit_offset_72_8=5 + +sff_cpld_reg.mode_73_8=config +sff_cpld_reg.src_73_8=cpld +sff_cpld_reg.frmt_73_8=bit +sff_cpld_reg.pola_73_8=negative +sff_cpld_reg.addr_73_8=0x00050073 +sff_cpld_reg.len_73_8=1 +sff_cpld_reg.bit_offset_73_8=6 + +sff_cpld_reg.mode_74_8=config +sff_cpld_reg.src_74_8=cpld +sff_cpld_reg.frmt_74_8=bit +sff_cpld_reg.pola_74_8=negative +sff_cpld_reg.addr_74_8=0x00050073 +sff_cpld_reg.len_74_8=1 +sff_cpld_reg.bit_offset_74_8=7 + +sff_cpld_reg.mode_75_8=config +sff_cpld_reg.src_75_8=cpld +sff_cpld_reg.frmt_75_8=bit +sff_cpld_reg.pola_75_8=negative +sff_cpld_reg.addr_75_8=0x00060078 +sff_cpld_reg.len_75_8=1 +sff_cpld_reg.bit_offset_75_8=0 + +sff_cpld_reg.mode_76_8=config +sff_cpld_reg.src_76_8=cpld +sff_cpld_reg.frmt_76_8=bit +sff_cpld_reg.pola_76_8=negative +sff_cpld_reg.addr_76_8=0x00060078 +sff_cpld_reg.len_76_8=1 +sff_cpld_reg.bit_offset_76_8=1 + +sff_cpld_reg.mode_77_8=config +sff_cpld_reg.src_77_8=cpld +sff_cpld_reg.frmt_77_8=bit +sff_cpld_reg.pola_77_8=negative +sff_cpld_reg.addr_77_8=0x00060078 +sff_cpld_reg.len_77_8=1 +sff_cpld_reg.bit_offset_77_8=2 + +sff_cpld_reg.mode_78_8=config +sff_cpld_reg.src_78_8=cpld +sff_cpld_reg.frmt_78_8=bit +sff_cpld_reg.pola_78_8=negative +sff_cpld_reg.addr_78_8=0x00060078 +sff_cpld_reg.len_78_8=1 +sff_cpld_reg.bit_offset_78_8=3 + +sff_cpld_reg.mode_79_8=config +sff_cpld_reg.src_79_8=cpld +sff_cpld_reg.frmt_79_8=bit +sff_cpld_reg.pola_79_8=negative +sff_cpld_reg.addr_79_8=0x00060078 +sff_cpld_reg.len_79_8=1 +sff_cpld_reg.bit_offset_79_8=4 + +sff_cpld_reg.mode_80_8=config +sff_cpld_reg.src_80_8=cpld +sff_cpld_reg.frmt_80_8=bit +sff_cpld_reg.pola_80_8=negative +sff_cpld_reg.addr_80_8=0x00060078 +sff_cpld_reg.len_80_8=1 +sff_cpld_reg.bit_offset_80_8=5 + +sff_cpld_reg.mode_81_8=config +sff_cpld_reg.src_81_8=cpld +sff_cpld_reg.frmt_81_8=bit +sff_cpld_reg.pola_81_8=negative +sff_cpld_reg.addr_81_8=0x00060077 +sff_cpld_reg.len_81_8=1 +sff_cpld_reg.bit_offset_81_8=0 + +sff_cpld_reg.mode_82_8=config +sff_cpld_reg.src_82_8=cpld +sff_cpld_reg.frmt_82_8=bit +sff_cpld_reg.pola_82_8=negative +sff_cpld_reg.addr_82_8=0x00060077 +sff_cpld_reg.len_82_8=1 +sff_cpld_reg.bit_offset_82_8=1 + +sff_cpld_reg.mode_83_8=config +sff_cpld_reg.src_83_8=cpld +sff_cpld_reg.frmt_83_8=bit +sff_cpld_reg.pola_83_8=negative +sff_cpld_reg.addr_83_8=0x00060077 +sff_cpld_reg.len_83_8=1 +sff_cpld_reg.bit_offset_83_8=2 + +sff_cpld_reg.mode_84_8=config +sff_cpld_reg.src_84_8=cpld +sff_cpld_reg.frmt_84_8=bit +sff_cpld_reg.pola_84_8=negative +sff_cpld_reg.addr_84_8=0x00060077 +sff_cpld_reg.len_84_8=1 +sff_cpld_reg.bit_offset_84_8=3 + +sff_cpld_reg.mode_85_8=config +sff_cpld_reg.src_85_8=cpld +sff_cpld_reg.frmt_85_8=bit +sff_cpld_reg.pola_85_8=negative +sff_cpld_reg.addr_85_8=0x00060077 +sff_cpld_reg.len_85_8=1 +sff_cpld_reg.bit_offset_85_8=4 + +sff_cpld_reg.mode_86_8=config +sff_cpld_reg.src_86_8=cpld +sff_cpld_reg.frmt_86_8=bit +sff_cpld_reg.pola_86_8=negative +sff_cpld_reg.addr_86_8=0x00060077 +sff_cpld_reg.len_86_8=1 +sff_cpld_reg.bit_offset_86_8=5 + +sff_cpld_reg.mode_87_8=config +sff_cpld_reg.src_87_8=cpld +sff_cpld_reg.frmt_87_8=bit +sff_cpld_reg.pola_87_8=negative +sff_cpld_reg.addr_87_8=0x00060077 +sff_cpld_reg.len_87_8=1 +sff_cpld_reg.bit_offset_87_8=6 + +sff_cpld_reg.mode_88_8=config +sff_cpld_reg.src_88_8=cpld +sff_cpld_reg.frmt_88_8=bit +sff_cpld_reg.pola_88_8=negative +sff_cpld_reg.addr_88_8=0x00060077 +sff_cpld_reg.len_88_8=1 +sff_cpld_reg.bit_offset_88_8=7 + +sff_cpld_reg.mode_89_8=config +sff_cpld_reg.src_89_8=cpld +sff_cpld_reg.frmt_89_8=bit +sff_cpld_reg.pola_89_8=negative +sff_cpld_reg.addr_89_8=0x00060076 +sff_cpld_reg.len_89_8=1 +sff_cpld_reg.bit_offset_89_8=0 + +sff_cpld_reg.mode_90_8=config +sff_cpld_reg.src_90_8=cpld +sff_cpld_reg.frmt_90_8=bit +sff_cpld_reg.pola_90_8=negative +sff_cpld_reg.addr_90_8=0x00060076 +sff_cpld_reg.len_90_8=1 +sff_cpld_reg.bit_offset_90_8=1 + +sff_cpld_reg.mode_91_8=config +sff_cpld_reg.src_91_8=cpld +sff_cpld_reg.frmt_91_8=bit +sff_cpld_reg.pola_91_8=negative +sff_cpld_reg.addr_91_8=0x00060076 +sff_cpld_reg.len_91_8=1 +sff_cpld_reg.bit_offset_91_8=2 + +sff_cpld_reg.mode_92_8=config +sff_cpld_reg.src_92_8=cpld +sff_cpld_reg.frmt_92_8=bit +sff_cpld_reg.pola_92_8=negative +sff_cpld_reg.addr_92_8=0x00060076 +sff_cpld_reg.len_92_8=1 +sff_cpld_reg.bit_offset_92_8=3 + +sff_cpld_reg.mode_93_8=config +sff_cpld_reg.src_93_8=cpld +sff_cpld_reg.frmt_93_8=bit +sff_cpld_reg.pola_93_8=negative +sff_cpld_reg.addr_93_8=0x00060076 +sff_cpld_reg.len_93_8=1 +sff_cpld_reg.bit_offset_93_8=4 + +sff_cpld_reg.mode_94_8=config +sff_cpld_reg.src_94_8=cpld +sff_cpld_reg.frmt_94_8=bit +sff_cpld_reg.pola_94_8=negative +sff_cpld_reg.addr_94_8=0x00060076 +sff_cpld_reg.len_94_8=1 +sff_cpld_reg.bit_offset_94_8=5 + +sff_cpld_reg.mode_95_8=config +sff_cpld_reg.src_95_8=cpld +sff_cpld_reg.frmt_95_8=bit +sff_cpld_reg.pola_95_8=negative +sff_cpld_reg.addr_95_8=0x00060076 +sff_cpld_reg.len_95_8=1 +sff_cpld_reg.bit_offset_95_8=6 + +sff_cpld_reg.mode_96_8=config +sff_cpld_reg.src_96_8=cpld +sff_cpld_reg.frmt_96_8=bit +sff_cpld_reg.pola_96_8=negative +sff_cpld_reg.addr_96_8=0x00060076 +sff_cpld_reg.len_96_8=1 +sff_cpld_reg.bit_offset_96_8=7 + +sff_cpld_reg.mode_97_8=config +sff_cpld_reg.src_97_8=cpld +sff_cpld_reg.frmt_97_8=bit +sff_cpld_reg.pola_97_8=negative +sff_cpld_reg.addr_97_8=0x00070077 +sff_cpld_reg.len_97_8=1 +sff_cpld_reg.bit_offset_97_8=0 + +sff_cpld_reg.mode_98_8=config +sff_cpld_reg.src_98_8=cpld +sff_cpld_reg.frmt_98_8=bit +sff_cpld_reg.pola_98_8=negative +sff_cpld_reg.addr_98_8=0x00070077 +sff_cpld_reg.len_98_8=1 +sff_cpld_reg.bit_offset_98_8=1 + +sff_cpld_reg.mode_99_8=config +sff_cpld_reg.src_99_8=cpld +sff_cpld_reg.frmt_99_8=bit +sff_cpld_reg.pola_99_8=negative +sff_cpld_reg.addr_99_8=0x00070077 +sff_cpld_reg.len_99_8=1 +sff_cpld_reg.bit_offset_99_8=2 + +sff_cpld_reg.mode_100_8=config +sff_cpld_reg.src_100_8=cpld +sff_cpld_reg.frmt_100_8=bit +sff_cpld_reg.pola_100_8=negative +sff_cpld_reg.addr_100_8=0x00070077 +sff_cpld_reg.len_100_8=1 +sff_cpld_reg.bit_offset_100_8=3 + +sff_cpld_reg.mode_101_8=config +sff_cpld_reg.src_101_8=cpld +sff_cpld_reg.frmt_101_8=bit +sff_cpld_reg.pola_101_8=negative +sff_cpld_reg.addr_101_8=0x00070077 +sff_cpld_reg.len_101_8=1 +sff_cpld_reg.bit_offset_101_8=4 + +sff_cpld_reg.mode_102_8=config +sff_cpld_reg.src_102_8=cpld +sff_cpld_reg.frmt_102_8=bit +sff_cpld_reg.pola_102_8=negative +sff_cpld_reg.addr_102_8=0x00070077 +sff_cpld_reg.len_102_8=1 +sff_cpld_reg.bit_offset_102_8=5 + +sff_cpld_reg.mode_103_8=config +sff_cpld_reg.src_103_8=cpld +sff_cpld_reg.frmt_103_8=bit +sff_cpld_reg.pola_103_8=negative +sff_cpld_reg.addr_103_8=0x00070077 +sff_cpld_reg.len_103_8=1 +sff_cpld_reg.bit_offset_103_8=6 + +sff_cpld_reg.mode_104_8=config +sff_cpld_reg.src_104_8=cpld +sff_cpld_reg.frmt_104_8=bit +sff_cpld_reg.pola_104_8=negative +sff_cpld_reg.addr_104_8=0x00070077 +sff_cpld_reg.len_104_8=1 +sff_cpld_reg.bit_offset_104_8=7 + +sff_cpld_reg.mode_105_8=config +sff_cpld_reg.src_105_8=cpld +sff_cpld_reg.frmt_105_8=bit +sff_cpld_reg.pola_105_8=negative +sff_cpld_reg.addr_105_8=0x00070076 +sff_cpld_reg.len_105_8=1 +sff_cpld_reg.bit_offset_105_8=0 + +sff_cpld_reg.mode_106_8=config +sff_cpld_reg.src_106_8=cpld +sff_cpld_reg.frmt_106_8=bit +sff_cpld_reg.pola_106_8=negative +sff_cpld_reg.addr_106_8=0x00070076 +sff_cpld_reg.len_106_8=1 +sff_cpld_reg.bit_offset_106_8=1 + +sff_cpld_reg.mode_107_8=config +sff_cpld_reg.src_107_8=cpld +sff_cpld_reg.frmt_107_8=bit +sff_cpld_reg.pola_107_8=negative +sff_cpld_reg.addr_107_8=0x00070076 +sff_cpld_reg.len_107_8=1 +sff_cpld_reg.bit_offset_107_8=2 + +sff_cpld_reg.mode_108_8=config +sff_cpld_reg.src_108_8=cpld +sff_cpld_reg.frmt_108_8=bit +sff_cpld_reg.pola_108_8=negative +sff_cpld_reg.addr_108_8=0x00070076 +sff_cpld_reg.len_108_8=1 +sff_cpld_reg.bit_offset_108_8=3 + +sff_cpld_reg.mode_109_8=config +sff_cpld_reg.src_109_8=cpld +sff_cpld_reg.frmt_109_8=bit +sff_cpld_reg.pola_109_8=negative +sff_cpld_reg.addr_109_8=0x00070076 +sff_cpld_reg.len_109_8=1 +sff_cpld_reg.bit_offset_109_8=4 + +sff_cpld_reg.mode_110_8=config +sff_cpld_reg.src_110_8=cpld +sff_cpld_reg.frmt_110_8=bit +sff_cpld_reg.pola_110_8=negative +sff_cpld_reg.addr_110_8=0x00070076 +sff_cpld_reg.len_110_8=1 +sff_cpld_reg.bit_offset_110_8=5 + +sff_cpld_reg.mode_111_8=config +sff_cpld_reg.src_111_8=cpld +sff_cpld_reg.frmt_111_8=bit +sff_cpld_reg.pola_111_8=negative +sff_cpld_reg.addr_111_8=0x00070076 +sff_cpld_reg.len_111_8=1 +sff_cpld_reg.bit_offset_111_8=6 + +sff_cpld_reg.mode_112_8=config +sff_cpld_reg.src_112_8=cpld +sff_cpld_reg.frmt_112_8=bit +sff_cpld_reg.pola_112_8=negative +sff_cpld_reg.addr_112_8=0x00070076 +sff_cpld_reg.len_112_8=1 +sff_cpld_reg.bit_offset_112_8=7 + +sff_cpld_reg.mode_113_8=config +sff_cpld_reg.src_113_8=cpld +sff_cpld_reg.frmt_113_8=bit +sff_cpld_reg.pola_113_8=negative +sff_cpld_reg.addr_113_8=0x00070075 +sff_cpld_reg.len_113_8=1 +sff_cpld_reg.bit_offset_113_8=0 + +sff_cpld_reg.mode_114_8=config +sff_cpld_reg.src_114_8=cpld +sff_cpld_reg.frmt_114_8=bit +sff_cpld_reg.pola_114_8=negative +sff_cpld_reg.addr_114_8=0x00070075 +sff_cpld_reg.len_114_8=1 +sff_cpld_reg.bit_offset_114_8=1 + +sff_cpld_reg.mode_115_8=config +sff_cpld_reg.src_115_8=cpld +sff_cpld_reg.frmt_115_8=bit +sff_cpld_reg.pola_115_8=negative +sff_cpld_reg.addr_115_8=0x00070075 +sff_cpld_reg.len_115_8=1 +sff_cpld_reg.bit_offset_115_8=2 + +sff_cpld_reg.mode_116_8=config +sff_cpld_reg.src_116_8=cpld +sff_cpld_reg.frmt_116_8=bit +sff_cpld_reg.pola_116_8=negative +sff_cpld_reg.addr_116_8=0x00070075 +sff_cpld_reg.len_116_8=1 +sff_cpld_reg.bit_offset_116_8=3 + +sff_cpld_reg.mode_117_8=config +sff_cpld_reg.src_117_8=cpld +sff_cpld_reg.frmt_117_8=bit +sff_cpld_reg.pola_117_8=negative +sff_cpld_reg.addr_117_8=0x00070075 +sff_cpld_reg.len_117_8=1 +sff_cpld_reg.bit_offset_117_8=4 + +sff_cpld_reg.mode_118_8=config +sff_cpld_reg.src_118_8=cpld +sff_cpld_reg.frmt_118_8=bit +sff_cpld_reg.pola_118_8=negative +sff_cpld_reg.addr_118_8=0x00070075 +sff_cpld_reg.len_118_8=1 +sff_cpld_reg.bit_offset_118_8=5 + +sff_cpld_reg.mode_119_8=config +sff_cpld_reg.src_119_8=cpld +sff_cpld_reg.frmt_119_8=bit +sff_cpld_reg.pola_119_8=negative +sff_cpld_reg.addr_119_8=0x00070075 +sff_cpld_reg.len_119_8=1 +sff_cpld_reg.bit_offset_119_8=6 + +sff_cpld_reg.mode_120_8=config +sff_cpld_reg.src_120_8=cpld +sff_cpld_reg.frmt_120_8=bit +sff_cpld_reg.pola_120_8=negative +sff_cpld_reg.addr_120_8=0x00070075 +sff_cpld_reg.len_120_8=1 +sff_cpld_reg.bit_offset_120_8=7 + +sff_cpld_reg.mode_121_8=config +sff_cpld_reg.src_121_8=cpld +sff_cpld_reg.frmt_121_8=bit +sff_cpld_reg.pola_121_8=negative +sff_cpld_reg.addr_121_8=0x00070074 +sff_cpld_reg.len_121_8=1 +sff_cpld_reg.bit_offset_121_8=0 + +sff_cpld_reg.mode_122_8=config +sff_cpld_reg.src_122_8=cpld +sff_cpld_reg.frmt_122_8=bit +sff_cpld_reg.pola_122_8=negative +sff_cpld_reg.addr_122_8=0x00070074 +sff_cpld_reg.len_122_8=1 +sff_cpld_reg.bit_offset_122_8=1 + +sff_cpld_reg.mode_123_8=config +sff_cpld_reg.src_123_8=cpld +sff_cpld_reg.frmt_123_8=bit +sff_cpld_reg.pola_123_8=negative +sff_cpld_reg.addr_123_8=0x00070074 +sff_cpld_reg.len_123_8=1 +sff_cpld_reg.bit_offset_123_8=2 + +sff_cpld_reg.mode_124_8=config +sff_cpld_reg.src_124_8=cpld +sff_cpld_reg.frmt_124_8=bit +sff_cpld_reg.pola_124_8=negative +sff_cpld_reg.addr_124_8=0x00070074 +sff_cpld_reg.len_124_8=1 +sff_cpld_reg.bit_offset_124_8=3 + +sff_cpld_reg.mode_125_8=config +sff_cpld_reg.src_125_8=cpld +sff_cpld_reg.frmt_125_8=bit +sff_cpld_reg.pola_125_8=negative +sff_cpld_reg.addr_125_8=0x00070074 +sff_cpld_reg.len_125_8=1 +sff_cpld_reg.bit_offset_125_8=4 + +sff_cpld_reg.mode_126_8=config +sff_cpld_reg.src_126_8=cpld +sff_cpld_reg.frmt_126_8=bit +sff_cpld_reg.pola_126_8=negative +sff_cpld_reg.addr_126_8=0x00070074 +sff_cpld_reg.len_126_8=1 +sff_cpld_reg.bit_offset_126_8=5 + +sff_cpld_reg.mode_127_8=config +sff_cpld_reg.src_127_8=cpld +sff_cpld_reg.frmt_127_8=bit +sff_cpld_reg.pola_127_8=negative +sff_cpld_reg.addr_127_8=0x00070074 +sff_cpld_reg.len_127_8=1 +sff_cpld_reg.bit_offset_127_8=6 + +sff_cpld_reg.mode_128_8=config +sff_cpld_reg.src_128_8=cpld +sff_cpld_reg.frmt_128_8=bit +sff_cpld_reg.pola_128_8=negative +sff_cpld_reg.addr_128_8=0x00070074 +sff_cpld_reg.len_128_8=1 +sff_cpld_reg.bit_offset_128_8=7 + + +sff_cpld_reg.mode_1_1=config +sff_cpld_reg.src_1_1=cpld +sff_cpld_reg.frmt_1_1=bit +sff_cpld_reg.addr_1_1=0x00020080 +sff_cpld_reg.len_1_1=1 +sff_cpld_reg.bit_offset_1_1=0 + +sff_cpld_reg.mode_2_1=config +sff_cpld_reg.src_2_1=cpld +sff_cpld_reg.frmt_2_1=bit +sff_cpld_reg.addr_2_1=0x00020080 +sff_cpld_reg.len_2_1=1 +sff_cpld_reg.bit_offset_2_1=0 + +sff_cpld_reg.mode_3_1=config +sff_cpld_reg.src_3_1=cpld +sff_cpld_reg.frmt_3_1=bit +sff_cpld_reg.addr_3_1=0x00020080 +sff_cpld_reg.len_3_1=1 +sff_cpld_reg.bit_offset_3_1=0 + +sff_cpld_reg.mode_4_1=config +sff_cpld_reg.src_4_1=cpld +sff_cpld_reg.frmt_4_1=bit +sff_cpld_reg.addr_4_1=0x00020080 +sff_cpld_reg.len_4_1=1 +sff_cpld_reg.bit_offset_4_1=0 + +sff_cpld_reg.mode_5_1=config +sff_cpld_reg.src_5_1=cpld +sff_cpld_reg.frmt_5_1=bit +sff_cpld_reg.addr_5_1=0x00020080 +sff_cpld_reg.len_5_1=1 +sff_cpld_reg.bit_offset_5_1=0 + +sff_cpld_reg.mode_6_1=config +sff_cpld_reg.src_6_1=cpld +sff_cpld_reg.frmt_6_1=bit +sff_cpld_reg.addr_6_1=0x00020080 +sff_cpld_reg.len_6_1=1 +sff_cpld_reg.bit_offset_6_1=0 + +sff_cpld_reg.mode_7_1=config +sff_cpld_reg.src_7_1=cpld +sff_cpld_reg.frmt_7_1=bit +sff_cpld_reg.addr_7_1=0x00020080 +sff_cpld_reg.len_7_1=1 +sff_cpld_reg.bit_offset_7_1=0 + +sff_cpld_reg.mode_8_1=config +sff_cpld_reg.src_8_1=cpld +sff_cpld_reg.frmt_8_1=bit +sff_cpld_reg.addr_8_1=0x00020080 +sff_cpld_reg.len_8_1=1 +sff_cpld_reg.bit_offset_8_1=0 + +sff_cpld_reg.mode_9_1=config +sff_cpld_reg.src_9_1=cpld +sff_cpld_reg.frmt_9_1=bit +sff_cpld_reg.addr_9_1=0x00020080 +sff_cpld_reg.len_9_1=1 +sff_cpld_reg.bit_offset_9_1=1 + +sff_cpld_reg.mode_10_1=config +sff_cpld_reg.src_10_1=cpld +sff_cpld_reg.frmt_10_1=bit +sff_cpld_reg.addr_10_1=0x00020080 +sff_cpld_reg.len_10_1=1 +sff_cpld_reg.bit_offset_10_1=1 + +sff_cpld_reg.mode_11_1=config +sff_cpld_reg.src_11_1=cpld +sff_cpld_reg.frmt_11_1=bit +sff_cpld_reg.addr_11_1=0x00020080 +sff_cpld_reg.len_11_1=1 +sff_cpld_reg.bit_offset_11_1=1 + +sff_cpld_reg.mode_12_1=config +sff_cpld_reg.src_12_1=cpld +sff_cpld_reg.frmt_12_1=bit +sff_cpld_reg.addr_12_1=0x00020080 +sff_cpld_reg.len_12_1=1 +sff_cpld_reg.bit_offset_12_1=1 + +sff_cpld_reg.mode_13_1=config +sff_cpld_reg.src_13_1=cpld +sff_cpld_reg.frmt_13_1=bit +sff_cpld_reg.addr_13_1=0x00020080 +sff_cpld_reg.len_13_1=1 +sff_cpld_reg.bit_offset_13_1=1 + +sff_cpld_reg.mode_14_1=config +sff_cpld_reg.src_14_1=cpld +sff_cpld_reg.frmt_14_1=bit +sff_cpld_reg.addr_14_1=0x00020080 +sff_cpld_reg.len_14_1=1 +sff_cpld_reg.bit_offset_14_1=1 + +sff_cpld_reg.mode_15_1=config +sff_cpld_reg.src_15_1=cpld +sff_cpld_reg.frmt_15_1=bit +sff_cpld_reg.addr_15_1=0x00020080 +sff_cpld_reg.len_15_1=1 +sff_cpld_reg.bit_offset_15_1=1 + +sff_cpld_reg.mode_16_1=config +sff_cpld_reg.src_16_1=cpld +sff_cpld_reg.frmt_16_1=bit +sff_cpld_reg.addr_16_1=0x00020080 +sff_cpld_reg.len_16_1=1 +sff_cpld_reg.bit_offset_16_1=1 + +sff_cpld_reg.mode_17_1=config +sff_cpld_reg.src_17_1=cpld +sff_cpld_reg.frmt_17_1=bit +sff_cpld_reg.addr_17_1=0x00020080 +sff_cpld_reg.len_17_1=1 +sff_cpld_reg.bit_offset_17_1=2 + +sff_cpld_reg.mode_18_1=config +sff_cpld_reg.src_18_1=cpld +sff_cpld_reg.frmt_18_1=bit +sff_cpld_reg.addr_18_1=0x00020080 +sff_cpld_reg.len_18_1=1 +sff_cpld_reg.bit_offset_18_1=2 + +sff_cpld_reg.mode_19_1=config +sff_cpld_reg.src_19_1=cpld +sff_cpld_reg.frmt_19_1=bit +sff_cpld_reg.addr_19_1=0x00020080 +sff_cpld_reg.len_19_1=1 +sff_cpld_reg.bit_offset_19_1=2 + +sff_cpld_reg.mode_20_1=config +sff_cpld_reg.src_20_1=cpld +sff_cpld_reg.frmt_20_1=bit +sff_cpld_reg.addr_20_1=0x00020080 +sff_cpld_reg.len_20_1=1 +sff_cpld_reg.bit_offset_20_1=2 + +sff_cpld_reg.mode_21_1=config +sff_cpld_reg.src_21_1=cpld +sff_cpld_reg.frmt_21_1=bit +sff_cpld_reg.addr_21_1=0x00020080 +sff_cpld_reg.len_21_1=1 +sff_cpld_reg.bit_offset_21_1=2 + +sff_cpld_reg.mode_22_1=config +sff_cpld_reg.src_22_1=cpld +sff_cpld_reg.frmt_22_1=bit +sff_cpld_reg.addr_22_1=0x00020080 +sff_cpld_reg.len_22_1=1 +sff_cpld_reg.bit_offset_22_1=2 + +sff_cpld_reg.mode_23_1=config +sff_cpld_reg.src_23_1=cpld +sff_cpld_reg.frmt_23_1=bit +sff_cpld_reg.addr_23_1=0x00020080 +sff_cpld_reg.len_23_1=1 +sff_cpld_reg.bit_offset_23_1=2 + +sff_cpld_reg.mode_24_1=config +sff_cpld_reg.src_24_1=cpld +sff_cpld_reg.frmt_24_1=bit +sff_cpld_reg.addr_24_1=0x00020080 +sff_cpld_reg.len_24_1=1 +sff_cpld_reg.bit_offset_24_1=2 + +sff_cpld_reg.mode_25_1=config +sff_cpld_reg.src_25_1=cpld +sff_cpld_reg.frmt_25_1=bit +sff_cpld_reg.addr_25_1=0x00020080 +sff_cpld_reg.len_25_1=1 +sff_cpld_reg.bit_offset_25_1=3 + +sff_cpld_reg.mode_26_1=config +sff_cpld_reg.src_26_1=cpld +sff_cpld_reg.frmt_26_1=bit +sff_cpld_reg.addr_26_1=0x00020080 +sff_cpld_reg.len_26_1=1 +sff_cpld_reg.bit_offset_26_1=3 + +sff_cpld_reg.mode_27_1=config +sff_cpld_reg.src_27_1=cpld +sff_cpld_reg.frmt_27_1=bit +sff_cpld_reg.addr_27_1=0x00020080 +sff_cpld_reg.len_27_1=1 +sff_cpld_reg.bit_offset_27_1=3 + +sff_cpld_reg.mode_28_1=config +sff_cpld_reg.src_28_1=cpld +sff_cpld_reg.frmt_28_1=bit +sff_cpld_reg.addr_28_1=0x00020080 +sff_cpld_reg.len_28_1=1 +sff_cpld_reg.bit_offset_28_1=3 + +sff_cpld_reg.mode_29_1=config +sff_cpld_reg.src_29_1=cpld +sff_cpld_reg.frmt_29_1=bit +sff_cpld_reg.addr_29_1=0x00020080 +sff_cpld_reg.len_29_1=1 +sff_cpld_reg.bit_offset_29_1=3 + +sff_cpld_reg.mode_30_1=config +sff_cpld_reg.src_30_1=cpld +sff_cpld_reg.frmt_30_1=bit +sff_cpld_reg.addr_30_1=0x00020080 +sff_cpld_reg.len_30_1=1 +sff_cpld_reg.bit_offset_30_1=3 + +sff_cpld_reg.mode_31_1=config +sff_cpld_reg.src_31_1=cpld +sff_cpld_reg.frmt_31_1=bit +sff_cpld_reg.addr_31_1=0x00020080 +sff_cpld_reg.len_31_1=1 +sff_cpld_reg.bit_offset_31_1=3 + +sff_cpld_reg.mode_32_1=config +sff_cpld_reg.src_32_1=cpld +sff_cpld_reg.frmt_32_1=bit +sff_cpld_reg.addr_32_1=0x00020080 +sff_cpld_reg.len_32_1=1 +sff_cpld_reg.bit_offset_32_1=3 + +sff_cpld_reg.mode_33_1=config +sff_cpld_reg.src_33_1=cpld +sff_cpld_reg.frmt_33_1=bit +sff_cpld_reg.addr_33_1=0x0005007C +sff_cpld_reg.len_33_1=1 +sff_cpld_reg.bit_offset_33_1=0 + +sff_cpld_reg.mode_34_1=config +sff_cpld_reg.src_34_1=cpld +sff_cpld_reg.frmt_34_1=bit +sff_cpld_reg.addr_34_1=0x0005007C +sff_cpld_reg.len_34_1=1 +sff_cpld_reg.bit_offset_34_1=0 + +sff_cpld_reg.mode_35_1=config +sff_cpld_reg.src_35_1=cpld +sff_cpld_reg.frmt_35_1=bit +sff_cpld_reg.addr_35_1=0x0005007C +sff_cpld_reg.len_35_1=1 +sff_cpld_reg.bit_offset_35_1=0 + +sff_cpld_reg.mode_36_1=config +sff_cpld_reg.src_36_1=cpld +sff_cpld_reg.frmt_36_1=bit +sff_cpld_reg.addr_36_1=0x0005007C +sff_cpld_reg.len_36_1=1 +sff_cpld_reg.bit_offset_36_1=0 + +sff_cpld_reg.mode_37_1=config +sff_cpld_reg.src_37_1=cpld +sff_cpld_reg.frmt_37_1=bit +sff_cpld_reg.addr_37_1=0x0005007C +sff_cpld_reg.len_37_1=1 +sff_cpld_reg.bit_offset_37_1=0 + +sff_cpld_reg.mode_38_1=config +sff_cpld_reg.src_38_1=cpld +sff_cpld_reg.frmt_38_1=bit +sff_cpld_reg.addr_38_1=0x0005007C +sff_cpld_reg.len_38_1=1 +sff_cpld_reg.bit_offset_38_1=0 + +sff_cpld_reg.mode_39_1=config +sff_cpld_reg.src_39_1=cpld +sff_cpld_reg.frmt_39_1=bit +sff_cpld_reg.addr_39_1=0x0005007C +sff_cpld_reg.len_39_1=1 +sff_cpld_reg.bit_offset_39_1=0 + +sff_cpld_reg.mode_40_1=config +sff_cpld_reg.src_40_1=cpld +sff_cpld_reg.frmt_40_1=bit +sff_cpld_reg.addr_40_1=0x0005007C +sff_cpld_reg.len_40_1=1 +sff_cpld_reg.bit_offset_40_1=0 + +sff_cpld_reg.mode_41_1=config +sff_cpld_reg.src_41_1=cpld +sff_cpld_reg.frmt_41_1=bit +sff_cpld_reg.addr_41_1=0x0005007C +sff_cpld_reg.len_41_1=1 +sff_cpld_reg.bit_offset_41_1=1 + +sff_cpld_reg.mode_42_1=config +sff_cpld_reg.src_42_1=cpld +sff_cpld_reg.frmt_42_1=bit +sff_cpld_reg.addr_42_1=0x0005007C +sff_cpld_reg.len_42_1=1 +sff_cpld_reg.bit_offset_42_1=1 + +sff_cpld_reg.mode_43_1=config +sff_cpld_reg.src_43_1=cpld +sff_cpld_reg.frmt_43_1=bit +sff_cpld_reg.addr_43_1=0x0005007C +sff_cpld_reg.len_43_1=1 +sff_cpld_reg.bit_offset_43_1=1 + +sff_cpld_reg.mode_44_1=config +sff_cpld_reg.src_44_1=cpld +sff_cpld_reg.frmt_44_1=bit +sff_cpld_reg.addr_44_1=0x0005007C +sff_cpld_reg.len_44_1=1 +sff_cpld_reg.bit_offset_44_1=1 + +sff_cpld_reg.mode_45_1=config +sff_cpld_reg.src_45_1=cpld +sff_cpld_reg.frmt_45_1=bit +sff_cpld_reg.addr_45_1=0x0005007C +sff_cpld_reg.len_45_1=1 +sff_cpld_reg.bit_offset_45_1=1 + +sff_cpld_reg.mode_46_1=config +sff_cpld_reg.src_46_1=cpld +sff_cpld_reg.frmt_46_1=bit +sff_cpld_reg.addr_46_1=0x0005007C +sff_cpld_reg.len_46_1=1 +sff_cpld_reg.bit_offset_46_1=1 + +sff_cpld_reg.mode_47_1=config +sff_cpld_reg.src_47_1=cpld +sff_cpld_reg.frmt_47_1=bit +sff_cpld_reg.addr_47_1=0x0005007C +sff_cpld_reg.len_47_1=1 +sff_cpld_reg.bit_offset_47_1=1 + +sff_cpld_reg.mode_48_1=config +sff_cpld_reg.src_48_1=cpld +sff_cpld_reg.frmt_48_1=bit +sff_cpld_reg.addr_48_1=0x0005007C +sff_cpld_reg.len_48_1=1 +sff_cpld_reg.bit_offset_48_1=1 + +sff_cpld_reg.mode_49_1=config +sff_cpld_reg.src_49_1=cpld +sff_cpld_reg.frmt_49_1=bit +sff_cpld_reg.addr_49_1=0x0005007C +sff_cpld_reg.len_49_1=1 +sff_cpld_reg.bit_offset_49_1=2 + +sff_cpld_reg.mode_50_1=config +sff_cpld_reg.src_50_1=cpld +sff_cpld_reg.frmt_50_1=bit +sff_cpld_reg.addr_50_1=0x0005007C +sff_cpld_reg.len_50_1=1 +sff_cpld_reg.bit_offset_50_1=2 + +sff_cpld_reg.mode_51_1=config +sff_cpld_reg.src_51_1=cpld +sff_cpld_reg.frmt_51_1=bit +sff_cpld_reg.addr_51_1=0x0005007C +sff_cpld_reg.len_51_1=1 +sff_cpld_reg.bit_offset_51_1=2 + +sff_cpld_reg.mode_52_1=config +sff_cpld_reg.src_52_1=cpld +sff_cpld_reg.frmt_52_1=bit +sff_cpld_reg.addr_52_1=0x0005007C +sff_cpld_reg.len_52_1=1 +sff_cpld_reg.bit_offset_52_1=2 + +sff_cpld_reg.mode_53_1=config +sff_cpld_reg.src_53_1=cpld +sff_cpld_reg.frmt_53_1=bit +sff_cpld_reg.addr_53_1=0x0005007C +sff_cpld_reg.len_53_1=1 +sff_cpld_reg.bit_offset_53_1=2 + +sff_cpld_reg.mode_54_1=config +sff_cpld_reg.src_54_1=cpld +sff_cpld_reg.frmt_54_1=bit +sff_cpld_reg.addr_54_1=0x0005007C +sff_cpld_reg.len_54_1=1 +sff_cpld_reg.bit_offset_54_1=2 + +sff_cpld_reg.mode_55_1=config +sff_cpld_reg.src_55_1=cpld +sff_cpld_reg.frmt_55_1=bit +sff_cpld_reg.addr_55_1=0x0005007C +sff_cpld_reg.len_55_1=1 +sff_cpld_reg.bit_offset_55_1=2 + +sff_cpld_reg.mode_56_1=config +sff_cpld_reg.src_56_1=cpld +sff_cpld_reg.frmt_56_1=bit +sff_cpld_reg.addr_56_1=0x0005007C +sff_cpld_reg.len_56_1=1 +sff_cpld_reg.bit_offset_56_1=2 + +sff_cpld_reg.mode_57_1=config +sff_cpld_reg.src_57_1=cpld +sff_cpld_reg.frmt_57_1=bit +sff_cpld_reg.addr_57_1=0x0005007C +sff_cpld_reg.len_57_1=1 +sff_cpld_reg.bit_offset_57_1=3 + +sff_cpld_reg.mode_58_1=config +sff_cpld_reg.src_58_1=cpld +sff_cpld_reg.frmt_58_1=bit +sff_cpld_reg.addr_58_1=0x0005007C +sff_cpld_reg.len_58_1=1 +sff_cpld_reg.bit_offset_58_1=3 + +sff_cpld_reg.mode_59_1=config +sff_cpld_reg.src_59_1=cpld +sff_cpld_reg.frmt_59_1=bit +sff_cpld_reg.addr_59_1=0x0005007C +sff_cpld_reg.len_59_1=1 +sff_cpld_reg.bit_offset_59_1=3 + +sff_cpld_reg.mode_60_1=config +sff_cpld_reg.src_60_1=cpld +sff_cpld_reg.frmt_60_1=bit +sff_cpld_reg.addr_60_1=0x0005007C +sff_cpld_reg.len_60_1=1 +sff_cpld_reg.bit_offset_60_1=3 + +sff_cpld_reg.mode_61_1=config +sff_cpld_reg.src_61_1=cpld +sff_cpld_reg.frmt_61_1=bit +sff_cpld_reg.addr_61_1=0x0005007C +sff_cpld_reg.len_61_1=1 +sff_cpld_reg.bit_offset_61_1=3 + +sff_cpld_reg.mode_62_1=config +sff_cpld_reg.src_62_1=cpld +sff_cpld_reg.frmt_62_1=bit +sff_cpld_reg.addr_62_1=0x0005007C +sff_cpld_reg.len_62_1=1 +sff_cpld_reg.bit_offset_62_1=3 + +sff_cpld_reg.mode_63_1=config +sff_cpld_reg.src_63_1=cpld +sff_cpld_reg.frmt_63_1=bit +sff_cpld_reg.addr_63_1=0x0005007C +sff_cpld_reg.len_63_1=1 +sff_cpld_reg.bit_offset_63_1=3 + +sff_cpld_reg.mode_64_1=config +sff_cpld_reg.src_64_1=cpld +sff_cpld_reg.frmt_64_1=bit +sff_cpld_reg.addr_64_1=0x0005007C +sff_cpld_reg.len_64_1=1 +sff_cpld_reg.bit_offset_64_1=3 + +sff_cpld_reg.mode_65_1=config +sff_cpld_reg.src_65_1=cpld +sff_cpld_reg.frmt_65_1=bit +sff_cpld_reg.addr_65_1=0x0005007C +sff_cpld_reg.len_65_1=1 +sff_cpld_reg.bit_offset_65_1=4 + +sff_cpld_reg.mode_66_1=config +sff_cpld_reg.src_66_1=cpld +sff_cpld_reg.frmt_66_1=bit +sff_cpld_reg.addr_66_1=0x0005007C +sff_cpld_reg.len_66_1=1 +sff_cpld_reg.bit_offset_66_1=4 + +sff_cpld_reg.mode_67_1=config +sff_cpld_reg.src_67_1=cpld +sff_cpld_reg.frmt_67_1=bit +sff_cpld_reg.addr_67_1=0x0005007C +sff_cpld_reg.len_67_1=1 +sff_cpld_reg.bit_offset_67_1=4 + +sff_cpld_reg.mode_68_1=config +sff_cpld_reg.src_68_1=cpld +sff_cpld_reg.frmt_68_1=bit +sff_cpld_reg.addr_68_1=0x0005007C +sff_cpld_reg.len_68_1=1 +sff_cpld_reg.bit_offset_68_1=4 + +sff_cpld_reg.mode_69_1=config +sff_cpld_reg.src_69_1=cpld +sff_cpld_reg.frmt_69_1=bit +sff_cpld_reg.addr_69_1=0x0005007C +sff_cpld_reg.len_69_1=1 +sff_cpld_reg.bit_offset_69_1=4 + +sff_cpld_reg.mode_70_1=config +sff_cpld_reg.src_70_1=cpld +sff_cpld_reg.frmt_70_1=bit +sff_cpld_reg.addr_70_1=0x0005007C +sff_cpld_reg.len_70_1=1 +sff_cpld_reg.bit_offset_70_1=4 + +sff_cpld_reg.mode_71_1=config +sff_cpld_reg.src_71_1=cpld +sff_cpld_reg.frmt_71_1=bit +sff_cpld_reg.addr_71_1=0x0005007C +sff_cpld_reg.len_71_1=1 +sff_cpld_reg.bit_offset_71_1=4 + +sff_cpld_reg.mode_72_1=config +sff_cpld_reg.src_72_1=cpld +sff_cpld_reg.frmt_72_1=bit +sff_cpld_reg.addr_72_1=0x0005007C +sff_cpld_reg.len_72_1=1 +sff_cpld_reg.bit_offset_72_1=4 + +sff_cpld_reg.mode_73_1=config +sff_cpld_reg.src_73_1=cpld +sff_cpld_reg.frmt_73_1=bit +sff_cpld_reg.addr_73_1=0x0005007C +sff_cpld_reg.len_73_1=1 +sff_cpld_reg.bit_offset_73_1=5 + +sff_cpld_reg.mode_74_1=config +sff_cpld_reg.src_74_1=cpld +sff_cpld_reg.frmt_74_1=bit +sff_cpld_reg.addr_74_1=0x0005007C +sff_cpld_reg.len_74_1=1 +sff_cpld_reg.bit_offset_74_1=5 + +sff_cpld_reg.mode_75_1=config +sff_cpld_reg.src_75_1=cpld +sff_cpld_reg.frmt_75_1=bit +sff_cpld_reg.addr_75_1=0x0005007C +sff_cpld_reg.len_75_1=1 +sff_cpld_reg.bit_offset_75_1=5 + +sff_cpld_reg.mode_76_1=config +sff_cpld_reg.src_76_1=cpld +sff_cpld_reg.frmt_76_1=bit +sff_cpld_reg.addr_76_1=0x0005007C +sff_cpld_reg.len_76_1=1 +sff_cpld_reg.bit_offset_76_1=5 + +sff_cpld_reg.mode_77_1=config +sff_cpld_reg.src_77_1=cpld +sff_cpld_reg.frmt_77_1=bit +sff_cpld_reg.addr_77_1=0x0005007C +sff_cpld_reg.len_77_1=1 +sff_cpld_reg.bit_offset_77_1=5 + +sff_cpld_reg.mode_78_1=config +sff_cpld_reg.src_78_1=cpld +sff_cpld_reg.frmt_78_1=bit +sff_cpld_reg.addr_78_1=0x0005007C +sff_cpld_reg.len_78_1=1 +sff_cpld_reg.bit_offset_78_1=5 + +sff_cpld_reg.mode_79_1=config +sff_cpld_reg.src_79_1=cpld +sff_cpld_reg.frmt_79_1=bit +sff_cpld_reg.addr_79_1=0x0005007C +sff_cpld_reg.len_79_1=1 +sff_cpld_reg.bit_offset_79_1=5 + +sff_cpld_reg.mode_80_1=config +sff_cpld_reg.src_80_1=cpld +sff_cpld_reg.frmt_80_1=bit +sff_cpld_reg.addr_80_1=0x0005007C +sff_cpld_reg.len_80_1=1 +sff_cpld_reg.bit_offset_80_1=5 + +sff_cpld_reg.mode_81_1=config +sff_cpld_reg.src_81_1=cpld +sff_cpld_reg.frmt_81_1=bit +sff_cpld_reg.addr_81_1=0x0005007C +sff_cpld_reg.len_81_1=1 +sff_cpld_reg.bit_offset_81_1=6 + +sff_cpld_reg.mode_82_1=config +sff_cpld_reg.src_82_1=cpld +sff_cpld_reg.frmt_82_1=bit +sff_cpld_reg.addr_82_1=0x0005007C +sff_cpld_reg.len_82_1=1 +sff_cpld_reg.bit_offset_82_1=6 + +sff_cpld_reg.mode_83_1=config +sff_cpld_reg.src_83_1=cpld +sff_cpld_reg.frmt_83_1=bit +sff_cpld_reg.addr_83_1=0x0005007C +sff_cpld_reg.len_83_1=1 +sff_cpld_reg.bit_offset_83_1=6 + +sff_cpld_reg.mode_84_1=config +sff_cpld_reg.src_84_1=cpld +sff_cpld_reg.frmt_84_1=bit +sff_cpld_reg.addr_84_1=0x0005007C +sff_cpld_reg.len_84_1=1 +sff_cpld_reg.bit_offset_84_1=6 + +sff_cpld_reg.mode_85_1=config +sff_cpld_reg.src_85_1=cpld +sff_cpld_reg.frmt_85_1=bit +sff_cpld_reg.addr_85_1=0x0005007C +sff_cpld_reg.len_85_1=1 +sff_cpld_reg.bit_offset_85_1=6 + +sff_cpld_reg.mode_86_1=config +sff_cpld_reg.src_86_1=cpld +sff_cpld_reg.frmt_86_1=bit +sff_cpld_reg.addr_86_1=0x0005007C +sff_cpld_reg.len_86_1=1 +sff_cpld_reg.bit_offset_86_1=6 + +sff_cpld_reg.mode_87_1=config +sff_cpld_reg.src_87_1=cpld +sff_cpld_reg.frmt_87_1=bit +sff_cpld_reg.addr_87_1=0x0005007C +sff_cpld_reg.len_87_1=1 +sff_cpld_reg.bit_offset_87_1=6 + +sff_cpld_reg.mode_88_1=config +sff_cpld_reg.src_88_1=cpld +sff_cpld_reg.frmt_88_1=bit +sff_cpld_reg.addr_88_1=0x0005007C +sff_cpld_reg.len_88_1=1 +sff_cpld_reg.bit_offset_88_1=6 + +sff_cpld_reg.mode_89_1=config +sff_cpld_reg.src_89_1=cpld +sff_cpld_reg.frmt_89_1=bit +sff_cpld_reg.addr_89_1=0x0005007C +sff_cpld_reg.len_89_1=1 +sff_cpld_reg.bit_offset_89_1=7 + +sff_cpld_reg.mode_90_1=config +sff_cpld_reg.src_90_1=cpld +sff_cpld_reg.frmt_90_1=bit +sff_cpld_reg.addr_90_1=0x0005007C +sff_cpld_reg.len_90_1=1 +sff_cpld_reg.bit_offset_90_1=7 + +sff_cpld_reg.mode_91_1=config +sff_cpld_reg.src_91_1=cpld +sff_cpld_reg.frmt_91_1=bit +sff_cpld_reg.addr_91_1=0x0005007C +sff_cpld_reg.len_91_1=1 +sff_cpld_reg.bit_offset_91_1=7 + +sff_cpld_reg.mode_92_1=config +sff_cpld_reg.src_92_1=cpld +sff_cpld_reg.frmt_92_1=bit +sff_cpld_reg.addr_92_1=0x0005007C +sff_cpld_reg.len_92_1=1 +sff_cpld_reg.bit_offset_92_1=7 + +sff_cpld_reg.mode_93_1=config +sff_cpld_reg.src_93_1=cpld +sff_cpld_reg.frmt_93_1=bit +sff_cpld_reg.addr_93_1=0x0005007C +sff_cpld_reg.len_93_1=1 +sff_cpld_reg.bit_offset_93_1=7 + +sff_cpld_reg.mode_94_1=config +sff_cpld_reg.src_94_1=cpld +sff_cpld_reg.frmt_94_1=bit +sff_cpld_reg.addr_94_1=0x0005007C +sff_cpld_reg.len_94_1=1 +sff_cpld_reg.bit_offset_94_1=7 + +sff_cpld_reg.mode_95_1=config +sff_cpld_reg.src_95_1=cpld +sff_cpld_reg.frmt_95_1=bit +sff_cpld_reg.addr_95_1=0x0005007C +sff_cpld_reg.len_95_1=1 +sff_cpld_reg.bit_offset_95_1=7 + +sff_cpld_reg.mode_96_1=config +sff_cpld_reg.src_96_1=cpld +sff_cpld_reg.frmt_96_1=bit +sff_cpld_reg.addr_96_1=0x0005007C +sff_cpld_reg.len_96_1=1 +sff_cpld_reg.bit_offset_96_1=7 + +sff_cpld_reg.mode_97_1=config +sff_cpld_reg.src_97_1=cpld +sff_cpld_reg.frmt_97_1=bit +sff_cpld_reg.addr_97_1=0x00070080 +sff_cpld_reg.len_97_1=1 +sff_cpld_reg.bit_offset_97_1=0 + +sff_cpld_reg.mode_98_1=config +sff_cpld_reg.src_98_1=cpld +sff_cpld_reg.frmt_98_1=bit +sff_cpld_reg.addr_98_1=0x00070080 +sff_cpld_reg.len_98_1=1 +sff_cpld_reg.bit_offset_98_1=0 + +sff_cpld_reg.mode_99_1=config +sff_cpld_reg.src_99_1=cpld +sff_cpld_reg.frmt_99_1=bit +sff_cpld_reg.addr_99_1=0x00070080 +sff_cpld_reg.len_99_1=1 +sff_cpld_reg.bit_offset_99_1=0 + +sff_cpld_reg.mode_100_1=config +sff_cpld_reg.src_100_1=cpld +sff_cpld_reg.frmt_100_1=bit +sff_cpld_reg.addr_100_1=0x00070080 +sff_cpld_reg.len_100_1=1 +sff_cpld_reg.bit_offset_100_1=0 + +sff_cpld_reg.mode_101_1=config +sff_cpld_reg.src_101_1=cpld +sff_cpld_reg.frmt_101_1=bit +sff_cpld_reg.addr_101_1=0x00070080 +sff_cpld_reg.len_101_1=1 +sff_cpld_reg.bit_offset_101_1=0 + +sff_cpld_reg.mode_102_1=config +sff_cpld_reg.src_102_1=cpld +sff_cpld_reg.frmt_102_1=bit +sff_cpld_reg.addr_102_1=0x00070080 +sff_cpld_reg.len_102_1=1 +sff_cpld_reg.bit_offset_102_1=0 + +sff_cpld_reg.mode_103_1=config +sff_cpld_reg.src_103_1=cpld +sff_cpld_reg.frmt_103_1=bit +sff_cpld_reg.addr_103_1=0x00070080 +sff_cpld_reg.len_103_1=1 +sff_cpld_reg.bit_offset_103_1=0 + +sff_cpld_reg.mode_104_1=config +sff_cpld_reg.src_104_1=cpld +sff_cpld_reg.frmt_104_1=bit +sff_cpld_reg.addr_104_1=0x00070080 +sff_cpld_reg.len_104_1=1 +sff_cpld_reg.bit_offset_104_1=0 + +sff_cpld_reg.mode_105_1=config +sff_cpld_reg.src_105_1=cpld +sff_cpld_reg.frmt_105_1=bit +sff_cpld_reg.addr_105_1=0x00070080 +sff_cpld_reg.len_105_1=1 +sff_cpld_reg.bit_offset_105_1=1 + +sff_cpld_reg.mode_106_1=config +sff_cpld_reg.src_106_1=cpld +sff_cpld_reg.frmt_106_1=bit +sff_cpld_reg.addr_106_1=0x00070080 +sff_cpld_reg.len_106_1=1 +sff_cpld_reg.bit_offset_106_1=1 + +sff_cpld_reg.mode_107_1=config +sff_cpld_reg.src_107_1=cpld +sff_cpld_reg.frmt_107_1=bit +sff_cpld_reg.addr_107_1=0x00070080 +sff_cpld_reg.len_107_1=1 +sff_cpld_reg.bit_offset_107_1=1 + +sff_cpld_reg.mode_108_1=config +sff_cpld_reg.src_108_1=cpld +sff_cpld_reg.frmt_108_1=bit +sff_cpld_reg.addr_108_1=0x00070080 +sff_cpld_reg.len_108_1=1 +sff_cpld_reg.bit_offset_108_1=1 + +sff_cpld_reg.mode_109_1=config +sff_cpld_reg.src_109_1=cpld +sff_cpld_reg.frmt_109_1=bit +sff_cpld_reg.addr_109_1=0x00070080 +sff_cpld_reg.len_109_1=1 +sff_cpld_reg.bit_offset_109_1=1 + +sff_cpld_reg.mode_110_1=config +sff_cpld_reg.src_110_1=cpld +sff_cpld_reg.frmt_110_1=bit +sff_cpld_reg.addr_110_1=0x00070080 +sff_cpld_reg.len_110_1=1 +sff_cpld_reg.bit_offset_110_1=1 + +sff_cpld_reg.mode_111_1=config +sff_cpld_reg.src_111_1=cpld +sff_cpld_reg.frmt_111_1=bit +sff_cpld_reg.addr_111_1=0x00070080 +sff_cpld_reg.len_111_1=1 +sff_cpld_reg.bit_offset_111_1=1 + +sff_cpld_reg.mode_112_1=config +sff_cpld_reg.src_112_1=cpld +sff_cpld_reg.frmt_112_1=bit +sff_cpld_reg.addr_112_1=0x00070080 +sff_cpld_reg.len_112_1=1 +sff_cpld_reg.bit_offset_112_1=1 + +sff_cpld_reg.mode_113_1=config +sff_cpld_reg.src_113_1=cpld +sff_cpld_reg.frmt_113_1=bit +sff_cpld_reg.addr_113_1=0x00070080 +sff_cpld_reg.len_113_1=1 +sff_cpld_reg.bit_offset_113_1=2 + +sff_cpld_reg.mode_114_1=config +sff_cpld_reg.src_114_1=cpld +sff_cpld_reg.frmt_114_1=bit +sff_cpld_reg.addr_114_1=0x00070080 +sff_cpld_reg.len_114_1=1 +sff_cpld_reg.bit_offset_114_1=2 + +sff_cpld_reg.mode_115_1=config +sff_cpld_reg.src_115_1=cpld +sff_cpld_reg.frmt_115_1=bit +sff_cpld_reg.addr_115_1=0x00070080 +sff_cpld_reg.len_115_1=1 +sff_cpld_reg.bit_offset_115_1=2 + +sff_cpld_reg.mode_116_1=config +sff_cpld_reg.src_116_1=cpld +sff_cpld_reg.frmt_116_1=bit +sff_cpld_reg.addr_116_1=0x00070080 +sff_cpld_reg.len_116_1=1 +sff_cpld_reg.bit_offset_116_1=2 + +sff_cpld_reg.mode_117_1=config +sff_cpld_reg.src_117_1=cpld +sff_cpld_reg.frmt_117_1=bit +sff_cpld_reg.addr_117_1=0x00070080 +sff_cpld_reg.len_117_1=1 +sff_cpld_reg.bit_offset_117_1=2 + +sff_cpld_reg.mode_118_1=config +sff_cpld_reg.src_118_1=cpld +sff_cpld_reg.frmt_118_1=bit +sff_cpld_reg.addr_118_1=0x00070080 +sff_cpld_reg.len_118_1=1 +sff_cpld_reg.bit_offset_118_1=2 + +sff_cpld_reg.mode_119_1=config +sff_cpld_reg.src_119_1=cpld +sff_cpld_reg.frmt_119_1=bit +sff_cpld_reg.addr_119_1=0x00070080 +sff_cpld_reg.len_119_1=1 +sff_cpld_reg.bit_offset_119_1=2 + +sff_cpld_reg.mode_120_1=config +sff_cpld_reg.src_120_1=cpld +sff_cpld_reg.frmt_120_1=bit +sff_cpld_reg.addr_120_1=0x00070080 +sff_cpld_reg.len_120_1=1 +sff_cpld_reg.bit_offset_120_1=2 + +sff_cpld_reg.mode_121_1=config +sff_cpld_reg.src_121_1=cpld +sff_cpld_reg.frmt_121_1=bit +sff_cpld_reg.addr_121_1=0x00070080 +sff_cpld_reg.len_121_1=1 +sff_cpld_reg.bit_offset_121_1=3 + +sff_cpld_reg.mode_122_1=config +sff_cpld_reg.src_122_1=cpld +sff_cpld_reg.frmt_122_1=bit +sff_cpld_reg.addr_122_1=0x00070080 +sff_cpld_reg.len_122_1=1 +sff_cpld_reg.bit_offset_122_1=3 + +sff_cpld_reg.mode_123_1=config +sff_cpld_reg.src_123_1=cpld +sff_cpld_reg.frmt_123_1=bit +sff_cpld_reg.addr_123_1=0x00070080 +sff_cpld_reg.len_123_1=1 +sff_cpld_reg.bit_offset_123_1=3 + +sff_cpld_reg.mode_124_1=config +sff_cpld_reg.src_124_1=cpld +sff_cpld_reg.frmt_124_1=bit +sff_cpld_reg.addr_124_1=0x00070080 +sff_cpld_reg.len_124_1=1 +sff_cpld_reg.bit_offset_124_1=3 + +sff_cpld_reg.mode_125_1=config +sff_cpld_reg.src_125_1=cpld +sff_cpld_reg.frmt_125_1=bit +sff_cpld_reg.addr_125_1=0x00070080 +sff_cpld_reg.len_125_1=1 +sff_cpld_reg.bit_offset_125_1=3 + +sff_cpld_reg.mode_126_1=config +sff_cpld_reg.src_126_1=cpld +sff_cpld_reg.frmt_126_1=bit +sff_cpld_reg.addr_126_1=0x00070080 +sff_cpld_reg.len_126_1=1 +sff_cpld_reg.bit_offset_126_1=3 + +sff_cpld_reg.mode_127_1=config +sff_cpld_reg.src_127_1=cpld +sff_cpld_reg.frmt_127_1=bit +sff_cpld_reg.addr_127_1=0x00070080 +sff_cpld_reg.len_127_1=1 +sff_cpld_reg.bit_offset_127_1=3 + +sff_cpld_reg.mode_128_1=config +sff_cpld_reg.src_128_1=cpld +sff_cpld_reg.frmt_128_1=bit +sff_cpld_reg.addr_128_1=0x00070080 +sff_cpld_reg.len_128_1=1 +sff_cpld_reg.bit_offset_128_1=3 + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-V2-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-V2-SENSOR.cfg new file mode 100755 index 000000000000..6cf1bc3adfc8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/cfg_file/TCS9400-V2-SENSOR.cfg @@ -0,0 +1,2405 @@ +# temp sensor number +dev_num_0_1=34 + +# voltage sensor number +dev_num_0_2=56 + +# current sensor number +dev_num_0_3=7 + +# sensor temp1 input +hwmon_temp.mode_0x0001_0x00=config +hwmon_temp.int_cons_0x0001_0x00=0 +hwmon_temp.src_0x0001_0x00=file +hwmon_temp.frmt_0x0001_0x00=buf +hwmon_temp.fpath_0x0001_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x00=0 +hwmon_temp.len_0x0001_0x00=8 +hwmon_temp.bit_offset_0x0001_0x00= +hwmon_temp.str_cons_0x0001_0x00=temp1_input + +# sensor temp1 alias +hwmon_temp.mode_0x0001_0x01=config +hwmon_temp.int_cons_0x0001_0x01= +hwmon_temp.src_0x0001_0x01=file +hwmon_temp.frmt_0x0001_0x01=buf +hwmon_temp.fpath_0x0001_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x01=0 +hwmon_temp.len_0x0001_0x01=16 +hwmon_temp.bit_offset_0x0001_0x01= +hwmon_temp.str_cons_0x0001_0x01=temp1_label + +hwmon_temp.mode_0x0001_0x02=str_constant +hwmon_temp.str_cons_0x0001_0x02=cpu + +# sensor temp1 max +hwmon_temp.mode_0x0001_0x03=config +hwmon_temp.int_cons_0x0001_0x03=0 +hwmon_temp.src_0x0001_0x03=file +hwmon_temp.frmt_0x0001_0x03=buf +hwmon_temp.fpath_0x0001_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0001_0x03=0 +hwmon_temp.len_0x0001_0x03=8 +hwmon_temp.bit_offset_0x0001_0x03= +hwmon_temp.str_cons_0x0001_0x03=temp1_max + + +# sensor temp2 input +hwmon_temp.mode_0x0002_0x00=config +hwmon_temp.int_cons_0x0002_0x00=0 +hwmon_temp.src_0x0002_0x00=file +hwmon_temp.frmt_0x0002_0x00=buf +hwmon_temp.fpath_0x0002_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x00=0 +hwmon_temp.len_0x0002_0x00=8 +hwmon_temp.bit_offset_0x0002_0x00= +hwmon_temp.str_cons_0x0002_0x00=temp2_input + +# sensor temp2 alias +hwmon_temp.mode_0x0002_0x01=config +hwmon_temp.int_cons_0x0002_0x01= +hwmon_temp.src_0x0002_0x01=file +hwmon_temp.frmt_0x0002_0x01=buf +hwmon_temp.fpath_0x0002_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x01=0 +hwmon_temp.len_0x0002_0x01=16 +hwmon_temp.bit_offset_0x0002_0x01= +hwmon_temp.str_cons_0x0002_0x01=temp2_label + +hwmon_temp.mode_0x0002_0x02=str_constant +hwmon_temp.str_cons_0x0002_0x02=cpu + +# sensor temp2 max +hwmon_temp.mode_0x0002_0x03=config +hwmon_temp.int_cons_0x0002_0x03=0 +hwmon_temp.src_0x0002_0x03=file +hwmon_temp.frmt_0x0002_0x03=buf +hwmon_temp.fpath_0x0002_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0002_0x03=0 +hwmon_temp.len_0x0002_0x03=8 +hwmon_temp.bit_offset_0x0002_0x03= +hwmon_temp.str_cons_0x0002_0x03=temp2_max + + +# sensor temp3 input +hwmon_temp.mode_0x0003_0x00=config +hwmon_temp.int_cons_0x0003_0x00=0 +hwmon_temp.src_0x0003_0x00=file +hwmon_temp.frmt_0x0003_0x00=buf +hwmon_temp.fpath_0x0003_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x00=0 +hwmon_temp.len_0x0003_0x00=8 +hwmon_temp.bit_offset_0x0003_0x00= +hwmon_temp.str_cons_0x0003_0x00=temp3_input + +# sensor temp3 alias +hwmon_temp.mode_0x0003_0x01=config +hwmon_temp.int_cons_0x0003_0x01= +hwmon_temp.src_0x0003_0x01=file +hwmon_temp.frmt_0x0003_0x01=buf +hwmon_temp.fpath_0x0003_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x01=0 +hwmon_temp.len_0x0003_0x01=16 +hwmon_temp.bit_offset_0x0003_0x01= +hwmon_temp.str_cons_0x0003_0x01=temp3_label + +hwmon_temp.mode_0x0003_0x02=str_constant +hwmon_temp.str_cons_0x0003_0x02=cpu + +# sensor temp3 max +hwmon_temp.mode_0x0003_0x03=config +hwmon_temp.int_cons_0x0003_0x03=0 +hwmon_temp.src_0x0003_0x03=file +hwmon_temp.frmt_0x0003_0x03=buf +hwmon_temp.fpath_0x0003_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0003_0x03=0 +hwmon_temp.len_0x0003_0x03=8 +hwmon_temp.bit_offset_0x0003_0x03= +hwmon_temp.str_cons_0x0003_0x03=temp3_max + + +# sensor temp4 input +hwmon_temp.mode_0x0004_0x00=config +hwmon_temp.int_cons_0x0004_0x00=0 +hwmon_temp.src_0x0004_0x00=file +hwmon_temp.frmt_0x0004_0x00=buf +hwmon_temp.fpath_0x0004_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x00=0 +hwmon_temp.len_0x0004_0x00=8 +hwmon_temp.bit_offset_0x0004_0x00= +hwmon_temp.str_cons_0x0004_0x00=temp4_input + +# sensor temp4 alias +hwmon_temp.mode_0x0004_0x01=config +hwmon_temp.int_cons_0x0004_0x01= +hwmon_temp.src_0x0004_0x01=file +hwmon_temp.frmt_0x0004_0x01=buf +hwmon_temp.fpath_0x0004_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x01=0 +hwmon_temp.len_0x0004_0x01=16 +hwmon_temp.bit_offset_0x0004_0x01= +hwmon_temp.str_cons_0x0004_0x01=temp4_label + +hwmon_temp.mode_0x0004_0x02=str_constant +hwmon_temp.str_cons_0x0004_0x02=cpu + +# sensor temp4 max +hwmon_temp.mode_0x0004_0x03=config +hwmon_temp.int_cons_0x0004_0x03=0 +hwmon_temp.src_0x0004_0x03=file +hwmon_temp.frmt_0x0004_0x03=buf +hwmon_temp.fpath_0x0004_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0004_0x03=0 +hwmon_temp.len_0x0004_0x03=8 +hwmon_temp.bit_offset_0x0004_0x03= +hwmon_temp.str_cons_0x0004_0x03=temp4_max + + +# sensor temp5 input +hwmon_temp.mode_0x0005_0x00=config +hwmon_temp.int_cons_0x0005_0x00=0 +hwmon_temp.src_0x0005_0x00=file +hwmon_temp.frmt_0x0005_0x00=buf +hwmon_temp.fpath_0x0005_0x00=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x00=0 +hwmon_temp.len_0x0005_0x00=8 +hwmon_temp.bit_offset_0x0005_0x00= +hwmon_temp.str_cons_0x0005_0x00=temp5_input + +# sensor temp5 alias +hwmon_temp.mode_0x0005_0x01=config +hwmon_temp.int_cons_0x0005_0x01= +hwmon_temp.src_0x0005_0x01=file +hwmon_temp.frmt_0x0005_0x01=buf +hwmon_temp.fpath_0x0005_0x01=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x01=0 +hwmon_temp.len_0x0005_0x01=16 +hwmon_temp.bit_offset_0x0005_0x01= +hwmon_temp.str_cons_0x0005_0x01=temp5_label + +hwmon_temp.mode_0x0005_0x02=str_constant +hwmon_temp.str_cons_0x0005_0x02=cpu + +# sensor temp5 max +hwmon_temp.mode_0x0005_0x03=config +hwmon_temp.int_cons_0x0005_0x03=0 +hwmon_temp.src_0x0005_0x03=file +hwmon_temp.frmt_0x0005_0x03=buf +hwmon_temp.fpath_0x0005_0x03=/sys/devices/platform/coretemp.0/hwmon/ +hwmon_temp.addr_0x0005_0x03=0 +hwmon_temp.len_0x0005_0x03=8 +hwmon_temp.bit_offset_0x0005_0x03= +hwmon_temp.str_cons_0x0005_0x03=temp5_max + +# sensor temp6 input +hwmon_temp.mode_0x0006_0x00=config +hwmon_temp.int_cons_0x0006_0x00=0 +hwmon_temp.src_0x0006_0x00=file +hwmon_temp.frmt_0x0006_0x00=buf +hwmon_temp.fpath_0x0006_0x00=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x00=0 +hwmon_temp.len_0x0006_0x00=8 +hwmon_temp.bit_offset_0x0006_0x00= +hwmon_temp.str_cons_0x0006_0x00=temp1_input + +hwmon_temp.mode_0x0006_0x01=str_constant +hwmon_temp.str_cons_0x0006_0x01=air_inlet + +hwmon_temp.mode_0x0006_0x02=str_constant +hwmon_temp.str_cons_0x0006_0x02=lm75 + +hwmon_temp.mode_0x0006_0x03=config +hwmon_temp.int_cons_0x0006_0x03=0 +hwmon_temp.src_0x0006_0x03=file +hwmon_temp.frmt_0x0006_0x03=buf +hwmon_temp.fpath_0x0006_0x03=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x03=0 +hwmon_temp.len_0x0006_0x03=8 +hwmon_temp.bit_offset_0x0006_0x03= +hwmon_temp.str_cons_0x0006_0x03=temp1_max + +hwmon_temp.mode_0x0006_0x04=config +hwmon_temp.int_cons_0x0006_0x04=0 +hwmon_temp.src_0x0006_0x04=file +hwmon_temp.frmt_0x0006_0x04=buf +hwmon_temp.fpath_0x0006_0x04=/sys/bus/i2c/devices/107-004b/hwmon/ +hwmon_temp.addr_0x0006_0x04=0 +hwmon_temp.len_0x0006_0x04=8 +hwmon_temp.bit_offset_0x0006_0x04= +hwmon_temp.str_cons_0x0006_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0007_0x00=config +hwmon_temp.int_cons_0x0007_0x00=0 +hwmon_temp.src_0x0007_0x00=file +hwmon_temp.frmt_0x0007_0x00=buf +hwmon_temp.fpath_0x0007_0x00=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x00=0 +hwmon_temp.len_0x0007_0x00=8 +hwmon_temp.bit_offset_0x0007_0x00= +hwmon_temp.str_cons_0x0007_0x00=temp1_input + +hwmon_temp.mode_0x0007_0x01=str_constant +hwmon_temp.str_cons_0x0007_0x01=Uport_air_inlet_L + +hwmon_temp.mode_0x0007_0x02=str_constant +hwmon_temp.str_cons_0x0007_0x02=lm75 + +hwmon_temp.mode_0x0007_0x03=config +hwmon_temp.int_cons_0x0007_0x03=0 +hwmon_temp.src_0x0007_0x03=file +hwmon_temp.frmt_0x0007_0x03=buf +hwmon_temp.fpath_0x0007_0x03=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x03=0 +hwmon_temp.len_0x0007_0x03=8 +hwmon_temp.bit_offset_0x0007_0x03= +hwmon_temp.str_cons_0x0007_0x03=temp1_max + +hwmon_temp.mode_0x0007_0x04=config +hwmon_temp.int_cons_0x0007_0x04=0 +hwmon_temp.src_0x0007_0x04=file +hwmon_temp.frmt_0x0007_0x04=buf +hwmon_temp.fpath_0x0007_0x04=/sys/bus/i2c/devices/64-004f/hwmon/ +hwmon_temp.addr_0x0007_0x04=0 +hwmon_temp.len_0x0007_0x04=8 +hwmon_temp.bit_offset_0x0007_0x04= +hwmon_temp.str_cons_0x0007_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0008_0x00=config +hwmon_temp.int_cons_0x0008_0x00=0 +hwmon_temp.src_0x0008_0x00=file +hwmon_temp.frmt_0x0008_0x00=buf +hwmon_temp.fpath_0x0008_0x00=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x00=0 +hwmon_temp.len_0x0008_0x00=8 +hwmon_temp.bit_offset_0x0008_0x00= +hwmon_temp.str_cons_0x0008_0x00=temp1_input + +hwmon_temp.mode_0x0008_0x01=str_constant +hwmon_temp.str_cons_0x0008_0x01=Uport_air_inlet_R + +hwmon_temp.mode_0x0008_0x02=str_constant +hwmon_temp.str_cons_0x0008_0x02=lm75 + +hwmon_temp.mode_0x0008_0x03=config +hwmon_temp.int_cons_0x0008_0x03=0 +hwmon_temp.src_0x0008_0x03=file +hwmon_temp.frmt_0x0008_0x03=buf +hwmon_temp.fpath_0x0008_0x03=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x03=0 +hwmon_temp.len_0x0008_0x03=8 +hwmon_temp.bit_offset_0x0008_0x03= +hwmon_temp.str_cons_0x0008_0x03=temp1_max + +hwmon_temp.mode_0x0008_0x04=config +hwmon_temp.int_cons_0x0008_0x04=0 +hwmon_temp.src_0x0008_0x04=file +hwmon_temp.frmt_0x0008_0x04=buf +hwmon_temp.fpath_0x0008_0x04=/sys/bus/i2c/devices/63-004b/hwmon/ +hwmon_temp.addr_0x0008_0x04=0 +hwmon_temp.len_0x0008_0x04=8 +hwmon_temp.bit_offset_0x0008_0x04= +hwmon_temp.str_cons_0x0008_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0009_0x00=config +hwmon_temp.int_cons_0x0009_0x00=0 +hwmon_temp.src_0x0009_0x00=file +hwmon_temp.frmt_0x0009_0x00=buf +hwmon_temp.fpath_0x0009_0x00=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x00=0 +hwmon_temp.len_0x0009_0x00=8 +hwmon_temp.bit_offset_0x0009_0x00= +hwmon_temp.str_cons_0x0009_0x00=temp1_input + +hwmon_temp.mode_0x0009_0x01=str_constant +hwmon_temp.str_cons_0x0009_0x01=Dport_air_inlet_L + +hwmon_temp.mode_0x0009_0x02=str_constant +hwmon_temp.str_cons_0x0009_0x02=lm75 + +hwmon_temp.mode_0x0009_0x03=config +hwmon_temp.int_cons_0x0009_0x03=0 +hwmon_temp.src_0x0009_0x03=file +hwmon_temp.frmt_0x0009_0x03=buf +hwmon_temp.fpath_0x0009_0x03=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x03=0 +hwmon_temp.len_0x0009_0x03=8 +hwmon_temp.bit_offset_0x0009_0x03= +hwmon_temp.str_cons_0x0009_0x03=temp1_max + +hwmon_temp.mode_0x0009_0x04=config +hwmon_temp.int_cons_0x0009_0x04=0 +hwmon_temp.src_0x0009_0x04=file +hwmon_temp.frmt_0x0009_0x04=buf +hwmon_temp.fpath_0x0009_0x04=/sys/bus/i2c/devices/114-004b/hwmon/ +hwmon_temp.addr_0x0009_0x04=0 +hwmon_temp.len_0x0009_0x04=8 +hwmon_temp.bit_offset_0x0009_0x04= +hwmon_temp.str_cons_0x0009_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000a_0x00=config +hwmon_temp.int_cons_0x000a_0x00=0 +hwmon_temp.src_0x000a_0x00=file +hwmon_temp.frmt_0x000a_0x00=buf +hwmon_temp.fpath_0x000a_0x00=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x00=0 +hwmon_temp.len_0x000a_0x00=8 +hwmon_temp.bit_offset_0x000a_0x00= +hwmon_temp.str_cons_0x000a_0x00=temp1_input + +hwmon_temp.mode_0x000a_0x01=str_constant +hwmon_temp.str_cons_0x000a_0x01=Dport_air_inlet_R + +hwmon_temp.mode_0x000a_0x02=str_constant +hwmon_temp.str_cons_0x000a_0x02=lm75 + +hwmon_temp.mode_0x000a_0x03=config +hwmon_temp.int_cons_0x000a_0x03=0 +hwmon_temp.src_0x000a_0x03=file +hwmon_temp.frmt_0x000a_0x03=buf +hwmon_temp.fpath_0x000a_0x03=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x03=0 +hwmon_temp.len_0x000a_0x03=8 +hwmon_temp.bit_offset_0x000a_0x03= +hwmon_temp.str_cons_0x000a_0x03=temp1_max + +hwmon_temp.mode_0x000a_0x04=config +hwmon_temp.int_cons_0x000a_0x04=0 +hwmon_temp.src_0x000a_0x04=file +hwmon_temp.frmt_0x000a_0x04=buf +hwmon_temp.fpath_0x000a_0x04=/sys/bus/i2c/devices/115-004f/hwmon/ +hwmon_temp.addr_0x000a_0x04=0 +hwmon_temp.len_0x000a_0x04=8 +hwmon_temp.bit_offset_0x000a_0x04= +hwmon_temp.str_cons_0x000a_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000b_0x00=config +hwmon_temp.int_cons_0x000b_0x00=0 +hwmon_temp.src_0x000b_0x00=file +hwmon_temp.frmt_0x000b_0x00=buf +hwmon_temp.fpath_0x000b_0x00=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x00=0 +hwmon_temp.len_0x000b_0x00=8 +hwmon_temp.bit_offset_0x000b_0x00= +hwmon_temp.str_cons_0x000b_0x00=temp1_input + +hwmon_temp.mode_0x000b_0x01=str_constant +hwmon_temp.str_cons_0x000b_0x01=MAC_air_inlet + +hwmon_temp.mode_0x000b_0x02=str_constant +hwmon_temp.str_cons_0x000b_0x02=lm75 + +hwmon_temp.mode_0x000b_0x03=config +hwmon_temp.int_cons_0x000b_0x03=0 +hwmon_temp.src_0x000b_0x03=file +hwmon_temp.frmt_0x000b_0x03=buf +hwmon_temp.fpath_0x000b_0x03=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x03=0 +hwmon_temp.len_0x000b_0x03=8 +hwmon_temp.bit_offset_0x000b_0x03= +hwmon_temp.str_cons_0x000b_0x03=temp1_max + +hwmon_temp.mode_0x000b_0x04=config +hwmon_temp.int_cons_0x000b_0x04=0 +hwmon_temp.src_0x000b_0x04=file +hwmon_temp.frmt_0x000b_0x04=buf +hwmon_temp.fpath_0x000b_0x04=/sys/bus/i2c/devices/69-004b/hwmon/ +hwmon_temp.addr_0x000b_0x04=0 +hwmon_temp.len_0x000b_0x04=8 +hwmon_temp.bit_offset_0x000b_0x04= +hwmon_temp.str_cons_0x000b_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000c_0x00=config +hwmon_temp.int_cons_0x000c_0x00=0 +hwmon_temp.src_0x000c_0x00=file +hwmon_temp.frmt_0x000c_0x00=buf +hwmon_temp.fpath_0x000c_0x00=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x00=0 +hwmon_temp.len_0x000c_0x00=8 +hwmon_temp.bit_offset_0x000c_0x00= +hwmon_temp.str_cons_0x000c_0x00=temp1_input + +hwmon_temp.mode_0x000c_0x01=str_constant +hwmon_temp.str_cons_0x000c_0x01=Base_air_inlet + +hwmon_temp.mode_0x000c_0x02=str_constant +hwmon_temp.str_cons_0x000c_0x02=lm75 + +hwmon_temp.mode_0x000c_0x03=config +hwmon_temp.int_cons_0x000c_0x03=0 +hwmon_temp.src_0x000c_0x03=file +hwmon_temp.frmt_0x000c_0x03=buf +hwmon_temp.fpath_0x000c_0x03=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x03=0 +hwmon_temp.len_0x000c_0x03=8 +hwmon_temp.bit_offset_0x000c_0x03= +hwmon_temp.str_cons_0x000c_0x03=temp1_max + +hwmon_temp.mode_0x000c_0x04=config +hwmon_temp.int_cons_0x000c_0x04=0 +hwmon_temp.src_0x000c_0x04=file +hwmon_temp.frmt_0x000c_0x04=buf +hwmon_temp.fpath_0x000c_0x04=/sys/bus/i2c/devices/109-004b/hwmon/ +hwmon_temp.addr_0x000c_0x04=0 +hwmon_temp.len_0x000c_0x04=8 +hwmon_temp.bit_offset_0x000c_0x04= +hwmon_temp.str_cons_0x000c_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000d_0x00=config +hwmon_temp.int_cons_0x000d_0x00=0 +hwmon_temp.src_0x000d_0x00=file +hwmon_temp.frmt_0x000d_0x00=buf +hwmon_temp.fpath_0x000d_0x00=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x00=0 +hwmon_temp.len_0x000d_0x00=8 +hwmon_temp.bit_offset_0x000d_0x00= +hwmon_temp.str_cons_0x000d_0x00=temp1_input + +hwmon_temp.mode_0x000d_0x01=str_constant +hwmon_temp.str_cons_0x000d_0x01=MAC_air_outlet + +hwmon_temp.mode_0x000d_0x02=str_constant +hwmon_temp.str_cons_0x000d_0x02=lm75 + +hwmon_temp.mode_0x000d_0x03=config +hwmon_temp.int_cons_0x000d_0x03=0 +hwmon_temp.src_0x000d_0x03=file +hwmon_temp.frmt_0x000d_0x03=buf +hwmon_temp.fpath_0x000d_0x03=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x03=0 +hwmon_temp.len_0x000d_0x03=8 +hwmon_temp.bit_offset_0x000d_0x03= +hwmon_temp.str_cons_0x000d_0x03=temp1_max + +hwmon_temp.mode_0x000d_0x04=config +hwmon_temp.int_cons_0x000d_0x04=0 +hwmon_temp.src_0x000d_0x04=file +hwmon_temp.frmt_0x000d_0x04=buf +hwmon_temp.fpath_0x000d_0x04=/sys/bus/i2c/devices/70-004f/hwmon/ +hwmon_temp.addr_0x000d_0x04=0 +hwmon_temp.len_0x000d_0x04=8 +hwmon_temp.bit_offset_0x000d_0x04= +hwmon_temp.str_cons_0x000d_0x04=temp1_max_hyst + +hwmon_temp.mode_0x000e_0x00=config +hwmon_temp.int_cons_0x000e_0x00=0 +hwmon_temp.src_0x000e_0x00=file +hwmon_temp.frmt_0x000e_0x00=buf +hwmon_temp.fpath_0x000e_0x00=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x00=0 +hwmon_temp.len_0x000e_0x00=8 +hwmon_temp.bit_offset_0x000e_0x00= +hwmon_temp.str_cons_0x000e_0x00=temp2_input + +hwmon_temp.mode_0x000e_0x01=str_constant +hwmon_temp.str_cons_0x000e_0x01=MAC_TEMPDIODE0 + +hwmon_temp.mode_0x000e_0x02=str_constant +hwmon_temp.str_cons_0x000e_0x02=tmp411 + +hwmon_temp.mode_0x000e_0x03=config +hwmon_temp.int_cons_0x000e_0x03=0 +hwmon_temp.src_0x000e_0x03=file +hwmon_temp.frmt_0x000e_0x03=buf +hwmon_temp.fpath_0x000e_0x03=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x03=0 +hwmon_temp.len_0x000e_0x03=8 +hwmon_temp.bit_offset_0x000e_0x03= +hwmon_temp.str_cons_0x000e_0x03=temp2_max + +hwmon_temp.mode_0x000e_0x04=config +hwmon_temp.int_cons_0x000e_0x04=0 +hwmon_temp.src_0x000e_0x04=file +hwmon_temp.frmt_0x000e_0x04=buf +hwmon_temp.fpath_0x000e_0x04=/sys/bus/i2c/devices/71-004c/hwmon/ +hwmon_temp.addr_0x000e_0x04=0 +hwmon_temp.len_0x000e_0x04=8 +hwmon_temp.bit_offset_0x000e_0x04= +hwmon_temp.str_cons_0x000e_0x04=temp2_max_hyst + +hwmon_temp.mode_0x000f_0x00=config +hwmon_temp.int_cons_0x000f_0x00=0 +hwmon_temp.src_0x000f_0x00=file +hwmon_temp.frmt_0x000f_0x00=buf +hwmon_temp.fpath_0x000f_0x00=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x00=0 +hwmon_temp.len_0x000f_0x00=8 +hwmon_temp.bit_offset_0x000f_0x00= +hwmon_temp.str_cons_0x000f_0x00=temp2_input + +hwmon_temp.mode_0x000f_0x01=str_constant +hwmon_temp.str_cons_0x000f_0x01=MAC_TEMPDIODE1 + +hwmon_temp.mode_0x000f_0x02=str_constant +hwmon_temp.str_cons_0x000f_0x02=tmp411 + +hwmon_temp.mode_0x000f_0x03=config +hwmon_temp.int_cons_0x000f_0x03=0 +hwmon_temp.src_0x000f_0x03=file +hwmon_temp.frmt_0x000f_0x03=buf +hwmon_temp.fpath_0x000f_0x03=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x03=0 +hwmon_temp.len_0x000f_0x03=8 +hwmon_temp.bit_offset_0x000f_0x03= +hwmon_temp.str_cons_0x000f_0x03=temp2_max + +hwmon_temp.mode_0x000f_0x04=config +hwmon_temp.int_cons_0x000f_0x04=0 +hwmon_temp.src_0x000f_0x04=file +hwmon_temp.frmt_0x000f_0x04=buf +hwmon_temp.fpath_0x000f_0x04=/sys/bus/i2c/devices/72-004c/hwmon/ +hwmon_temp.addr_0x000f_0x04=0 +hwmon_temp.len_0x000f_0x04=8 +hwmon_temp.bit_offset_0x000f_0x04= +hwmon_temp.str_cons_0x000f_0x04=temp2_max_hyst + +hwmon_temp.mode_0x0010_0x00=config +hwmon_temp.int_cons_0x0010_0x00=0 +hwmon_temp.src_0x0010_0x00=file +hwmon_temp.frmt_0x0010_0x00=buf +hwmon_temp.fpath_0x0010_0x00=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x00=0 +hwmon_temp.len_0x0010_0x00=8 +hwmon_temp.bit_offset_0x0010_0x00= +hwmon_temp.str_cons_0x0010_0x00=temp1_input + +hwmon_temp.mode_0x0010_0x01=str_constant +hwmon_temp.str_cons_0x0010_0x01=FCB_air_outlet_UL + +hwmon_temp.mode_0x0010_0x02=str_constant +hwmon_temp.str_cons_0x0010_0x02=lm75 + +hwmon_temp.mode_0x0010_0x03=config +hwmon_temp.int_cons_0x0010_0x03=0 +hwmon_temp.src_0x0010_0x03=file +hwmon_temp.frmt_0x0010_0x03=buf +hwmon_temp.fpath_0x0010_0x03=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x03=0 +hwmon_temp.len_0x0010_0x03=8 +hwmon_temp.bit_offset_0x0010_0x03= +hwmon_temp.str_cons_0x0010_0x03=temp1_max + +hwmon_temp.mode_0x0010_0x04=config +hwmon_temp.int_cons_0x0010_0x04=0 +hwmon_temp.src_0x0010_0x04=file +hwmon_temp.frmt_0x0010_0x04=buf +hwmon_temp.fpath_0x0010_0x04=/sys/bus/i2c/devices/88-0048/hwmon/ +hwmon_temp.addr_0x0010_0x04=0 +hwmon_temp.len_0x0010_0x04=8 +hwmon_temp.bit_offset_0x0010_0x04= +hwmon_temp.str_cons_0x0010_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0011_0x00=config +hwmon_temp.int_cons_0x0011_0x00=0 +hwmon_temp.src_0x0011_0x00=file +hwmon_temp.frmt_0x0011_0x00=buf +hwmon_temp.fpath_0x0011_0x00=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x00=0 +hwmon_temp.len_0x0011_0x00=8 +hwmon_temp.bit_offset_0x0011_0x00= +hwmon_temp.str_cons_0x0011_0x00=temp1_input + +hwmon_temp.mode_0x0011_0x01=str_constant +hwmon_temp.str_cons_0x0011_0x01=FCB_air_outlet_UR + +hwmon_temp.mode_0x0011_0x02=str_constant +hwmon_temp.str_cons_0x0011_0x02=lm75 + +hwmon_temp.mode_0x0011_0x03=config +hwmon_temp.int_cons_0x0011_0x03=0 +hwmon_temp.src_0x0011_0x03=file +hwmon_temp.frmt_0x0011_0x03=buf +hwmon_temp.fpath_0x0011_0x03=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x03=0 +hwmon_temp.len_0x0011_0x03=8 +hwmon_temp.bit_offset_0x0011_0x03= +hwmon_temp.str_cons_0x0011_0x03=temp1_max + +hwmon_temp.mode_0x0011_0x04=config +hwmon_temp.int_cons_0x0011_0x04=0 +hwmon_temp.src_0x0011_0x04=file +hwmon_temp.frmt_0x0011_0x04=buf +hwmon_temp.fpath_0x0011_0x04=/sys/bus/i2c/devices/89-0049/hwmon/ +hwmon_temp.addr_0x0011_0x04=0 +hwmon_temp.len_0x0011_0x04=8 +hwmon_temp.bit_offset_0x0011_0x04= +hwmon_temp.str_cons_0x0011_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0012_0x00=config +hwmon_temp.int_cons_0x0012_0x00=0 +hwmon_temp.src_0x0012_0x00=file +hwmon_temp.frmt_0x0012_0x00=buf +hwmon_temp.fpath_0x0012_0x00=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x00=0 +hwmon_temp.len_0x0012_0x00=8 +hwmon_temp.bit_offset_0x0012_0x00= +hwmon_temp.str_cons_0x0012_0x00=temp1_input + +hwmon_temp.mode_0x0012_0x01=str_constant +hwmon_temp.str_cons_0x0012_0x01=FCB_air_outlet_DL + +hwmon_temp.mode_0x0012_0x02=str_constant +hwmon_temp.str_cons_0x0012_0x02=lm75 + +hwmon_temp.mode_0x0012_0x03=config +hwmon_temp.int_cons_0x0012_0x03=0 +hwmon_temp.src_0x0012_0x03=file +hwmon_temp.frmt_0x0012_0x03=buf +hwmon_temp.fpath_0x0012_0x03=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x03=0 +hwmon_temp.len_0x0012_0x03=8 +hwmon_temp.bit_offset_0x0012_0x03= +hwmon_temp.str_cons_0x0012_0x03=temp1_max + +hwmon_temp.mode_0x0012_0x04=config +hwmon_temp.int_cons_0x0012_0x04=0 +hwmon_temp.src_0x0012_0x04=file +hwmon_temp.frmt_0x0012_0x04=buf +hwmon_temp.fpath_0x0012_0x04=/sys/bus/i2c/devices/96-0048/hwmon/ +hwmon_temp.addr_0x0012_0x04=0 +hwmon_temp.len_0x0012_0x04=8 +hwmon_temp.bit_offset_0x0012_0x04= +hwmon_temp.str_cons_0x0012_0x04=temp1_max_hyst + +hwmon_temp.mode_0x0013_0x00=config +hwmon_temp.int_cons_0x0013_0x00=0 +hwmon_temp.src_0x0013_0x00=file +hwmon_temp.frmt_0x0013_0x00=buf +hwmon_temp.fpath_0x0013_0x00=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x00=0 +hwmon_temp.len_0x0013_0x00=8 +hwmon_temp.bit_offset_0x0013_0x00= +hwmon_temp.str_cons_0x0013_0x00=temp1_input + +hwmon_temp.mode_0x0013_0x01=str_constant +hwmon_temp.str_cons_0x0013_0x01=FCB_air_outlet_DR + +hwmon_temp.mode_0x0013_0x02=str_constant +hwmon_temp.str_cons_0x0013_0x02=lm75 + +hwmon_temp.mode_0x0013_0x03=config +hwmon_temp.int_cons_0x0013_0x03=0 +hwmon_temp.src_0x0013_0x03=file +hwmon_temp.frmt_0x0013_0x03=buf +hwmon_temp.fpath_0x0013_0x03=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x03=0 +hwmon_temp.len_0x0013_0x03=8 +hwmon_temp.bit_offset_0x0013_0x03= +hwmon_temp.str_cons_0x0013_0x03=temp1_max + +hwmon_temp.mode_0x0013_0x04=config +hwmon_temp.int_cons_0x0013_0x04=0 +hwmon_temp.src_0x0013_0x04=file +hwmon_temp.frmt_0x0013_0x04=buf +hwmon_temp.fpath_0x0013_0x04=/sys/bus/i2c/devices/97-0049/hwmon/ +hwmon_temp.addr_0x0013_0x04=0 +hwmon_temp.len_0x0013_0x04=8 +hwmon_temp.bit_offset_0x0013_0x04= +hwmon_temp.str_cons_0x0013_0x04=temp1_max_hyst + + +# sensor temp20 input +hwmon_temp.mode_0x0014_0x00=config +hwmon_temp.int_cons_0x0014_0x00=0 +hwmon_temp.src_0x0014_0x00=file +hwmon_temp.frmt_0x0014_0x00=buf +hwmon_temp.fpath_0x0014_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0014_0x00=0 +hwmon_temp.len_0x0014_0x00=16 +hwmon_temp.bit_offset_0x0014_0x00= +hwmon_temp.str_cons_0x0014_0x00=temp1_input + +# sensor temp20 alias +hwmon_temp.mode_0x0014_0x01=str_constant +hwmon_temp.str_cons_0x0014_0x01=MAC_DIE_0 + +# sensor temp20 type +hwmon_temp.mode_0x0014_0x02=str_constant +hwmon_temp.str_cons_0x0014_0x02=mac_bsc + + +# sensor temp21 input +hwmon_temp.mode_0x0015_0x00=config +hwmon_temp.int_cons_0x0015_0x00=0 +hwmon_temp.src_0x0015_0x00=file +hwmon_temp.frmt_0x0015_0x00=buf +hwmon_temp.fpath_0x0015_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0015_0x00=0 +hwmon_temp.len_0x0015_0x00=16 +hwmon_temp.bit_offset_0x0015_0x00= +hwmon_temp.str_cons_0x0015_0x00=temp2_input + +# sensor temp21 alias +hwmon_temp.mode_0x0015_0x01=str_constant +hwmon_temp.str_cons_0x0015_0x01=MAC_DIE_1 + +# sensor temp21 type +hwmon_temp.mode_0x0015_0x02=str_constant +hwmon_temp.str_cons_0x0015_0x02=mac_bsc + + +# sensor temp22 input +hwmon_temp.mode_0x0016_0x00=config +hwmon_temp.int_cons_0x0016_0x00=0 +hwmon_temp.src_0x0016_0x00=file +hwmon_temp.frmt_0x0016_0x00=buf +hwmon_temp.fpath_0x0016_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0016_0x00=0 +hwmon_temp.len_0x0016_0x00=16 +hwmon_temp.bit_offset_0x0016_0x00= +hwmon_temp.str_cons_0x0016_0x00=temp3_input + +# sensor temp22 alias +hwmon_temp.mode_0x0016_0x01=str_constant +hwmon_temp.str_cons_0x0016_0x01=MAC_DIE_2 + +# sensor temp22 type +hwmon_temp.mode_0x0016_0x02=str_constant +hwmon_temp.str_cons_0x0016_0x02=mac_bsc + + +# sensor temp23 input +hwmon_temp.mode_0x0017_0x00=config +hwmon_temp.int_cons_0x0017_0x00=0 +hwmon_temp.src_0x0017_0x00=file +hwmon_temp.frmt_0x0017_0x00=buf +hwmon_temp.fpath_0x0017_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0017_0x00=0 +hwmon_temp.len_0x0017_0x00=16 +hwmon_temp.bit_offset_0x0017_0x00= +hwmon_temp.str_cons_0x0017_0x00=temp4_input + +# sensor temp23 alias +hwmon_temp.mode_0x0017_0x01=str_constant +hwmon_temp.str_cons_0x0017_0x01=MAC_DIE_3 + +# sensor temp23 type +hwmon_temp.mode_0x0017_0x02=str_constant +hwmon_temp.str_cons_0x0017_0x02=mac_bsc + + +# sensor temp24 input +hwmon_temp.mode_0x0018_0x00=config +hwmon_temp.int_cons_0x0018_0x00=0 +hwmon_temp.src_0x0018_0x00=file +hwmon_temp.frmt_0x0018_0x00=buf +hwmon_temp.fpath_0x0018_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0018_0x00=0 +hwmon_temp.len_0x0018_0x00=16 +hwmon_temp.bit_offset_0x0018_0x00= +hwmon_temp.str_cons_0x0018_0x00=temp5_input + +# sensor temp24 alias +hwmon_temp.mode_0x0018_0x01=str_constant +hwmon_temp.str_cons_0x0018_0x01=MAC_DIE_4 + +# sensor temp24 type +hwmon_temp.mode_0x0018_0x02=str_constant +hwmon_temp.str_cons_0x0018_0x02=mac_bsc + + +# sensor temp25 input +hwmon_temp.mode_0x0019_0x00=config +hwmon_temp.int_cons_0x0019_0x00=0 +hwmon_temp.src_0x0019_0x00=file +hwmon_temp.frmt_0x0019_0x00=buf +hwmon_temp.fpath_0x0019_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0019_0x00=0 +hwmon_temp.len_0x0019_0x00=16 +hwmon_temp.bit_offset_0x0019_0x00= +hwmon_temp.str_cons_0x0019_0x00=temp6_input + +# sensor temp25 alias +hwmon_temp.mode_0x0019_0x01=str_constant +hwmon_temp.str_cons_0x0019_0x01=MAC_DIE_5 + +# sensor temp25 type +hwmon_temp.mode_0x0019_0x02=str_constant +hwmon_temp.str_cons_0x0019_0x02=mac_bsc + + +# sensor temp26 input +hwmon_temp.mode_0x001a_0x00=config +hwmon_temp.int_cons_0x001a_0x00=0 +hwmon_temp.src_0x001a_0x00=file +hwmon_temp.frmt_0x001a_0x00=buf +hwmon_temp.fpath_0x001a_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001a_0x00=0 +hwmon_temp.len_0x001a_0x00=16 +hwmon_temp.bit_offset_0x001a_0x00= +hwmon_temp.str_cons_0x001a_0x00=temp7_input + +# sensor temp26 alias +hwmon_temp.mode_0x001a_0x01=str_constant +hwmon_temp.str_cons_0x001a_0x01=MAC_DIE_6 + +# sensor temp26 type +hwmon_temp.mode_0x001a_0x02=str_constant +hwmon_temp.str_cons_0x001a_0x02=mac_bsc + + +# sensor temp27 input +hwmon_temp.mode_0x001b_0x00=config +hwmon_temp.int_cons_0x001b_0x00=0 +hwmon_temp.src_0x001b_0x00=file +hwmon_temp.frmt_0x001b_0x00=buf +hwmon_temp.fpath_0x001b_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001b_0x00=0 +hwmon_temp.len_0x001b_0x00=16 +hwmon_temp.bit_offset_0x001b_0x00= +hwmon_temp.str_cons_0x001b_0x00=temp8_input + +# sensor temp27 alias +hwmon_temp.mode_0x001b_0x01=str_constant +hwmon_temp.str_cons_0x001b_0x01=MAC_DIE_7 + +# sensor temp27 type +hwmon_temp.mode_0x001b_0x02=str_constant +hwmon_temp.str_cons_0x001b_0x02=mac_bsc + + +# sensor temp28 input +hwmon_temp.mode_0x001c_0x00=config +hwmon_temp.int_cons_0x001c_0x00=0 +hwmon_temp.src_0x001c_0x00=file +hwmon_temp.frmt_0x001c_0x00=buf +hwmon_temp.fpath_0x001c_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001c_0x00=0 +hwmon_temp.len_0x001c_0x00=16 +hwmon_temp.bit_offset_0x001c_0x00= +hwmon_temp.str_cons_0x001c_0x00=temp9_input + +# sensor temp28 alias +hwmon_temp.mode_0x001c_0x01=str_constant +hwmon_temp.str_cons_0x001c_0x01=MAC_DIE_8 + +# sensor temp28 type +hwmon_temp.mode_0x001c_0x02=str_constant +hwmon_temp.str_cons_0x001c_0x02=mac_bsc + + +# sensor temp29 input +hwmon_temp.mode_0x001d_0x00=config +hwmon_temp.int_cons_0x001d_0x00=0 +hwmon_temp.src_0x001d_0x00=file +hwmon_temp.frmt_0x001d_0x00=buf +hwmon_temp.fpath_0x001d_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001d_0x00=0 +hwmon_temp.len_0x001d_0x00=16 +hwmon_temp.bit_offset_0x001d_0x00= +hwmon_temp.str_cons_0x001d_0x00=temp10_input + +# sensor temp29 alias +hwmon_temp.mode_0x001d_0x01=str_constant +hwmon_temp.str_cons_0x001d_0x01=MAC_DIE_9 + +# sensor temp29 type +hwmon_temp.mode_0x001d_0x02=str_constant +hwmon_temp.str_cons_0x001d_0x02=mac_bsc + + +# sensor temp30 input +hwmon_temp.mode_0x001e_0x00=config +hwmon_temp.int_cons_0x001e_0x00=0 +hwmon_temp.src_0x001e_0x00=file +hwmon_temp.frmt_0x001e_0x00=buf +hwmon_temp.fpath_0x001e_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001e_0x00=0 +hwmon_temp.len_0x001e_0x00=16 +hwmon_temp.bit_offset_0x001e_0x00= +hwmon_temp.str_cons_0x001e_0x00=temp11_input + +# sensor temp30 alias +hwmon_temp.mode_0x001e_0x01=str_constant +hwmon_temp.str_cons_0x001e_0x01=MAC_DIE_10 + +# sensor temp30 type +hwmon_temp.mode_0x001e_0x02=str_constant +hwmon_temp.str_cons_0x001e_0x02=mac_bsc + + +# sensor temp31 input +hwmon_temp.mode_0x001f_0x00=config +hwmon_temp.int_cons_0x001f_0x00=0 +hwmon_temp.src_0x001f_0x00=file +hwmon_temp.frmt_0x001f_0x00=buf +hwmon_temp.fpath_0x001f_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x001f_0x00=0 +hwmon_temp.len_0x001f_0x00=16 +hwmon_temp.bit_offset_0x001f_0x00= +hwmon_temp.str_cons_0x001f_0x00=temp12_input + +# sensor temp31 alias +hwmon_temp.mode_0x001f_0x01=str_constant +hwmon_temp.str_cons_0x001f_0x01=MAC_DIE_11 + +# sensor temp31 type +hwmon_temp.mode_0x001f_0x02=str_constant +hwmon_temp.str_cons_0x001f_0x02=mac_bsc + + +# sensor temp32 input +hwmon_temp.mode_0x0020_0x00=config +hwmon_temp.int_cons_0x0020_0x00=0 +hwmon_temp.src_0x0020_0x00=file +hwmon_temp.frmt_0x0020_0x00=buf +hwmon_temp.fpath_0x0020_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0020_0x00=0 +hwmon_temp.len_0x0020_0x00=16 +hwmon_temp.bit_offset_0x0020_0x00= +hwmon_temp.str_cons_0x0020_0x00=temp13_input + +# sensor temp32 alias +hwmon_temp.mode_0x0020_0x01=str_constant +hwmon_temp.str_cons_0x0020_0x01=MAC_DIE_12 + +# sensor temp32 type +hwmon_temp.mode_0x0020_0x02=str_constant +hwmon_temp.str_cons_0x0020_0x02=mac_bsc + + +# sensor temp33 input +hwmon_temp.mode_0x0021_0x00=config +hwmon_temp.int_cons_0x0021_0x00=0 +hwmon_temp.src_0x0021_0x00=file +hwmon_temp.frmt_0x0021_0x00=buf +hwmon_temp.fpath_0x0021_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0021_0x00=0 +hwmon_temp.len_0x0021_0x00=16 +hwmon_temp.bit_offset_0x0021_0x00= +hwmon_temp.str_cons_0x0021_0x00=temp14_input + +# sensor temp33 alias +hwmon_temp.mode_0x0021_0x01=str_constant +hwmon_temp.str_cons_0x0021_0x01=MAC_DIE_13 + +# sensor temp33 type +hwmon_temp.mode_0x0021_0x02=str_constant +hwmon_temp.str_cons_0x0021_0x02=mac_bsc + + +# sensor temp34 input +hwmon_temp.mode_0x0022_0x00=config +hwmon_temp.int_cons_0x0022_0x00=0 +hwmon_temp.src_0x0022_0x00=file +hwmon_temp.frmt_0x0022_0x00=buf +hwmon_temp.fpath_0x0022_0x00=/sys/bus/i2c/devices/74-0044/hwmon/ +hwmon_temp.addr_0x0022_0x00=0 +hwmon_temp.len_0x0022_0x00=16 +hwmon_temp.bit_offset_0x0022_0x00= +hwmon_temp.str_cons_0x0022_0x00=temp15_input + +# sensor temp34 alias +hwmon_temp.mode_0x0022_0x01=str_constant +hwmon_temp.str_cons_0x0022_0x01=MAC_DIE_14 + +# sensor temp34 type +hwmon_temp.mode_0x0022_0x02=str_constant +hwmon_temp.str_cons_0x0022_0x02=mac_bsc + + +# sensor vol +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=0 +hwmon_in.src_0x0001_0x00=file +hwmon_in.frmt_0x0001_0x00=buf +hwmon_in.fpath_0x0001_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0001_0x00=0 +hwmon_in.len_0x0001_0x00=8 +hwmon_in.bit_offset_0x0001_0x00= +hwmon_in.str_cons_0x0001_0x00=in1_input + +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_VDD_ANALOG1 + +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=ucd90160 + +hwmon_in.mode_0x0001_0x03=constant +hwmon_in.int_cons_0x0001_0x03=809 + +hwmon_in.mode_0x0001_0x05=constant +hwmon_in.int_cons_0x0001_0x05=731 + +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=0 +hwmon_in.src_0x0002_0x00=file +hwmon_in.frmt_0x0002_0x00=buf +hwmon_in.fpath_0x0002_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0002_0x00=0 +hwmon_in.len_0x0002_0x00=8 +hwmon_in.bit_offset_0x0002_0x00= +hwmon_in.str_cons_0x0002_0x00=in2_input + +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_VDD12V + +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=ucd90160 + +hwmon_in.mode_0x0002_0x03=constant +hwmon_in.int_cons_0x0002_0x03=12600 + +hwmon_in.mode_0x0002_0x05=constant +hwmon_in.int_cons_0x0002_0x05=11400 + +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=0 +hwmon_in.src_0x0003_0x00=file +hwmon_in.frmt_0x0003_0x00=buf +hwmon_in.fpath_0x0003_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0003_0x00=0 +hwmon_in.len_0x0003_0x00=8 +hwmon_in.bit_offset_0x0003_0x00= +hwmon_in.str_cons_0x0003_0x00=in3_input + +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_VDD1.0V_FPGA + +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=ucd90160 + +hwmon_in.mode_0x0003_0x03=constant +hwmon_in.int_cons_0x0003_0x03=1071 + +hwmon_in.mode_0x0003_0x05=constant +hwmon_in.int_cons_0x0003_0x05=969 + +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=0 +hwmon_in.src_0x0004_0x00=file +hwmon_in.frmt_0x0004_0x00=buf +hwmon_in.fpath_0x0004_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0004_0x00=0 +hwmon_in.len_0x0004_0x00=8 +hwmon_in.bit_offset_0x0004_0x00= +hwmon_in.str_cons_0x0004_0x00=in4_input + +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_VDD1.8V_FPGA + +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=ucd90160 + +hwmon_in.mode_0x0004_0x03=constant +hwmon_in.int_cons_0x0004_0x03=1890 + +hwmon_in.mode_0x0004_0x05=constant +hwmon_in.int_cons_0x0004_0x05=1710 + +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=0 +hwmon_in.src_0x0005_0x00=file +hwmon_in.frmt_0x0005_0x00=buf +hwmon_in.fpath_0x0005_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0005_0x00=0 +hwmon_in.len_0x0005_0x00=8 +hwmon_in.bit_offset_0x0005_0x00= +hwmon_in.str_cons_0x0005_0x00=in5_input + +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_VDD1.2V_FPGA + +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=ucd90160 + +hwmon_in.mode_0x0005_0x03=constant +hwmon_in.int_cons_0x0005_0x03=1260 + +hwmon_in.mode_0x0005_0x05=constant +hwmon_in.int_cons_0x0005_0x05=1140 + +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=0 +hwmon_in.src_0x0006_0x00=file +hwmon_in.frmt_0x0006_0x00=buf +hwmon_in.fpath_0x0006_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0006_0x00=0 +hwmon_in.len_0x0006_0x00=8 +hwmon_in.bit_offset_0x0006_0x00= +hwmon_in.str_cons_0x0006_0x00=in6_input + +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_VDD3.3V + +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=ucd90160 + +hwmon_in.mode_0x0006_0x03=constant +hwmon_in.int_cons_0x0006_0x03=3465 + +hwmon_in.mode_0x0006_0x05=constant +hwmon_in.int_cons_0x0006_0x05=3135 + +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=0 +hwmon_in.src_0x0007_0x00=file +hwmon_in.frmt_0x0007_0x00=buf +hwmon_in.fpath_0x0007_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0007_0x00=0 +hwmon_in.len_0x0007_0x00=8 +hwmon_in.bit_offset_0x0007_0x00= +hwmon_in.str_cons_0x0007_0x00=in7_input + +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_SW_VDD1.2V + +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=ucd90160 + +hwmon_in.mode_0x0007_0x03=constant +hwmon_in.int_cons_0x0007_0x03=1260 + +hwmon_in.mode_0x0007_0x05=constant +hwmon_in.int_cons_0x0007_0x05=1140 + +hwmon_in.mode_0x0008_0x00=config +hwmon_in.int_cons_0x0008_0x00=0 +hwmon_in.src_0x0008_0x00=file +hwmon_in.frmt_0x0008_0x00=buf +hwmon_in.fpath_0x0008_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0008_0x00=0 +hwmon_in.len_0x0008_0x00=8 +hwmon_in.bit_offset_0x0008_0x00= +hwmon_in.str_cons_0x0008_0x00=in8_input + +hwmon_in.mode_0x0008_0x01=str_constant +hwmon_in.str_cons_0x0008_0x01=MAC_VDD5V_CLK_MCU + +hwmon_in.mode_0x0008_0x02=str_constant +hwmon_in.str_cons_0x0008_0x02=ucd90160 + +hwmon_in.mode_0x0008_0x03=constant +hwmon_in.int_cons_0x0008_0x03=5334 + +hwmon_in.mode_0x0008_0x05=constant +hwmon_in.int_cons_0x0008_0x05=4826 + +hwmon_in.mode_0x0009_0x00=config +hwmon_in.int_cons_0x0009_0x00=0 +hwmon_in.src_0x0009_0x00=file +hwmon_in.frmt_0x0009_0x00=buf +hwmon_in.fpath_0x0009_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0009_0x00=0 +hwmon_in.len_0x0009_0x00=8 +hwmon_in.bit_offset_0x0009_0x00= +hwmon_in.str_cons_0x0009_0x00=in9_input + +hwmon_in.mode_0x0009_0x01=str_constant +hwmon_in.str_cons_0x0009_0x01=MAC_VDD5V_VR + +hwmon_in.mode_0x0009_0x02=str_constant +hwmon_in.str_cons_0x0009_0x02=ucd90160 + +hwmon_in.mode_0x0009_0x03=constant +hwmon_in.int_cons_0x0009_0x03=5334 + +hwmon_in.mode_0x0009_0x05=constant +hwmon_in.int_cons_0x0009_0x05=4826 + +hwmon_in.mode_0x000a_0x00=config +hwmon_in.int_cons_0x000a_0x00=0 +hwmon_in.src_0x000a_0x00=file +hwmon_in.frmt_0x000a_0x00=buf +hwmon_in.fpath_0x000a_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000a_0x00=0 +hwmon_in.len_0x000a_0x00=8 +hwmon_in.bit_offset_0x000a_0x00= +hwmon_in.str_cons_0x000a_0x00=in10_input + +hwmon_in.mode_0x000a_0x01=str_constant +hwmon_in.str_cons_0x000a_0x01=MAC_VDD3.3_CLK + +hwmon_in.mode_0x000a_0x02=str_constant +hwmon_in.str_cons_0x000a_0x02=ucd90160 + +hwmon_in.mode_0x000a_0x03=constant +hwmon_in.int_cons_0x000a_0x03=3486 + +hwmon_in.mode_0x000a_0x05=constant +hwmon_in.int_cons_0x000a_0x05=3154 + +hwmon_in.mode_0x000b_0x00=config +hwmon_in.int_cons_0x000b_0x00=0 +hwmon_in.src_0x000b_0x00=file +hwmon_in.frmt_0x000b_0x00=buf +hwmon_in.fpath_0x000b_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000b_0x00=0 +hwmon_in.len_0x000b_0x00=8 +hwmon_in.bit_offset_0x000b_0x00= +hwmon_in.str_cons_0x000b_0x00=in11_input + +hwmon_in.mode_0x000b_0x01=str_constant +hwmon_in.str_cons_0x000b_0x01=MAC_VDDO1.8V + +hwmon_in.mode_0x000b_0x02=str_constant +hwmon_in.str_cons_0x000b_0x02=ucd90160 + +hwmon_in.mode_0x000b_0x03=constant +hwmon_in.int_cons_0x000b_0x03=1901 + +hwmon_in.mode_0x000b_0x05=constant +hwmon_in.int_cons_0x000b_0x05=1719 + +hwmon_in.mode_0x000c_0x00=config +hwmon_in.int_cons_0x000c_0x00=0 +hwmon_in.src_0x000c_0x00=file +hwmon_in.frmt_0x000c_0x00=buf +hwmon_in.fpath_0x000c_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000c_0x00=0 +hwmon_in.len_0x000c_0x00=8 +hwmon_in.bit_offset_0x000c_0x00= +hwmon_in.str_cons_0x000c_0x00=in12_input + +hwmon_in.mode_0x000c_0x01=str_constant +hwmon_in.str_cons_0x000c_0x01=MAC_VDDO1.2V + +hwmon_in.mode_0x000c_0x02=str_constant +hwmon_in.str_cons_0x000c_0x02=ucd90160 + +hwmon_in.mode_0x000c_0x03=constant +hwmon_in.int_cons_0x000c_0x03=1260 + +hwmon_in.mode_0x000c_0x05=constant +hwmon_in.int_cons_0x000c_0x05=1140 + +hwmon_in.mode_0x000d_0x00=config +hwmon_in.int_cons_0x000d_0x00=0 +hwmon_in.src_0x000d_0x00=file +hwmon_in.frmt_0x000d_0x00=buf +hwmon_in.fpath_0x000d_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000d_0x00=0 +hwmon_in.len_0x000d_0x00=8 +hwmon_in.bit_offset_0x000d_0x00= +hwmon_in.str_cons_0x000d_0x00=in13_input + +hwmon_in.mode_0x000d_0x01=str_constant +hwmon_in.str_cons_0x000d_0x01=MAC_VDD_CORE + +hwmon_in.mode_0x000d_0x02=str_constant +hwmon_in.str_cons_0x000d_0x02=ucd90160 + +hwmon_in.mode_0x000d_0x03=constant +hwmon_in.int_cons_0x000d_0x03=950 + +hwmon_in.mode_0x000d_0x05=constant +hwmon_in.int_cons_0x000d_0x05=700 + +hwmon_in.mode_0x000e_0x00=config +hwmon_in.int_cons_0x000e_0x00=0 +hwmon_in.src_0x000e_0x00=file +hwmon_in.frmt_0x000e_0x00=buf +hwmon_in.fpath_0x000e_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000e_0x00=0 +hwmon_in.len_0x000e_0x00=8 +hwmon_in.bit_offset_0x000e_0x00= +hwmon_in.str_cons_0x000e_0x00=in14_input + +hwmon_in.mode_0x000e_0x01=str_constant +hwmon_in.str_cons_0x000e_0x01=MAC_VDD_ANALOG + +hwmon_in.mode_0x000e_0x02=str_constant +hwmon_in.str_cons_0x000e_0x02=ucd90160 + +hwmon_in.mode_0x000e_0x03=constant +hwmon_in.int_cons_0x000e_0x03=809 + +hwmon_in.mode_0x000e_0x05=constant +hwmon_in.int_cons_0x000e_0x05=731 + +hwmon_in.mode_0x000f_0x00=config +hwmon_in.int_cons_0x000f_0x00=0 +hwmon_in.src_0x000f_0x00=file +hwmon_in.frmt_0x000f_0x00=buf +hwmon_in.fpath_0x000f_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x000f_0x00=0 +hwmon_in.len_0x000f_0x00=8 +hwmon_in.bit_offset_0x000f_0x00= +hwmon_in.str_cons_0x000f_0x00=in15_input + +hwmon_in.mode_0x000f_0x01=str_constant +hwmon_in.str_cons_0x000f_0x01=MAC_VDD1.2V_MAC + +hwmon_in.mode_0x000f_0x02=str_constant +hwmon_in.str_cons_0x000f_0x02=ucd90160 + +hwmon_in.mode_0x000f_0x03=constant +hwmon_in.int_cons_0x000f_0x03=1260 + +hwmon_in.mode_0x000f_0x05=constant +hwmon_in.int_cons_0x000f_0x05=1140 + +hwmon_in.mode_0x0010_0x00=config +hwmon_in.int_cons_0x0010_0x00=0 +hwmon_in.src_0x0010_0x00=file +hwmon_in.frmt_0x0010_0x00=buf +hwmon_in.fpath_0x0010_0x00=/sys/bus/i2c/devices/73-005b/hwmon/ +hwmon_in.addr_0x0010_0x00=0 +hwmon_in.len_0x0010_0x00=8 +hwmon_in.bit_offset_0x0010_0x00= +hwmon_in.str_cons_0x0010_0x00=in16_input + +hwmon_in.mode_0x0010_0x01=str_constant +hwmon_in.str_cons_0x0010_0x01=MAC_AVDD1.8V + +hwmon_in.mode_0x0010_0x02=str_constant +hwmon_in.str_cons_0x0010_0x02=ucd90160 + +hwmon_in.mode_0x0010_0x03=constant +hwmon_in.int_cons_0x0010_0x03=1890 + +hwmon_in.mode_0x0010_0x05=constant +hwmon_in.int_cons_0x0010_0x05=1710 + +hwmon_in.mode_0x0011_0x00=config +hwmon_in.int_cons_0x0011_0x00=0 +hwmon_in.src_0x0011_0x00=file +hwmon_in.frmt_0x0011_0x00=buf +hwmon_in.fpath_0x0011_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0011_0x00=0 +hwmon_in.len_0x0011_0x00=8 +hwmon_in.bit_offset_0x0011_0x00= +hwmon_in.str_cons_0x0011_0x00=in1_input + +hwmon_in.mode_0x0011_0x01=str_constant +hwmon_in.str_cons_0x0011_0x01=BASE_VDD12V + +hwmon_in.mode_0x0011_0x02=str_constant +hwmon_in.str_cons_0x0011_0x02=ucd90160 + +hwmon_in.mode_0x0011_0x03=constant +hwmon_in.int_cons_0x0011_0x03=12600 + +hwmon_in.mode_0x0011_0x05=constant +hwmon_in.int_cons_0x0011_0x05=11400 + +hwmon_in.mode_0x0012_0x00=config +hwmon_in.int_cons_0x0012_0x00=0 +hwmon_in.src_0x0012_0x00=file +hwmon_in.frmt_0x0012_0x00=buf +hwmon_in.fpath_0x0012_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0012_0x00=0 +hwmon_in.len_0x0012_0x00=8 +hwmon_in.bit_offset_0x0012_0x00= +hwmon_in.str_cons_0x0012_0x00=in2_input + +hwmon_in.mode_0x0012_0x01=str_constant +hwmon_in.str_cons_0x0012_0x01=BASE_SW_VDD1.0V + +hwmon_in.mode_0x0012_0x02=str_constant +hwmon_in.str_cons_0x0012_0x02=ucd90160 + +hwmon_in.mode_0x0012_0x03=constant +hwmon_in.int_cons_0x0012_0x03=1050 + +hwmon_in.mode_0x0012_0x05=constant +hwmon_in.int_cons_0x0012_0x05=950 + + +hwmon_in.mode_0x0013_0x00=config +hwmon_in.int_cons_0x0013_0x00=0 +hwmon_in.src_0x0013_0x00=file +hwmon_in.frmt_0x0013_0x00=buf +hwmon_in.fpath_0x0013_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0013_0x00=0 +hwmon_in.len_0x0013_0x00=8 +hwmon_in.bit_offset_0x0013_0x00= +hwmon_in.str_cons_0x0013_0x00=in4_input + +hwmon_in.mode_0x0013_0x01=str_constant +hwmon_in.str_cons_0x0013_0x01=BASE_VDD3.3V + +hwmon_in.mode_0x0013_0x02=str_constant +hwmon_in.str_cons_0x0013_0x02=ucd90160 + +hwmon_in.mode_0x0013_0x03=constant +hwmon_in.int_cons_0x0013_0x03=3444 + +hwmon_in.mode_0x0013_0x05=constant +hwmon_in.int_cons_0x0013_0x05=3116 + + +hwmon_in.mode_0x0014_0x00=config +hwmon_in.int_cons_0x0014_0x00=0 +hwmon_in.src_0x0014_0x00=file +hwmon_in.frmt_0x0014_0x00=buf +hwmon_in.fpath_0x0014_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0014_0x00=0 +hwmon_in.len_0x0014_0x00=8 +hwmon_in.bit_offset_0x0014_0x00= +hwmon_in.str_cons_0x0014_0x00=in5_input + +hwmon_in.mode_0x0014_0x01=str_constant +hwmon_in.str_cons_0x0014_0x01=BASE_SW_OVDD + +hwmon_in.mode_0x0014_0x02=str_constant +hwmon_in.str_cons_0x0014_0x02=ucd90160 + +hwmon_in.mode_0x0014_0x03=constant +hwmon_in.int_cons_0x0014_0x03=3444 + +hwmon_in.mode_0x0014_0x05=constant +hwmon_in.int_cons_0x0014_0x05=3116 + + +hwmon_in.mode_0x0015_0x00=config +hwmon_in.int_cons_0x0015_0x00=0 +hwmon_in.src_0x0015_0x00=file +hwmon_in.frmt_0x0015_0x00=buf +hwmon_in.fpath_0x0015_0x00=/sys/bus/i2c/devices/105-005b/hwmon/ +hwmon_in.addr_0x0015_0x00=0 +hwmon_in.len_0x0015_0x00=8 +hwmon_in.bit_offset_0x0015_0x00= +hwmon_in.str_cons_0x0015_0x00=in6_input + +hwmon_in.mode_0x0015_0x01=str_constant +hwmon_in.str_cons_0x0015_0x01=BASE_SSD_VDD3.3V + +hwmon_in.mode_0x0015_0x02=str_constant +hwmon_in.str_cons_0x0015_0x02=ucd90160 + +hwmon_in.mode_0x0015_0x03=constant +hwmon_in.int_cons_0x0015_0x03=3465 + +hwmon_in.mode_0x0015_0x05=constant +hwmon_in.int_cons_0x0015_0x05=3135 + +hwmon_in.mode_0x0016_0x00=config +hwmon_in.int_cons_0x0016_0x00=0 +hwmon_in.src_0x0016_0x00=file +hwmon_in.frmt_0x0016_0x00=buf +hwmon_in.fpath_0x0016_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_in.addr_0x0016_0x00=0 +hwmon_in.len_0x0016_0x00=8 +hwmon_in.bit_offset_0x0016_0x00= +hwmon_in.str_cons_0x0016_0x00=in3_input + +hwmon_in.mode_0x0016_0x01=str_constant +hwmon_in.str_cons_0x0016_0x01=CPU_VCCIN + +hwmon_in.mode_0x0016_0x02=str_constant +hwmon_in.str_cons_0x0016_0x02=tps53622 + +hwmon_in.mode_0x0016_0x03=constant +hwmon_in.int_cons_0x0016_0x03=1950 + +hwmon_in.mode_0x0016_0x05=constant +hwmon_in.int_cons_0x0016_0x05=1600 + +hwmon_in.mode_0x0017_0x00=config +hwmon_in.int_cons_0x0017_0x00=0 +hwmon_in.src_0x0017_0x00=file +hwmon_in.frmt_0x0017_0x00=buf +hwmon_in.fpath_0x0017_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_in.addr_0x0017_0x00=0 +hwmon_in.len_0x0017_0x00=8 +hwmon_in.bit_offset_0x0017_0x00= +hwmon_in.str_cons_0x0017_0x00=in4_input + +hwmon_in.mode_0x0017_0x01=str_constant +hwmon_in.str_cons_0x0017_0x01=CPU_P1V05 + +hwmon_in.mode_0x0017_0x02=str_constant +hwmon_in.str_cons_0x0017_0x02=tps53622 + +hwmon_in.mode_0x0017_0x03=constant +hwmon_in.int_cons_0x0017_0x03=1100 + +hwmon_in.mode_0x0017_0x05=constant +hwmon_in.int_cons_0x0017_0x05=1000 + +hwmon_in.mode_0x0018_0x00=config +hwmon_in.int_cons_0x0018_0x00=0 +hwmon_in.src_0x0018_0x00=file +hwmon_in.frmt_0x0018_0x00=buf +hwmon_in.fpath_0x0018_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_in.addr_0x0018_0x00=0 +hwmon_in.len_0x0018_0x00=8 +hwmon_in.bit_offset_0x0018_0x00= +hwmon_in.str_cons_0x0018_0x00=in3_input + +hwmon_in.mode_0x0018_0x01=str_constant +hwmon_in.str_cons_0x0018_0x01=CPU_P1V2_VDDQ + +hwmon_in.mode_0x0018_0x02=str_constant +hwmon_in.str_cons_0x0018_0x02=tps53622 + +hwmon_in.mode_0x0018_0x03=constant +hwmon_in.int_cons_0x0018_0x03=1260 + +hwmon_in.mode_0x0018_0x05=constant +hwmon_in.int_cons_0x0018_0x05=1160 + +hwmon_in.mode_0x0019_0x00=config +hwmon_in.int_cons_0x0019_0x00=3 +hwmon_in.src_0x0019_0x00=file +hwmon_in.frmt_0x0019_0x00=buf +hwmon_in.fpath_0x0019_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_in.addr_0x0019_0x00=0 +hwmon_in.len_0x0019_0x00=8 +hwmon_in.bit_offset_0x0019_0x00=0 +hwmon_in.str_cons_0x0019_0x00=in4_input +hwmon_in.int_extra1_0x0019_0x00=1124 + +hwmon_in.mode_0x0019_0x01=str_constant +hwmon_in.str_cons_0x0019_0x01=CPU_P2V5_VPP + +hwmon_in.mode_0x0019_0x02=str_constant +hwmon_in.str_cons_0x0019_0x02=tps53622 + +hwmon_in.mode_0x0019_0x03=constant +hwmon_in.int_cons_0x0019_0x03=2750 + +hwmon_in.mode_0x0019_0x05=constant +hwmon_in.int_cons_0x0019_0x05=2375 + +hwmon_in.mode_0x001a_0x00=config +hwmon_in.int_cons_0x001a_0x00=0 +hwmon_in.src_0x001a_0x00=file +hwmon_in.frmt_0x001a_0x00=buf +hwmon_in.fpath_0x001a_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001a_0x00=0 +hwmon_in.len_0x001a_0x00=8 +hwmon_in.bit_offset_0x001a_0x00= +hwmon_in.str_cons_0x001a_0x00=in1_input + +hwmon_in.mode_0x001a_0x01=str_constant +hwmon_in.str_cons_0x001a_0x01=CPU_P3V3_STBY + +hwmon_in.mode_0x001a_0x02=str_constant +hwmon_in.str_cons_0x001a_0x02=ina3221 + +hwmon_in.mode_0x001a_0x03=constant +hwmon_in.int_cons_0x001a_0x03=3465 + +hwmon_in.mode_0x001a_0x05=constant +hwmon_in.int_cons_0x001a_0x05=3135 + +hwmon_in.mode_0x001b_0x00=config +hwmon_in.int_cons_0x001b_0x00=0 +hwmon_in.src_0x001b_0x00=file +hwmon_in.frmt_0x001b_0x00=buf +hwmon_in.fpath_0x001b_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001b_0x00=0 +hwmon_in.len_0x001b_0x00=8 +hwmon_in.bit_offset_0x001b_0x00= +hwmon_in.str_cons_0x001b_0x00=in2_input + +hwmon_in.mode_0x001b_0x01=str_constant +hwmon_in.str_cons_0x001b_0x01=CPU_P5V_AUX_IN + +hwmon_in.mode_0x001b_0x02=str_constant +hwmon_in.str_cons_0x001b_0x02=ina3221 + +hwmon_in.mode_0x001b_0x03=constant +hwmon_in.int_cons_0x001b_0x03=5500 + +hwmon_in.mode_0x001b_0x05=constant +hwmon_in.int_cons_0x001b_0x05=4250 + +hwmon_in.mode_0x001c_0x00=config +hwmon_in.int_cons_0x001c_0x00=0 +hwmon_in.src_0x001c_0x00=file +hwmon_in.frmt_0x001c_0x00=buf +hwmon_in.fpath_0x001c_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_in.addr_0x001c_0x00=0 +hwmon_in.len_0x001c_0x00=8 +hwmon_in.bit_offset_0x001c_0x00= +hwmon_in.str_cons_0x001c_0x00=in3_input + +hwmon_in.mode_0x001c_0x01=str_constant +hwmon_in.str_cons_0x001c_0x01=CPU_P1V7_VCCSCFUSESUS_IN + +hwmon_in.mode_0x001c_0x02=str_constant +hwmon_in.str_cons_0x001c_0x02=ina3221 + +hwmon_in.mode_0x001c_0x03=constant +hwmon_in.int_cons_0x001c_0x03=1785 + +hwmon_in.mode_0x001c_0x05=constant +hwmon_in.int_cons_0x001c_0x05=1615 + +hwmon_in.mode_0x001d_0x00=config +hwmon_in.int_cons_0x001d_0x00=0 +hwmon_in.src_0x001d_0x00=file +hwmon_in.frmt_0x001d_0x00=buf +hwmon_in.fpath_0x001d_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001d_0x00=0 +hwmon_in.len_0x001d_0x00=8 +hwmon_in.bit_offset_0x001d_0x00= +hwmon_in.str_cons_0x001d_0x00=in1_input + +hwmon_in.mode_0x001d_0x01=str_constant +hwmon_in.str_cons_0x001d_0x01=UPORT_VDD1.0V_FPGA + +hwmon_in.mode_0x001d_0x02=str_constant +hwmon_in.str_cons_0x001d_0x02=ucd90160 + +hwmon_in.mode_0x001d_0x03=constant +hwmon_in.int_cons_0x001d_0x03=1061 + +hwmon_in.mode_0x001d_0x05=constant +hwmon_in.int_cons_0x001d_0x05=959 + +hwmon_in.mode_0x001e_0x00=config +hwmon_in.int_cons_0x001e_0x00=0 +hwmon_in.src_0x001e_0x00=file +hwmon_in.frmt_0x001e_0x00=buf +hwmon_in.fpath_0x001e_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001e_0x00=0 +hwmon_in.len_0x001e_0x00=8 +hwmon_in.bit_offset_0x001e_0x00= +hwmon_in.str_cons_0x001e_0x00=in2_input + +hwmon_in.mode_0x001e_0x01=str_constant +hwmon_in.str_cons_0x001e_0x01=UPORT_VDD1.8V_FPGA + +hwmon_in.mode_0x001e_0x02=str_constant +hwmon_in.str_cons_0x001e_0x02=ucd90160 + +hwmon_in.mode_0x001e_0x03=constant +hwmon_in.int_cons_0x001e_0x03=1901 + +hwmon_in.mode_0x001e_0x05=constant +hwmon_in.int_cons_0x001e_0x05=1719 + +hwmon_in.mode_0x001f_0x00=config +hwmon_in.int_cons_0x001f_0x00=0 +hwmon_in.src_0x001f_0x00=file +hwmon_in.frmt_0x001f_0x00=buf +hwmon_in.fpath_0x001f_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x001f_0x00=0 +hwmon_in.len_0x001f_0x00=8 +hwmon_in.bit_offset_0x001f_0x00= +hwmon_in.str_cons_0x001f_0x00=in3_input + +hwmon_in.mode_0x001f_0x01=str_constant +hwmon_in.str_cons_0x001f_0x01=UPORT_VDD1.2V_FPGA + +hwmon_in.mode_0x001f_0x02=str_constant +hwmon_in.str_cons_0x001f_0x02=ucd90160 + +hwmon_in.mode_0x001f_0x03=constant +hwmon_in.int_cons_0x001f_0x03=1260 + +hwmon_in.mode_0x001f_0x05=constant +hwmon_in.int_cons_0x001f_0x05=1140 + +hwmon_in.mode_0x0020_0x00=config +hwmon_in.int_cons_0x0020_0x00=0 +hwmon_in.src_0x0020_0x00=file +hwmon_in.frmt_0x0020_0x00=buf +hwmon_in.fpath_0x0020_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0020_0x00=0 +hwmon_in.len_0x0020_0x00=8 +hwmon_in.bit_offset_0x0020_0x00= +hwmon_in.str_cons_0x0020_0x00=in4_input + +hwmon_in.mode_0x0020_0x01=str_constant +hwmon_in.str_cons_0x0020_0x01=UPORT_VDD3.3V + +hwmon_in.mode_0x0020_0x02=str_constant +hwmon_in.str_cons_0x0020_0x02=ucd90160 + +hwmon_in.mode_0x0020_0x03=constant +hwmon_in.int_cons_0x0020_0x03=3600 + +hwmon_in.mode_0x0020_0x05=constant +hwmon_in.int_cons_0x0020_0x05=3200 + +hwmon_in.mode_0x0021_0x00=config +hwmon_in.int_cons_0x0021_0x00=0 +hwmon_in.src_0x0021_0x00=file +hwmon_in.frmt_0x0021_0x00=buf +hwmon_in.fpath_0x0021_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0021_0x00=0 +hwmon_in.len_0x0021_0x00=8 +hwmon_in.bit_offset_0x0021_0x00= +hwmon_in.str_cons_0x0021_0x00=in5_input + +hwmon_in.mode_0x0021_0x01=str_constant +hwmon_in.str_cons_0x0021_0x01=UPORT_QSFP56_VDD3.3V_A + +hwmon_in.mode_0x0021_0x02=str_constant +hwmon_in.str_cons_0x0021_0x02=ucd90160 + +hwmon_in.mode_0x0021_0x03=constant +hwmon_in.int_cons_0x0021_0x03=3600 + +hwmon_in.mode_0x0021_0x05=constant +hwmon_in.int_cons_0x0021_0x05=3200 + +hwmon_in.mode_0x0022_0x00=config +hwmon_in.int_cons_0x0022_0x00=0 +hwmon_in.src_0x0022_0x00=file +hwmon_in.frmt_0x0022_0x00=buf +hwmon_in.fpath_0x0022_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0022_0x00=0 +hwmon_in.len_0x0022_0x00=8 +hwmon_in.bit_offset_0x0022_0x00= +hwmon_in.str_cons_0x0022_0x00=in6_input + +hwmon_in.mode_0x0022_0x01=str_constant +hwmon_in.str_cons_0x0022_0x01=UPORT_QSFP56_VDD3.3V_B + +hwmon_in.mode_0x0022_0x02=str_constant +hwmon_in.str_cons_0x0022_0x02=ucd90160 + +hwmon_in.mode_0x0022_0x03=constant +hwmon_in.int_cons_0x0022_0x03=3600 + +hwmon_in.mode_0x0022_0x05=constant +hwmon_in.int_cons_0x0022_0x05=3200 + +hwmon_in.mode_0x0023_0x00=config +hwmon_in.int_cons_0x0023_0x00=0 +hwmon_in.src_0x0023_0x00=file +hwmon_in.frmt_0x0023_0x00=buf +hwmon_in.fpath_0x0023_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0023_0x00=0 +hwmon_in.len_0x0023_0x00=8 +hwmon_in.bit_offset_0x0023_0x00= +hwmon_in.str_cons_0x0023_0x00=in7_input + +hwmon_in.mode_0x0023_0x01=str_constant +hwmon_in.str_cons_0x0023_0x01=UPORT_QSFP56_VDD3.3V_C + +hwmon_in.mode_0x0023_0x02=str_constant +hwmon_in.str_cons_0x0023_0x02=ucd90160 + +hwmon_in.mode_0x0023_0x03=constant +hwmon_in.int_cons_0x0023_0x03=3600 + +hwmon_in.mode_0x0023_0x05=constant +hwmon_in.int_cons_0x0023_0x05=3200 + +hwmon_in.mode_0x0024_0x00=config +hwmon_in.int_cons_0x0024_0x00=0 +hwmon_in.src_0x0024_0x00=file +hwmon_in.frmt_0x0024_0x00=buf +hwmon_in.fpath_0x0024_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0024_0x00=0 +hwmon_in.len_0x0024_0x00=8 +hwmon_in.bit_offset_0x0024_0x00= +hwmon_in.str_cons_0x0024_0x00=in8_input + +hwmon_in.mode_0x0024_0x01=str_constant +hwmon_in.str_cons_0x0024_0x01=UPORT_QSFP56_VDD3.3V_D + +hwmon_in.mode_0x0024_0x02=str_constant +hwmon_in.str_cons_0x0024_0x02=ucd90160 + +hwmon_in.mode_0x0024_0x03=constant +hwmon_in.int_cons_0x0024_0x03=3600 + +hwmon_in.mode_0x0024_0x05=constant +hwmon_in.int_cons_0x0024_0x05=3200 + +hwmon_in.mode_0x0025_0x00=config +hwmon_in.int_cons_0x0025_0x00=0 +hwmon_in.src_0x0025_0x00=file +hwmon_in.frmt_0x0025_0x00=buf +hwmon_in.fpath_0x0025_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0025_0x00=0 +hwmon_in.len_0x0025_0x00=8 +hwmon_in.bit_offset_0x0025_0x00= +hwmon_in.str_cons_0x0025_0x00=in9_input + +hwmon_in.mode_0x0025_0x01=str_constant +hwmon_in.str_cons_0x0025_0x01=UPORT_VDD3.3_MON + +hwmon_in.mode_0x0025_0x02=str_constant +hwmon_in.str_cons_0x0025_0x02=ucd90160 + +hwmon_in.mode_0x0025_0x03=constant +hwmon_in.int_cons_0x0025_0x03=3465 + +hwmon_in.mode_0x0025_0x05=constant +hwmon_in.int_cons_0x0025_0x05=3135 + +hwmon_in.mode_0x0026_0x00=config +hwmon_in.int_cons_0x0026_0x00=0 +hwmon_in.src_0x0026_0x00=file +hwmon_in.frmt_0x0026_0x00=buf +hwmon_in.fpath_0x0026_0x00=/sys/bus/i2c/devices/62-005b/hwmon/ +hwmon_in.addr_0x0026_0x00=0 +hwmon_in.len_0x0026_0x00=8 +hwmon_in.bit_offset_0x0026_0x00= +hwmon_in.str_cons_0x0026_0x00=in10_input + +hwmon_in.mode_0x0026_0x01=str_constant +hwmon_in.str_cons_0x0026_0x01=UPORT_VDD12V + +hwmon_in.mode_0x0026_0x02=str_constant +hwmon_in.str_cons_0x0026_0x02=ucd90160 + +hwmon_in.mode_0x0026_0x03=constant +hwmon_in.int_cons_0x0026_0x03=12600 + +hwmon_in.mode_0x0026_0x05=constant +hwmon_in.int_cons_0x0026_0x05=11400 + +hwmon_in.mode_0x0027_0x00=config +hwmon_in.int_cons_0x0027_0x00=0 +hwmon_in.src_0x0027_0x00=file +hwmon_in.frmt_0x0027_0x00=buf +hwmon_in.fpath_0x0027_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0027_0x00=0 +hwmon_in.len_0x0027_0x00=8 +hwmon_in.bit_offset_0x0027_0x00= +hwmon_in.str_cons_0x0027_0x00=in1_input + +hwmon_in.mode_0x0027_0x01=str_constant +hwmon_in.str_cons_0x0027_0x01=DPORT_VDD1.0V_FPGA + +hwmon_in.mode_0x0027_0x02=str_constant +hwmon_in.str_cons_0x0027_0x02=ucd90160 + +hwmon_in.mode_0x0027_0x03=constant +hwmon_in.int_cons_0x0027_0x03=1061 + +hwmon_in.mode_0x0027_0x05=constant +hwmon_in.int_cons_0x0027_0x05=959 + +hwmon_in.mode_0x0028_0x00=config +hwmon_in.int_cons_0x0028_0x00=0 +hwmon_in.src_0x0028_0x00=file +hwmon_in.frmt_0x0028_0x00=buf +hwmon_in.fpath_0x0028_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0028_0x00=0 +hwmon_in.len_0x0028_0x00=8 +hwmon_in.bit_offset_0x0028_0x00= +hwmon_in.str_cons_0x0028_0x00=in2_input + +hwmon_in.mode_0x0028_0x01=str_constant +hwmon_in.str_cons_0x0028_0x01=DPORT_VDD1.8V_FPGA + +hwmon_in.mode_0x0028_0x02=str_constant +hwmon_in.str_cons_0x0028_0x02=ucd90160 + +hwmon_in.mode_0x0028_0x03=constant +hwmon_in.int_cons_0x0028_0x03=1901 + +hwmon_in.mode_0x0028_0x05=constant +hwmon_in.int_cons_0x0028_0x05=1719 + +hwmon_in.mode_0x0029_0x00=config +hwmon_in.int_cons_0x0029_0x00=0 +hwmon_in.src_0x0029_0x00=file +hwmon_in.frmt_0x0029_0x00=buf +hwmon_in.fpath_0x0029_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0029_0x00=0 +hwmon_in.len_0x0029_0x00=8 +hwmon_in.bit_offset_0x0029_0x00= +hwmon_in.str_cons_0x0029_0x00=in3_input + +hwmon_in.mode_0x0029_0x01=str_constant +hwmon_in.str_cons_0x0029_0x01=DPORT_VDD1.2V_FPGA + +hwmon_in.mode_0x0029_0x02=str_constant +hwmon_in.str_cons_0x0029_0x02=ucd90160 + +hwmon_in.mode_0x0029_0x03=constant +hwmon_in.int_cons_0x0029_0x03=1260 + +hwmon_in.mode_0x0029_0x05=constant +hwmon_in.int_cons_0x0029_0x05=1140 + +hwmon_in.mode_0x002a_0x00=config +hwmon_in.int_cons_0x002a_0x00=0 +hwmon_in.src_0x002a_0x00=file +hwmon_in.frmt_0x002a_0x00=buf +hwmon_in.fpath_0x002a_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002a_0x00=0 +hwmon_in.len_0x002a_0x00=8 +hwmon_in.bit_offset_0x002a_0x00= +hwmon_in.str_cons_0x002a_0x00=in4_input + +hwmon_in.mode_0x002a_0x01=str_constant +hwmon_in.str_cons_0x002a_0x01=DPORT_VDD3.3V + +hwmon_in.mode_0x002a_0x02=str_constant +hwmon_in.str_cons_0x002a_0x02=ucd90160 + +hwmon_in.mode_0x002a_0x03=constant +hwmon_in.int_cons_0x002a_0x03=3600 + +hwmon_in.mode_0x002a_0x05=constant +hwmon_in.int_cons_0x002a_0x05=3200 + +hwmon_in.mode_0x002b_0x00=config +hwmon_in.int_cons_0x002b_0x00=0 +hwmon_in.src_0x002b_0x00=file +hwmon_in.frmt_0x002b_0x00=buf +hwmon_in.fpath_0x002b_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002b_0x00=0 +hwmon_in.len_0x002b_0x00=8 +hwmon_in.bit_offset_0x002b_0x00= +hwmon_in.str_cons_0x002b_0x00=in5_input + +hwmon_in.mode_0x002b_0x01=str_constant +hwmon_in.str_cons_0x002b_0x01=DPORT_QSFP56_VDD3.3V_A + +hwmon_in.mode_0x002b_0x02=str_constant +hwmon_in.str_cons_0x002b_0x02=ucd90160 + +hwmon_in.mode_0x002b_0x03=constant +hwmon_in.int_cons_0x002b_0x03=3600 + +hwmon_in.mode_0x002b_0x05=constant +hwmon_in.int_cons_0x002b_0x05=3200 + +hwmon_in.mode_0x002c_0x00=config +hwmon_in.int_cons_0x002c_0x00=0 +hwmon_in.src_0x002c_0x00=file +hwmon_in.frmt_0x002c_0x00=buf +hwmon_in.fpath_0x002c_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002c_0x00=0 +hwmon_in.len_0x002c_0x00=8 +hwmon_in.bit_offset_0x002c_0x00= +hwmon_in.str_cons_0x002c_0x00=in6_input + +hwmon_in.mode_0x002c_0x01=str_constant +hwmon_in.str_cons_0x002c_0x01=DPORT_QSFP56_VDD3.3V_B + +hwmon_in.mode_0x002c_0x02=str_constant +hwmon_in.str_cons_0x002c_0x02=ucd90160 + +hwmon_in.mode_0x002c_0x03=constant +hwmon_in.int_cons_0x002c_0x03=3600 + +hwmon_in.mode_0x002c_0x05=constant +hwmon_in.int_cons_0x002c_0x05=3200 + +hwmon_in.mode_0x002d_0x00=config +hwmon_in.int_cons_0x002d_0x00=0 +hwmon_in.src_0x002d_0x00=file +hwmon_in.frmt_0x002d_0x00=buf +hwmon_in.fpath_0x002d_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002d_0x00=0 +hwmon_in.len_0x002d_0x00=8 +hwmon_in.bit_offset_0x002d_0x00= +hwmon_in.str_cons_0x002d_0x00=in7_input + +hwmon_in.mode_0x002d_0x01=str_constant +hwmon_in.str_cons_0x002d_0x01=DPORT_QSFP56_VDD3.3V_C + +hwmon_in.mode_0x002d_0x02=str_constant +hwmon_in.str_cons_0x002d_0x02=ucd90160 + +hwmon_in.mode_0x002d_0x03=constant +hwmon_in.int_cons_0x002d_0x03=3600 + +hwmon_in.mode_0x002d_0x05=constant +hwmon_in.int_cons_0x002d_0x05=3200 + +hwmon_in.mode_0x002e_0x00=config +hwmon_in.int_cons_0x002e_0x00=0 +hwmon_in.src_0x002e_0x00=file +hwmon_in.frmt_0x002e_0x00=buf +hwmon_in.fpath_0x002e_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002e_0x00=0 +hwmon_in.len_0x002e_0x00=8 +hwmon_in.bit_offset_0x002e_0x00= +hwmon_in.str_cons_0x002e_0x00=in8_input + +hwmon_in.mode_0x002e_0x01=str_constant +hwmon_in.str_cons_0x002e_0x01=DPORT_QSFP56_VDD3.3V_D + +hwmon_in.mode_0x002e_0x02=str_constant +hwmon_in.str_cons_0x002e_0x02=ucd90160 + +hwmon_in.mode_0x002e_0x03=constant +hwmon_in.int_cons_0x002e_0x03=3600 + +hwmon_in.mode_0x002e_0x05=constant +hwmon_in.int_cons_0x002e_0x05=3200 + +hwmon_in.mode_0x002f_0x00=config +hwmon_in.int_cons_0x002f_0x00=0 +hwmon_in.src_0x002f_0x00=file +hwmon_in.frmt_0x002f_0x00=buf +hwmon_in.fpath_0x002f_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x002f_0x00=0 +hwmon_in.len_0x002f_0x00=8 +hwmon_in.bit_offset_0x002f_0x00= +hwmon_in.str_cons_0x002f_0x00=in9_input + +hwmon_in.mode_0x002f_0x01=str_constant +hwmon_in.str_cons_0x002f_0x01=DPORT_VDD3.3_MON + +hwmon_in.mode_0x002f_0x02=str_constant +hwmon_in.str_cons_0x002f_0x02=ucd90160 + +hwmon_in.mode_0x002f_0x03=constant +hwmon_in.int_cons_0x002f_0x03=3465 + +hwmon_in.mode_0x002f_0x05=constant +hwmon_in.int_cons_0x002f_0x05=3135 + +hwmon_in.mode_0x0030_0x00=config +hwmon_in.int_cons_0x0030_0x00=0 +hwmon_in.src_0x0030_0x00=file +hwmon_in.frmt_0x0030_0x00=buf +hwmon_in.fpath_0x0030_0x00=/sys/bus/i2c/devices/113-005b/hwmon/ +hwmon_in.addr_0x0030_0x00=0 +hwmon_in.len_0x0030_0x00=8 +hwmon_in.bit_offset_0x0030_0x00= +hwmon_in.str_cons_0x0030_0x00=in10_input + +hwmon_in.mode_0x0030_0x01=str_constant +hwmon_in.str_cons_0x0030_0x01=DPORT_VDD12V + +hwmon_in.mode_0x0030_0x02=str_constant +hwmon_in.str_cons_0x0030_0x02=ucd90160 + +hwmon_in.mode_0x0030_0x03=constant +hwmon_in.int_cons_0x0030_0x03=12600 + +hwmon_in.mode_0x0030_0x05=constant +hwmon_in.int_cons_0x0030_0x05=11400 + + +# MAC_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x0031_0x00=config +hwmon_in.int_cons_0x0031_0x00=0 +hwmon_in.src_0x0031_0x00=cpld +hwmon_in.frmt_0x0031_0x00=num_bytes +hwmon_in.addr_0x0031_0x00=0x00050030 +hwmon_in.len_0x0031_0x00=2 +hwmon_in.int_extra1_0x0031_0x00=0x00050030 +hwmon_in.int_extra2_0x0031_0x00=2000 + +hwmon_in.mode_0x0031_0x01=str_constant +hwmon_in.str_cons_0x0031_0x01=MAC_QSFPDD_VDD3.3V_A + +hwmon_in.mode_0x0031_0x02=str_constant +hwmon_in.str_cons_0x0031_0x02=cpld + +hwmon_in.mode_0x0031_0x03=constant +hwmon_in.int_cons_0x0031_0x03=3600 + +hwmon_in.mode_0x0031_0x05=constant +hwmon_in.int_cons_0x0031_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0032_0x00=config +hwmon_in.int_cons_0x0032_0x00=0 +hwmon_in.src_0x0032_0x00=cpld +hwmon_in.frmt_0x0032_0x00=num_bytes +hwmon_in.addr_0x0032_0x00=0x00050032 +hwmon_in.len_0x0032_0x00=2 +hwmon_in.int_extra1_0x0032_0x00=0x00050032 +hwmon_in.int_extra2_0x0032_0x00=2000 + +hwmon_in.mode_0x0032_0x01=str_constant +hwmon_in.str_cons_0x0032_0x01=MAC_QSFPDD_VDD3.3V_B + +hwmon_in.mode_0x0032_0x02=str_constant +hwmon_in.str_cons_0x0032_0x02=cpld + +hwmon_in.mode_0x0032_0x03=constant +hwmon_in.int_cons_0x0032_0x03=3600 + +hwmon_in.mode_0x0032_0x05=constant +hwmon_in.int_cons_0x0032_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_C +hwmon_in.mode_0x0033_0x00=config +hwmon_in.int_cons_0x0033_0x00=0 +hwmon_in.src_0x0033_0x00=cpld +hwmon_in.frmt_0x0033_0x00=num_bytes +hwmon_in.addr_0x0033_0x00=0x00050034 +hwmon_in.len_0x0033_0x00=2 +hwmon_in.int_extra1_0x0033_0x00=0x00050034 +hwmon_in.int_extra2_0x0033_0x00=2000 + +hwmon_in.mode_0x0033_0x01=str_constant +hwmon_in.str_cons_0x0033_0x01=MAC_QSFPDD_VDD3.3V_C + +hwmon_in.mode_0x0033_0x02=str_constant +hwmon_in.str_cons_0x0033_0x02=cpld + +hwmon_in.mode_0x0033_0x03=constant +hwmon_in.int_cons_0x0033_0x03=3600 + +hwmon_in.mode_0x0033_0x05=constant +hwmon_in.int_cons_0x0033_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_D +hwmon_in.mode_0x0034_0x00=config +hwmon_in.int_cons_0x0034_0x00=0 +hwmon_in.src_0x0034_0x00=cpld +hwmon_in.frmt_0x0034_0x00=num_bytes +hwmon_in.addr_0x0034_0x00=0x00050036 +hwmon_in.len_0x0034_0x00=2 +hwmon_in.int_extra1_0x0034_0x00=0x00050036 +hwmon_in.int_extra2_0x0034_0x00=2000 + +hwmon_in.mode_0x0034_0x01=str_constant +hwmon_in.str_cons_0x0034_0x01=MAC_QSFPDD_VDD3.3V_D + +hwmon_in.mode_0x0034_0x02=str_constant +hwmon_in.str_cons_0x0034_0x02=cpld + +hwmon_in.mode_0x0034_0x03=constant +hwmon_in.int_cons_0x0034_0x03=3600 + +hwmon_in.mode_0x0034_0x05=constant +hwmon_in.int_cons_0x0034_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_E +hwmon_in.mode_0x0035_0x00=config +hwmon_in.int_cons_0x0035_0x00=0 +hwmon_in.src_0x0035_0x00=cpld +hwmon_in.frmt_0x0035_0x00=num_bytes +hwmon_in.addr_0x0035_0x00=0x00050038 +hwmon_in.len_0x0035_0x00=2 +hwmon_in.int_extra1_0x0035_0x00=0x00050038 +hwmon_in.int_extra2_0x0035_0x00=2000 + +hwmon_in.mode_0x0035_0x01=str_constant +hwmon_in.str_cons_0x0035_0x01=MAC_QSFPDD_VDD3.3V_E + +hwmon_in.mode_0x0035_0x02=str_constant +hwmon_in.str_cons_0x0035_0x02=cpld + +hwmon_in.mode_0x0035_0x03=constant +hwmon_in.int_cons_0x0035_0x03=3600 + +hwmon_in.mode_0x0035_0x05=constant +hwmon_in.int_cons_0x0035_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_F +hwmon_in.mode_0x0036_0x00=config +hwmon_in.int_cons_0x0036_0x00=0 +hwmon_in.src_0x0036_0x00=cpld +hwmon_in.frmt_0x0036_0x00=num_bytes +hwmon_in.addr_0x0036_0x00=0x0005003a +hwmon_in.len_0x0036_0x00=2 +hwmon_in.int_extra1_0x0036_0x00=0x0005003a +hwmon_in.int_extra2_0x0036_0x00=2000 + +hwmon_in.mode_0x0036_0x01=str_constant +hwmon_in.str_cons_0x0036_0x01=MAC_QSFPDD_VDD3.3V_F + +hwmon_in.mode_0x0036_0x02=str_constant +hwmon_in.str_cons_0x0036_0x02=cpld + +hwmon_in.mode_0x0036_0x03=constant +hwmon_in.int_cons_0x0036_0x03=3600 + +hwmon_in.mode_0x0036_0x05=constant +hwmon_in.int_cons_0x0036_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_G +hwmon_in.mode_0x0037_0x00=config +hwmon_in.int_cons_0x0037_0x00=0 +hwmon_in.src_0x0037_0x00=cpld +hwmon_in.frmt_0x0037_0x00=num_bytes +hwmon_in.addr_0x0037_0x00=0x0005003c +hwmon_in.len_0x0037_0x00=2 +hwmon_in.int_extra1_0x0037_0x00=0x0005003c +hwmon_in.int_extra2_0x0037_0x00=2000 + +hwmon_in.mode_0x0037_0x01=str_constant +hwmon_in.str_cons_0x0037_0x01=MAC_QSFPDD_VDD3.3V_G + +hwmon_in.mode_0x0037_0x02=str_constant +hwmon_in.str_cons_0x0037_0x02=cpld + +hwmon_in.mode_0x0037_0x03=constant +hwmon_in.int_cons_0x0037_0x03=3600 + +hwmon_in.mode_0x0037_0x05=constant +hwmon_in.int_cons_0x0037_0x05=3200 + + +# MAC_QSFPDD_VDD3.3V_H +hwmon_in.mode_0x0038_0x00=config +hwmon_in.int_cons_0x0038_0x00=0 +hwmon_in.src_0x0038_0x00=cpld +hwmon_in.frmt_0x0038_0x00=num_bytes +hwmon_in.addr_0x0038_0x00=0x0005003e +hwmon_in.len_0x0038_0x00=2 +hwmon_in.int_extra1_0x0038_0x00=0x0005003e +hwmon_in.int_extra2_0x0038_0x00=2000 + +hwmon_in.mode_0x0038_0x01=str_constant +hwmon_in.str_cons_0x0038_0x01=MAC_QSFPDD_VDD3.3V_H + +hwmon_in.mode_0x0038_0x02=str_constant +hwmon_in.str_cons_0x0038_0x02=cpld + +hwmon_in.mode_0x0038_0x03=constant +hwmon_in.int_cons_0x0038_0x03=3600 + +hwmon_in.mode_0x0038_0x05=constant +hwmon_in.int_cons_0x0038_0x05=3200 + + +# curr1 +hwmon_curr.mode_0x0001_0x00=config +hwmon_curr.int_cons_0x0001_0x00=0 +hwmon_curr.src_0x0001_0x00=file +hwmon_curr.frmt_0x0001_0x00=buf +hwmon_curr.fpath_0x0001_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_curr.addr_0x0001_0x00=0 +hwmon_curr.len_0x0001_0x00=8 +hwmon_curr.bit_offset_0x0001_0x00= +hwmon_curr.str_cons_0x0001_0x00=curr1_input + +hwmon_curr.mode_0x0001_0x01=str_constant +hwmon_curr.str_cons_0x0001_0x01=CPU_VCCIN_C + +hwmon_curr.mode_0x0001_0x02=str_constant +hwmon_curr.str_cons_0x0001_0x02=tps53622 + +hwmon_curr.mode_0x0001_0x03=constant +hwmon_curr.int_cons_0x0001_0x03=47300 + +hwmon_curr.mode_0x0001_0x05=constant +hwmon_curr.int_cons_0x0001_0x05=0 + +# curr2 +hwmon_curr.mode_0x0002_0x00=config +hwmon_curr.int_cons_0x0002_0x00=0 +hwmon_curr.src_0x0002_0x00=file +hwmon_curr.frmt_0x0002_0x00=buf +hwmon_curr.fpath_0x0002_0x00=/sys/bus/i2c/devices/106-0060/hwmon/ +hwmon_curr.addr_0x0002_0x00=0 +hwmon_curr.len_0x0002_0x00=8 +hwmon_curr.bit_offset_0x0002_0x00= +hwmon_curr.str_cons_0x0002_0x00=curr2_input + +hwmon_curr.mode_0x0002_0x01=str_constant +hwmon_curr.str_cons_0x0002_0x01=CPU_P1V05_C + +hwmon_curr.mode_0x0002_0x02=str_constant +hwmon_curr.str_cons_0x0002_0x02=tps53622 + +hwmon_curr.mode_0x0002_0x03=constant +hwmon_curr.int_cons_0x0002_0x03=15400 + +hwmon_curr.mode_0x0002_0x05=constant +hwmon_curr.int_cons_0x0002_0x05=0 + +# curr3 +hwmon_curr.mode_0x0003_0x00=config +hwmon_curr.int_cons_0x0003_0x00=0 +hwmon_curr.src_0x0003_0x00=file +hwmon_curr.frmt_0x0003_0x00=buf +hwmon_curr.fpath_0x0003_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_curr.addr_0x0003_0x00=0 +hwmon_curr.len_0x0003_0x00=8 +hwmon_curr.bit_offset_0x0003_0x00= +hwmon_curr.str_cons_0x0003_0x00=curr1_input + +hwmon_curr.mode_0x0003_0x01=str_constant +hwmon_curr.str_cons_0x0003_0x01=CPU_P1V2_VDDQ_C + +hwmon_curr.mode_0x0003_0x02=str_constant +hwmon_curr.str_cons_0x0003_0x02=tps53622 + +hwmon_curr.mode_0x0003_0x03=constant +hwmon_curr.int_cons_0x0003_0x03=9900 + +hwmon_curr.mode_0x0003_0x05=constant +hwmon_curr.int_cons_0x0003_0x05=0 + +# curr4 +hwmon_curr.mode_0x0004_0x00=config +hwmon_curr.int_cons_0x0004_0x00=0 +hwmon_curr.src_0x0004_0x00=file +hwmon_curr.frmt_0x0004_0x00=buf +hwmon_curr.fpath_0x0004_0x00=/sys/bus/i2c/devices/106-006c/hwmon/ +hwmon_curr.addr_0x0004_0x00=0 +hwmon_curr.len_0x0004_0x00=8 +hwmon_curr.bit_offset_0x0004_0x00= +hwmon_curr.str_cons_0x0004_0x00=curr2_input + +hwmon_curr.mode_0x0004_0x01=str_constant +hwmon_curr.str_cons_0x0004_0x01=CPU_P2V5_VPP_C + +hwmon_curr.mode_0x0004_0x02=str_constant +hwmon_curr.str_cons_0x0004_0x02=tps53622 + +hwmon_curr.mode_0x0004_0x03=constant +hwmon_curr.int_cons_0x0004_0x03=2200 + +hwmon_curr.mode_0x0004_0x05=constant +hwmon_curr.int_cons_0x0004_0x05=0 + +# curr5 +hwmon_curr.mode_0x0005_0x00=config +hwmon_curr.int_cons_0x0005_0x00=0 +hwmon_curr.src_0x0005_0x00=file +hwmon_curr.frmt_0x0005_0x00=buf +hwmon_curr.fpath_0x0005_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0005_0x00=0 +hwmon_curr.len_0x0005_0x00=8 +hwmon_curr.bit_offset_0x0005_0x00= +hwmon_curr.str_cons_0x0005_0x00=curr1_input + +hwmon_curr.mode_0x0005_0x01=str_constant +hwmon_curr.str_cons_0x0005_0x01=CPU_P3V3_STBY_C + +hwmon_curr.mode_0x0005_0x02=str_constant +hwmon_curr.str_cons_0x0005_0x02=ina3221 + +hwmon_curr.mode_0x0005_0x03=constant +hwmon_curr.int_cons_0x0005_0x03=4686 + +hwmon_curr.mode_0x0005_0x05=constant +hwmon_curr.int_cons_0x0005_0x05=0 + +# curr6 +hwmon_curr.mode_0x0006_0x00=config +hwmon_curr.int_cons_0x0006_0x00=0 +hwmon_curr.src_0x0006_0x00=file +hwmon_curr.frmt_0x0006_0x00=buf +hwmon_curr.fpath_0x0006_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0006_0x00=0 +hwmon_curr.len_0x0006_0x00=8 +hwmon_curr.bit_offset_0x0006_0x00= +hwmon_curr.str_cons_0x0006_0x00=curr2_input + +hwmon_curr.mode_0x0006_0x01=str_constant +hwmon_curr.str_cons_0x0006_0x01=CPU_P5V_AUX_IN_C + +hwmon_curr.mode_0x0006_0x02=str_constant +hwmon_curr.str_cons_0x0006_0x02=ina3221 + +hwmon_curr.mode_0x0006_0x03=constant +hwmon_curr.int_cons_0x0006_0x03=2200 + +hwmon_curr.mode_0x0006_0x05=constant +hwmon_curr.int_cons_0x0006_0x05=0 + +# curr7 +hwmon_curr.mode_0x0007_0x00=config +hwmon_curr.int_cons_0x0007_0x00=0 +hwmon_curr.src_0x0007_0x00=file +hwmon_curr.frmt_0x0007_0x00=buf +hwmon_curr.fpath_0x0007_0x00=/sys/bus/i2c/devices/106-0043/hwmon/ +hwmon_curr.addr_0x0007_0x00=0 +hwmon_curr.len_0x0007_0x00=8 +hwmon_curr.bit_offset_0x0007_0x00= +hwmon_curr.str_cons_0x0007_0x00=curr3_input + +hwmon_curr.mode_0x0007_0x01=str_constant +hwmon_curr.str_cons_0x0007_0x01=CPU_P1V7_VCCSCFUSESUS_IN_C + +hwmon_curr.mode_0x0007_0x02=str_constant +hwmon_curr.str_cons_0x0007_0x02=ina3221 + +hwmon_curr.mode_0x0007_0x03=constant +hwmon_curr.int_cons_0x0007_0x03=2200 + +hwmon_curr.mode_0x0007_0x05=constant +hwmon_curr.int_cons_0x0007_0x05=0 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4074 b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4074 new file mode 100755 index 000000000000..255b82321caf --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4074 @@ -0,0 +1,7 @@ +TCS8400-CPLD +TCS8400-FPGA +TCS8400-FAN +TCS8400-LED +TCS8400-PSU +TCS8400-SENSOR +TCS8400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4078 b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4078 new file mode 100755 index 000000000000..99df76574a75 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x4078 @@ -0,0 +1,7 @@ +TCS9400-CPLD +TCS9400-FPGA +TCS9400-FAN +TCS9400-LED +TCS9400-PSU +TCS9400-SENSOR +TCS9400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407b b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407b new file mode 100755 index 000000000000..90747316d593 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407b @@ -0,0 +1,7 @@ +TCS8400-CPLD +TCS8400-FPGA +TCS8400-FAN +TCS8400-LED +TCS8400-PSU +TCS8400-V2-SENSOR +TCS8400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407c new file mode 100755 index 000000000000..f09852e08737 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/dfd_cfg/ko/file_name/0x407c @@ -0,0 +1,7 @@ +TCS9400-CPLD +TCS9400-FPGA +TCS9400-FAN +TCS9400-LED +TCS9400-PSU +TCS9400-V2-SENSOR +TCS9400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg.h new file mode 100644 index 000000000000..4ed3e57a7a2c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg.h @@ -0,0 +1,139 @@ +#ifndef __DFD_CFG_H__ +#define __DFD_CFG_H__ + +#include + +#define DFD_KO_FILE_NAME_DIR "/etc/dfd_cfg/ko/file_name/" +#define DFD_KO_CFG_FILE_DIR "/etc/dfd_cfg/ko/cfg_file/" +#define DFD_PUB_CARDTYPE_FILE "/sys/module/ruijie_common/parameters/dfd_my_type" + +#define DFD_CFG_CMDLINE_MAX_LEN (256) +#define DFD_CFG_NAME_MAX_LEN (256) +#define DFD_CFG_VALUE_MAX_LEN (256) +#define DFD_CFG_STR_MAX_LEN (64) +#define DFD_CFG_CPLD_NUM_MAX (16) +#define DFD_PRODUCT_ID_LENGTH (8) +#define DFD_PID_BUF_LEN (32) +#define DFD_TEMP_NAME_BUF_LEN (32) + +#define DFD_CFG_EMPTY_VALUE (-1) +#define DFD_CFG_INVALID_VALUE (0) + +#define DFD_CFG_KEY(item, index1, index2) \ + ((((item) & 0xff) << 24) | (((index1) & 0xffff) << 8) | ((index2) & 0xff)) +#define DFD_CFG_ITEM_ID(key) (((key) >> 24) & 0xff) +#define DFD_CFG_INDEX1(key) (((key) >> 8) & 0xffff) +#define DFD_CFG_INDEX2(key) ((key)& 0xff) + +#define INDEX_NOT_EXIST (-1) +#define INDEX1_MAX (0xffff) +#define INDEX2_MAX (0xff) + +#define DFD_CFG_ITEM_ALL \ + DFD_CFG_ITEM(DFD_CFG_ITEM_NONE, "none", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DEV_NUM, "dev_num", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_TOLERANCE, "fan_speed_tolerance", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_TARGET, "fan_speed_target", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_MAX, "fan_speed_max", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED_MIN, "fan_speed_min", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_LED_STATUS_DECODE, "led_status_decode", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_LPC_DEV, "cpld_lpc_dev", INDEX1_MAX, DFD_CFG_CPLD_NUM_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_TYPE_NUM, "fan_type_num", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_EEPROM_SIZE, "eeprom_size", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DECODE_POWER_FAN_DIR, "decode_power_fan_dir", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_WATCHDOG_ID, "watchdog_id", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_POWER_RSUPPLY, "power_rate_supply", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_PMBUS_ID, "psu_pmbus_id", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_INT_END, "end_int", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_MODE, "mode_cpld", INDEX1_MAX, DFD_CFG_CPLD_NUM_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_NAME, "cpld_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_TYPE, "cpld_type", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_NAME, "fpga_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_TYPE, "fpga_type", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_MODEL_DECODE, "fpga_model_decode", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_E2_MODE, "fan_e2_mode", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SYSFS_NAME, "fan_sysfs_name", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_POWER_NAME, "power_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_NAME, "fan_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DECODE_POWER_NAME, "decode_power_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DECODE_FAN_NAME, "decode_fan_name", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_EEPROM_PATH, "eeprom_path", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_DIRECTION, "fan_direction", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_WATCHDOG_NAME, "watchdog_name", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_SYSFS_NAME, "psu_sysfs_name", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SLOT_SYSFS_NAME, "slot_sysfs_name", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_STRING_END, "end_string", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_I2C_DEV, "cpld_i2c_dev", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_OTHER_I2C_DEV, "other_i2c_dev", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_I2C_DEV_END, "end_i2c_dev", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_ROLL_STATUS, "fan_roll_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_SPEED, "fan_speed", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FAN_RATIO, "fan_ratio", INDEX1_MAX, INDEX_NOT_EXIST) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_LED_STATUS, "led_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_VERSION, "cpld_version", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_CPLD_TEST_REG, "cpld_test_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_DEV_PRESENT_STATUS, "dev_present_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_PSU_STATUS, "psu_status", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_TEMP, "hwmon_temp", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_IN, "hwmon_in", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_CURR, "hwmon_curr", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_HWMON_PSU, "hwmon_psu", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_SFF_CPLD_REG, "sff_cpld_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_VERSION, "fpga_version", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_TEST_REG, "fpga_test_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_FPGA_MODEL_REG, "fpga_model_reg", INDEX1_MAX, INDEX2_MAX) \ + DFD_CFG_ITEM(DFD_CFG_ITEM_INFO_CTRL_END, "end_info_ctrl", INDEX_NOT_EXIST, INDEX_NOT_EXIST) \ + +#ifdef DFD_CFG_ITEM +#undef DFD_CFG_ITEM +#endif +#define DFD_CFG_ITEM(_id, _name, _index_min, _index_max) _id, +typedef enum dfd_cfg_item_id_s { + DFD_CFG_ITEM_ALL +} dfd_cfg_item_id_t; + +#define DFD_CFG_ITEM_IS_INT(item_id) \ + (((item_id) > DFD_CFG_ITEM_NONE) && ((item_id) < DFD_CFG_ITEM_INT_END)) + +#define DFD_CFG_ITEM_IS_STRING(item_id) \ + (((item_id) > DFD_CFG_ITEM_INT_END) && ((item_id) < DFD_CFG_ITEM_STRING_END)) + +#define DFD_CFG_ITEM_IS_I2C_DEV(item_id) \ + (((item_id) > DFD_CFG_ITEM_STRING_END) && ((item_id) < DFD_CFG_ITEM_I2C_DEV_END)) + +#define DFD_CFG_ITEM_IS_INFO_CTRL(item_id) \ + (((item_id) > DFD_CFG_ITEM_I2C_DEV_END) && ((item_id) < DFD_CFG_ITEM_INFO_CTRL_END)) + +typedef struct index_range_s { + int index1_max; + int index2_max; +} index_range_t; + +typedef struct val_convert_node_s { + struct list_head lst; + int int_val; + char str_val[DFD_CFG_STR_MAX_LEN]; + int index1; + int index2; +} val_convert_node_t; + +void *dfd_ko_cfg_get_item(int key); + +void dfd_ko_cfg_show_item(int key); + +int32_t dfd_dev_cfg_init(void); + +void dfd_dev_cfg_exit(void); + +void dfd_ko_cfg_del_space_lf_cr(char *str); + +int dfd_ko_cfg_get_fan_direction_by_name(char *fan_name, int *fan_direction); + +int dfd_ko_cfg_get_power_type_by_name(char *power_name, int *power_type); + +int dfd_ko_cfg_get_led_status_decode2_by_regval(int regval, int index1, int *value); + +#endif /* __DFD_CFG_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_adapter.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_adapter.h new file mode 100644 index 000000000000..7b6c2682ca80 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_adapter.h @@ -0,0 +1,49 @@ +#ifndef __DFD_CFG_ADAPTER_H__ +#define __DFD_CFG_ADAPTER_H__ + +#define DFD_KO_CPLD_I2C_RETRY_SLEEP (10) /* ms */ +#define DFD_KO_CPLD_I2C_RETRY_TIMES (50 / DFD_KO_CPLD_I2C_RETRY_SLEEP) + +#define DFD_KO_CPLD_GET_SLOT(addr) ((addr >> 24) & 0xff) +#define DFD_KO_CPLD_GET_ID(addr) ((addr >> 16) & 0xff) +#define DFD_KO_CPLD_GET_INDEX(addr) (addr & 0xffff) +#define DFD_KO_CPLD_MODE_I2C_STRING "i2c" +#define DFD_KO_CPLD_MODE_LPC_STRING "lpc" +#define DFD_SYSFS_PATH_MAX_LEN (64) + +typedef struct dfd_i2c_dev_s { + int bus; + int addr; +} dfd_i2c_dev_t; + +typedef enum dfd_i2c_dev_mem_s { + DFD_I2C_DEV_MEM_BUS, + DFD_I2C_DEV_MEM_ADDR, + DFD_I2C_DEV_MEM_END +} dfd_i2c_dev_mem_t; + +typedef enum cpld_mode_e { + DFD_CPLD_MODE_I2C, + DFD_CPLD_MODE_LPC, +} cpld_mode_t; + +typedef enum i2c_mode_e { + DFD_I2C_MODE_NORMAL_I2C, + DFD_I2C_MODE_SMBUS, +} i2c_mode_t; + +extern char *g_dfd_i2c_dev_mem_str[DFD_I2C_DEV_MEM_END]; + +int32_t dfd_ko_cpld_read(int32_t addr, uint8_t *buf); + +int32_t dfd_ko_cpld_write(int32_t addr, uint8_t val); + +int32_t dfd_ko_i2c_read(int bus, int addr, int offset, uint8_t *buf, uint32_t size, const char *sysfs_name); + +int32_t dfd_ko_i2c_write(int bus, int addr, int offset, uint8_t *buf, uint32_t size); + +int32_t dfd_ko_read_file(char *fpath, int32_t addr, uint8_t *val, int32_t read_bytes); + +int32_t dfd_ko_write_file(char *fpath, int32_t addr, uint8_t *val, int32_t write_bytes); + +#endif /* __DFD_CFG_ADAPTER_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_file.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_file.h new file mode 100644 index 000000000000..50d7a42d5564 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_file.h @@ -0,0 +1,37 @@ +#ifndef __DFD_CFG_FILE_H__ +#define __DFD_CFG_FILE_H__ + +#include + +#define KFILE_RV_OK (0) +#define KFILE_RV_INPUT_ERR (-1) +#define KFILE_RV_STAT_FAIL (-2) +#define KFILE_RV_OPEN_FAIL (-3) +#define KFILE_RV_MALLOC_FAIL (-4) +#define KFILE_RV_RD_FAIL (-5) +#define KFILE_RV_ADDR_ERR (-6) +#define KFILE_RV_WR_FAIL (-7) + +#define IS_CR(c) ((c) == '\n') + +typedef struct kfile_ctrl_s { + int32_t size; + int32_t pos; + char *buf; +} kfile_ctrl_t; + +int kfile_open(char *fname, kfile_ctrl_t *kfile_ctrl); + +void kfile_close(kfile_ctrl_t *kfile_ctrl); + +int kfile_gets(char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl); + +int kfile_read(int32_t addr, char *buf, int buf_size, kfile_ctrl_t *kfile_ctrl); + +int kfile_iterate_dir(const char *dir_path, const char *obj_name, char *match_name, int len); + +#if 0 + +int kfile_write(char *fpath, int32_t addr, char *buf, int buf_size); +#endif +#endif /* __DFD_CFG_FILE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_info.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_info.h new file mode 100644 index 000000000000..a80734989964 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_info.h @@ -0,0 +1,110 @@ +#ifndef __DFD_CFG_INFO_H__ +#define __DFD_CFG_INFO_H__ + +#include + +typedef int (*info_num_buf_to_value_f)(uint8_t *num_buf, int buf_len, int *num_val); + +typedef int (*info_buf_to_buf_f)(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new); + +#define IS_INFO_FRMT_BIT(frmt) ((frmt) == INFO_FRMT_BIT) +#define IS_INFO_FRMT_BYTE(frmt) (((frmt) == INFO_FRMT_BYTE) || ((frmt) == INFO_FRMT_NUM_BYTES)) +#define IS_INFO_FRMT_NUM_STR(frmt) ((frmt) == INFO_FRMT_NUM_STR) +#define IS_INFO_FRMT_NUM_BUF(frmt) ((frmt) == INFO_FRMT_NUM_BUF) +#define IS_INFO_FRMT_BUF(frmt) ((frmt) == INFO_FRMT_BUF) + +#define INFO_INT_MAX_LEN (32) +#define INFO_INT_LEN_VALAID(len) (((len) > 0) && ((len) < INFO_INT_MAX_LEN)) + +#define INFO_BUF_MAX_LEN (128) +#define INFO_BUF_LEN_VALAID(len) (((len) > 0) && ((len) < INFO_BUF_MAX_LEN)) + +#define INFO_BIT_OFFSET_VALID(bit_offset) (((bit_offset) >= 0) && ((bit_offset) < 8)) + +typedef enum info_ctrl_mode_e { + INFO_CTRL_MODE_NONE, + INFO_CTRL_MODE_CFG, + INFO_CTRL_MODE_CONS, + INFO_CTRL_MODE_TLV, + INFO_CTRL_MODE_SRT_CONS, + INFO_CTRL_MODE_END +} info_ctrl_mode_t; + +typedef enum info_frmt_e { + INFO_FRMT_NONE, + INFO_FRMT_BIT, + INFO_FRMT_BYTE, + INFO_FRMT_NUM_BYTES, + INFO_FRMT_NUM_STR, + INFO_FRMT_NUM_BUF, + INFO_FRMT_BUF, + INFO_FRMT_END +} info_frmt_t; + +typedef enum info_src_e { + INFO_SRC_NONE, + INFO_SRC_CPLD, + INFO_SRC_FPGA, + INFO_SRC_OTHER_I2C, + INFO_SRC_FILE, + INFO_SRC_END +} info_src_t; + +typedef enum info_pola_e { + INFO_POLA_NONE, + INFO_POLA_POSI, + INFO_POLA_NEGA, + INFO_POLA_END +} info_pola_t; + +#define INFO_FPATH_MAX_LEN (128) +#define INFO_STR_CONS_MAX_LEN (64) +typedef struct info_ctrl_s { + info_ctrl_mode_t mode; + int32_t int_cons; + info_src_t src; + info_frmt_t frmt; + info_pola_t pola; + char fpath[INFO_FPATH_MAX_LEN]; + int32_t addr; + int32_t len; + int32_t bit_offset; + char str_cons[INFO_STR_CONS_MAX_LEN]; + int32_t int_extra1; + int32_t int_extra2; +} info_ctrl_t; + +typedef enum info_ctrl_mem_s { + INFO_CTRL_MEM_MODE, + INFO_CTRL_MEM_INT_CONS, + INFO_CTRL_MEM_SRC, + INFO_CTRL_MEM_FRMT, + INFO_CTRL_MEM_POLA, + INFO_CTRL_MEM_FPATH, + INFO_CTRL_MEM_ADDR, + INFO_CTRL_MEM_LEN, + INFO_CTRL_MEM_BIT_OFFSET, + INFO_CTRL_MEM_STR_CONS, + INFO_CTRL_MEM_INT_EXTRA1, + INFO_CTRL_MEM_INT_EXTRA2, + INFO_CTRL_MEM_END +} info_ctrl_mem_t; + +typedef int (*info_hwmon_buf_f)(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new, + info_ctrl_t *info_ctrl, int coefficient, int addend); + +extern char *g_info_ctrl_mem_str[INFO_CTRL_MEM_END]; +extern char *g_info_src_str[INFO_SRC_END]; +extern char *g_info_frmt_str[INFO_FRMT_END]; +extern char *g_info_pola_str[INFO_POLA_END]; +extern char *g_info_ctrl_mode_str[INFO_CTRL_MODE_END]; + +int dfd_info_get_int(int key, int *ret, info_num_buf_to_value_f pfun); + +int dfd_info_get_buf(int key, uint8_t *buf, int buf_len, info_buf_to_buf_f pfun); + +int dfd_info_set_int(int key, int val); + +int dfd_info_get_sensor(uint32_t key, char *buf, int buf_len, info_hwmon_buf_f pfun); + +#endif /* __DFD_CFG_INFO_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_listnode.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_listnode.h new file mode 100644 index 000000000000..955dfa96e42e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_cfg_listnode.h @@ -0,0 +1,30 @@ +#ifndef __DFD_CFG_LISTNODE_H__ +#define __DFD_CFG_LISTNODE_H__ + +#include + +#define LNODE_RV_OK (0) +#define LNODE_RV_INPUT_ERR (-1) +#define LNODE_RV_NODE_EXIST (-2) +#define LNODE_RV_NOMEM (-3) + +typedef struct lnode_root_s { + struct list_head root; +} lnode_root_t; + +typedef struct lnode_node_s { + struct list_head lst; + + int key; + void *data; +} lnode_node_t; + +void *lnode_find_node(lnode_root_t *root, int key); + +int lnode_insert_node(lnode_root_t *root, int key, void *data); + +int lnode_init_root(lnode_root_t *root); + +void lnode_free_list(lnode_root_t *root); + +#endif /* __DFD_CFG_LISTNODE_H__ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_frueeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_frueeprom.h new file mode 100644 index 000000000000..64aa88d4c8c7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_frueeprom.h @@ -0,0 +1,69 @@ +#ifndef _DFD_FRUEEPROM_H_ +#define _DFD_FRUEEPROM_H_ + +/* Per IPMI v2.0 FRU specification */ +typedef struct fru_common_header_s +{ + uint8_t fixed; + uint8_t internal_offset; + uint8_t chassis_offset; + uint8_t board_offset; + uint8_t product_offset; + uint8_t multi_offset; + uint8_t pad; + uint8_t crc; +}__attribute__((packed)) fru_common_header_t; + +/* first byte in header is 1h per IPMI V2 spec. */ + +#define IPMI_FRU_HDR_BYTE_ZERO 1 +#define IPMI_EIGHT_BYTES 8 +#define IPMI_FRU_PRODUCT_AREA_MIN_LEN (7) +#define IPMI_FRU_BOARD_AREA_MIN_LEN (5) + +#define IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX 512 +#define IPMI_FRU_BOARD_INFO_MFG_TIME_LENGTH 3 +#define IPMI_FRU_SENTINEL_VALUE 0xC1 +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_MASK 0xC0 +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_SHIFT 0x06 +#define IPMI_FRU_TYPE_LENGTH_NUMBER_OF_DATA_BYTES_MASK 0x3F +#define IPMI_FRU_TYPE_LENGTH_TYPE_CODE_LANGUAGE_CODE 0x03 + +struct ipmi_fru_field +{ + uint8_t type_length_field[IPMI_FRU_AREA_TYPE_LENGTH_FIELD_MAX]; + /* store length of data stored in buffer */ + unsigned int type_length_field_length; +}; + +typedef struct ipmi_fru_field ipmi_fru_field_t; + +typedef struct ipmi_product_info_s { + uint8_t *language_code; + ipmi_fru_field_t *product_manufacturer_name; + ipmi_fru_field_t *product_name; + ipmi_fru_field_t *product_part_model_number; + ipmi_fru_field_t *product_version; + ipmi_fru_field_t *product_serial_number; + ipmi_fru_field_t *product_asset_tag; + ipmi_fru_field_t *product_fru_file_id; + ipmi_fru_field_t *product_custom_fields; + ipmi_fru_field_t *product_type_fields; +}ipmi_product_info_t; + +typedef struct ipmi_board_info_s { + uint8_t *language_code; + uint8_t *mfg_time; + ipmi_fru_field_t *board_manufacturer; + ipmi_fru_field_t *board_product_name; + ipmi_fru_field_t *board_serial_number; + ipmi_fru_field_t *board_part_number; + ipmi_fru_field_t *board_fru_file_id; + ipmi_fru_field_t *board_custom_fields; /*hw version */ +}ipmi_board_info_t; + +int dfd_get_fru_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len, const char *sysfs_name); + +int dfd_get_fru_board_data(int bus, int dev_addr, int type, uint8_t *buf, uint32_t buf_len, const char *sysfs_name); + +#endif /* endif _DFD_FRUEEPROM_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_sysfs_common.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_sysfs_common.h new file mode 100644 index 000000000000..ee2802209d8b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_sysfs_common.h @@ -0,0 +1,192 @@ +#ifndef _DFD_SYSFS_COMMON_H_ +#define _DFD_SYSFS_COMMON_H_ + +struct switch_drivers_s { + /* temperature sensors */ + int (*get_main_board_temp_number)(void); + ssize_t (*get_main_board_temp_alias)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_type)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_max)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_max)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_min)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_min)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_value)(unsigned int temp_index, char *buf, size_t count); + /* voltage sensors */ + int (*get_main_board_vol_number)(void); + ssize_t (*get_main_board_vol_alias)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_type)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_max)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_max)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_min)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_min)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_range)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_nominal_value)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_value)(unsigned int vol_index, char *buf, size_t count); + /* current sensors */ + int (*get_main_board_curr_number)(void); + ssize_t (*get_main_board_curr_alias)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_type)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_max)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_max)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_min)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_min)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_value)(unsigned int curr_index, char *buf, size_t count); + /* syseeprom */ + int (*get_syseeprom_size)(void); + ssize_t (*read_syseeprom_data)(char *buf, loff_t offset, size_t count); + ssize_t (*write_syseeprom_data)(char *buf, loff_t offset, size_t count); + /* fan */ + int (*get_fan_number)(void); + int (*get_fan_motor_number)(unsigned int fan_index); + ssize_t (*get_fan_model_name)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_serial_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_part_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_hardware_version)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_status)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_led_status)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_led_status)(unsigned int fan_index, int status); + ssize_t (*get_fan_direction)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_tolerance)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_target)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_max)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_min)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_ratio)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_ratio)(unsigned int fan_index, int ratio); + /* PSU */ + int (*get_psu_number)(void); + int (*get_psu_temp_number)(unsigned int psu_index); + ssize_t (*get_psu_model_name)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_serial_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_part_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_hardware_version)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_type)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_max_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_present_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_speed)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_ratio)(unsigned int psu_index, char *buf, size_t count); + int (*set_psu_fan_ratio)(unsigned int psu_index, int ratio); + ssize_t (*get_psu_fan_direction)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_led_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_temp_alias)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_type)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_value)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + /* transceiver */ + int (*get_eth_number)(void); + ssize_t (*get_transceiver_power_on_status)(char *buf, size_t count); + int (*set_transceiver_power_on_status)(int status); + ssize_t (*get_eth_power_on_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_power_on_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_tx_fault_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_tx_disable_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_tx_disable_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_present_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_rx_los_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_reset_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_reset_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_low_power_mode_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_interrupt_status)(unsigned int eth_index, char *buf, size_t count); + int (*get_eth_eeprom_size)(unsigned int eth_index); + ssize_t (*read_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); + ssize_t (*write_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); + /* sysled */ + ssize_t (*get_sys_led_status)(char *buf, size_t count); + int (*set_sys_led_status)(int status); + ssize_t (*get_bmc_led_status)(char *buf, size_t count); + int (*set_bmc_led_status)(int status); + ssize_t (*get_sys_fan_led_status)(char *buf, size_t count); + int (*set_sys_fan_led_status)(int status); + ssize_t (*get_sys_psu_led_status)(char *buf, size_t count); + int (*set_sys_psu_led_status)(int status); + ssize_t (*get_id_led_status)(char *buf, size_t count); + int (*set_id_led_status)(int status); + /* FPGA */ + int (*get_main_board_fpga_number)(void); + ssize_t (*get_main_board_fpga_alias)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_type)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_firmware_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_board_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_test_reg)(unsigned int fpga_index, char *buf, size_t count); + int (*set_main_board_fpga_test_reg)(unsigned int fpga_index, unsigned int value); + /* CPLD */ + int (*get_main_board_cpld_number)(void); + ssize_t (*get_main_board_cpld_alias)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_type)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_firmware_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_board_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_test_reg)(unsigned int cpld_index, char *buf, size_t count); + int (*set_main_board_cpld_test_reg)(unsigned int cpld_index, unsigned int value); + /* watchdog */ + ssize_t (*get_watchdog_identify)(char *buf, size_t count); + ssize_t (*get_watchdog_timeleft)(char *buf, size_t count); + ssize_t (*get_watchdog_timeout)(char *buf, size_t count); + int (*set_watchdog_timeout)(int value); + ssize_t (*get_watchdog_enable_status)(char *buf, size_t count); + int (*set_watchdog_enable_status)(int value); + int (*set_watchdog_reset)(int value); + /* slot */ + int (*get_slot_number)(void); + int (*get_slot_temp_number)(unsigned int slot_index); + int (*get_slot_vol_number)(unsigned int slot_index); + int (*get_slot_curr_number)(unsigned int slot_index); + int (*get_slot_cpld_number)(unsigned int slot_index); + int (*get_slot_fpga_number)(unsigned int slot_index); + ssize_t (*get_slot_model_name)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_serial_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_part_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_hardware_version)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_status)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_led_status)(unsigned int slot_index, char *buf, size_t count); + int (*set_slot_led_status)(unsigned int slot_index, int status); + ssize_t (*get_slot_temp_alias)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_type)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_value)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_vol_alias)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_type)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_range)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_nominal_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_curr_alias)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_type)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_value)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_alias)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_type)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_firmware_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_board_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + int (*set_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, unsigned int value); + ssize_t (*get_slot_cpld_alias)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_type)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_firmware_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_board_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + int (*set_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, unsigned int value); +}; + +extern struct switch_drivers_s * switch_driver_get(void); + +#endif /*_DFD_SYSFS_COMMON_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_tlveeprom.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_tlveeprom.h new file mode 100644 index 000000000000..4f894ec352d3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/dfd_tlveeprom.h @@ -0,0 +1,70 @@ +#ifndef _DFD_TLVEEPROM_H_ +#define _DFD_TLVEEPROM_H_ + +#ifndef be16_to_cpu +#define be16_to_cpu(x) ntohs(x) +#endif + +#ifndef cpu_to_be16 +#define cpu_to_be16(x) htons(x) +#endif + +#define TLV_CODE_NAME_LEN 64 + +/* + * Struct for displaying the TLV codes and names. + */ +struct tlv_code_desc { + uint8_t m_code; + char m_name[TLV_CODE_NAME_LEN]; +}; + +typedef struct dfd_tlv_type_s { + uint8_t main_type; + uint8_t ext_type; +} dfd_tlv_type_t; + +/* Header Field Constants */ +#define TLV_INFO_ID_STRING "TlvInfo" +#define TLV_INFO_VERSION 0x01 + +struct __attribute__ ((__packed__)) tlvinfo_header_s { + char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ + uint8_t version; /* 0x08 Structure version */ + uint16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ +}; +typedef struct tlvinfo_header_s tlvinfo_header_t; + +/* + * TlvInfo TLV: Layout of a TLV field + */ +struct __attribute__ ((__packed__)) tlvinfo_tlv_s { + uint8_t type; + uint8_t length; + uint8_t value[0]; +}; +typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; + +#define TLV_VALUE_MAX_LEN 255 +/* + * 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) + +typedef struct tlv_decode_value_s { + uint8_t value[TLV_DECODE_VALUE_MAX_LEN]; + uint32_t length; +} tlv_decode_value_t; + +typedef enum dfd_tlvinfo_ext_tlv_type_e { + DFD_TLVINFO_EXT_TLV_TYPE_DEV_TYPE = 1, +} dfd_tlvinfo_ext_tlv_type_t; + +int dfd_tlvinfo_get_e2prom_info(uint8_t *eeprom, uint32_t size, dfd_tlv_type_t *tlv_type, uint8_t* buf, uint32_t *buf_len); + +#endif /* endif _DFD_TLVEEPROM_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_cpld_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_cpld_driver.h new file mode 100644 index 000000000000..fbf5b077ce82 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_cpld_driver.h @@ -0,0 +1,19 @@ +#ifndef _RG_CPLD_DRIVER_H_ +#define _RG_CPLD_DRIVER_H_ + +ssize_t dfd_get_cpld_name(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count); + +ssize_t dfd_get_cpld_type(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count); + +ssize_t dfd_get_cpld_fw_version(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count); + +ssize_t dfd_get_cpld_hw_version(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count); + +int dfd_set_cpld_testreg(uint8_t main_dev_id, unsigned int cpld_index, int value); + +int dfd_get_cpld_testreg(uint8_t main_dev_id, unsigned int cpld_index, int *value); + +ssize_t dfd_get_cpld_testreg_str(uint8_t main_dev_id, unsigned int cpld_index, + char *buf, size_t count); + +#endif /* _RG_CPLD_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_eeprom_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_eeprom_driver.h new file mode 100644 index 000000000000..8fc74e1e1ef7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_eeprom_driver.h @@ -0,0 +1,9 @@ +#ifndef _RG_EEPROM_DRIVER_H_ +#define _RG_EEPROM_DRIVER_H_ + +int dfd_get_eeprom_size(int e2_type, int index); + +ssize_t dfd_read_eeprom_data(int e2_type, int index, char *buf, loff_t offset, size_t count); + +ssize_t dfd_write_eeprom_data(int e2_type, int index, char *buf, loff_t offset, size_t count); +#endif /* _RG_EEPROM_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fan_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fan_driver.h new file mode 100644 index 000000000000..96d57e309232 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fan_driver.h @@ -0,0 +1,35 @@ +#ifndef _RG_FAN_DRIVER_H_ +#define _RG_FAN_DRIVER_H_ + +ssize_t dfd_get_fan_status_str(unsigned int fan_index, char *buf, size_t count); + +ssize_t dfd_get_fan_info(unsigned int fan_index, uint8_t cmd, char *buf, size_t count); + +int dfd_get_fan_speed(unsigned int fan_index, unsigned int motor_index,unsigned int *speed); + +ssize_t dfd_get_fan_speed_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +int dfd_set_fan_pwm(unsigned int fan_index, int pwm); + +int dfd_get_fan_pwm(unsigned int fan_index, int *pwm); + +ssize_t dfd_get_fan_pwm_str(unsigned int fan_index, char *buf, size_t count); + +ssize_t dfd_get_fan_motor_speed_tolerance_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +int dfd_get_fan_speed_target(unsigned int fan_index, unsigned int motor_index, int *value); + +ssize_t dfd_get_fan_motor_speed_target_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +ssize_t dfd_get_fan_direction_str(unsigned int fan_index, char *buf, size_t count); + +ssize_t dfd_get_fan_motor_speed_max_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +ssize_t dfd_get_fan_motor_speed_min_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count); + +#endif /* _RG_FAN_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fpga_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fpga_driver.h new file mode 100644 index 000000000000..a850d9343ef7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_fpga_driver.h @@ -0,0 +1,19 @@ +#ifndef _RG_FPGA_DRIVER_H_ +#define _RG_FPGA_DRIVER_H_ + +ssize_t dfd_get_fpga_name(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count); + +ssize_t dfd_get_fpga_type(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count); + +ssize_t dfd_get_fpga_fw_version(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count); + +ssize_t dfd_get_fpga_hw_version(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count); + +int dfd_set_fpga_testreg(uint8_t main_dev_id, unsigned int fpga_index, int value); + +int dfd_get_fpga_testreg(uint8_t main_dev_id, unsigned int fpga_index, int *value); + +ssize_t dfd_get_fpga_testreg_str(uint8_t main_dev_id, unsigned int fpga_index, + char *buf, size_t count); + +#endif /* _RG_FPGA_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_led_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_led_driver.h new file mode 100644 index 000000000000..8798ed2eacdb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_led_driver.h @@ -0,0 +1,8 @@ +#ifndef _RG_LED_DRIVER_H_ +#define _RG_LED_DRIVER_H_ + +ssize_t dfd_get_led_status(uint16_t led_id, uint8_t led_index, char *buf, size_t count); + +ssize_t dfd_set_led_status(uint16_t led_id, uint8_t led_index, int value); + +#endif /* _RG_LED_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_module.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_module.h new file mode 100644 index 000000000000..22107a470afe --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_module.h @@ -0,0 +1,267 @@ +#ifndef _RG_MODULE_H_ +#define _RG_MODULE_H_ + +#include "switch_driver.h" + +typedef enum dfd_rv_s { + DFD_RV_OK = 0, + DFD_RV_INIT_ERR = 1, + DFD_RV_SLOT_INVALID = 2, + DFD_RV_MODE_INVALID = 3, + DFD_RV_MODE_NOTSUPPORT = 4, + DFD_RV_TYPE_ERR = 5, + DFD_RV_DEV_NOTSUPPORT = 6, + DFD_RV_DEV_FAIL = 7, + DFD_RV_INDEX_INVALID = 8, + DFD_RV_NO_INTF = 9, + DFD_RV_NO_NODE = 10, + DFD_RV_NODE_FAIL = 11, + DFD_RV_INVALID_VALUE = 12, + DFD_RV_NO_MEMORY = 13, +} dfd_rv_t; + +typedef enum status_mem_e { + STATUS_ABSENT = 0, + STATUS_OK = 1, + STATUS_NOT_OK = 2, + STATUS_MEM_END = 3, +} status_mem_t; + +/* psu PMBUS */ +typedef enum psu_sensors_type_e { + PSU_SENSOR_NONE = 0, + PSU_IN_VOL = 1, + PSU_IN_CURR = 2, + PSU_IN_POWER = 3, + PSU_OUT_VOL = 4, + PSU_OUT_CURR = 5, + PSU_OUT_POWER = 6, + PSU_FAN_SPEED = 7, + PSU_OUT_MAX_POWERE = 8, + PSU_OUT_STATUS = 9, + PSU_IN_STATUS = 10, + PSU_IN_TYPE = 11, +} psu_sensors_type_t; + +typedef enum rg_wdt_type_e { + RG_WDT_TYPE_NAME = 0, /* watchdog identify */ + RG_WDT_TYPE_STATE = 1, /* watchdog state */ + RG_WDT_TYPE_TIMELEFT = 2, /* watchdog timeleft */ + RG_WDT_TYPE_TIMEOUT = 3, /* watchdog timeout */ + RG_WDT_TYPE_ENABLE = 4, /* watchdog enable */ +} rg_wdt_type_t; + +typedef enum dfd_dev_info_type_e { + DFD_DEV_INFO_TYPE_MAC = 1, + DFD_DEV_INFO_TYPE_NAME = 2, + DFD_DEV_INFO_TYPE_SN = 3, + DFD_DEV_INFO_TYPE_PWR_CONS = 4, + DFD_DEV_INFO_TYPE_HW_INFO = 5, + DFD_DEV_INFO_TYPE_DEV_TYPE = 6, + DFD_DEV_INFO_TYPE_PART_NAME = 7, + DFD_DEV_INFO_TYPE_PART_NUMBER = 8, /* part number */ + DFD_DEV_INFO_TYPE_FAN_DIRECTION = 9, + DFD_DEV_INFO_TYPE_MAX_OUTPUT_POWRER = 10, /* max_output_power */ +} dfd_dev_tlv_type_t; + +typedef enum rg_main_dev_type_e { + RG_MAIN_DEV_MAINBOARD = 0, + RG_MAIN_DEV_FAN = 1, + RG_MAIN_DEV_PSU = 2, + RG_MAIN_DEV_SFF = 3, + RG_MAIN_DEV_CPLD = 4, /* CPLD */ + RG_MAIN_DEV_SLOT = 5, +} rg_main_dev_type_t; + +typedef enum rg_minor_dev_type_e { + RG_MINOR_DEV_NONE = 0, /* None */ + RG_MINOR_DEV_TEMP = 1, + RG_MINOR_DEV_IN = 2, + RG_MINOR_DEV_CURR = 3, + RG_MINOR_DEV_POWER = 4, + RG_MINOR_DEV_MOTOR = 5, + RG_MINOR_DEV_PSU = 6, + RG_MINOR_DEV_FAN = 7, + RG_MINOR_DEV_CPLD = 8, /* CPLD */ + RG_MINOR_DEV_FPGA = 9, /* FPGA */ +} rg_minor_dev_type_t; + +typedef enum rg_sensor_type_e { + RG_SENSOR_INPUT = 0, + RG_SENSOR_ALIAS = 1, + RG_SENSOR_TYPE = 2, + RG_SENSOR_MAX = 3, + RG_SENSOR_MAX_HYST = 4, + RG_SENSOR_MIN = 5, + RG_SENSOR_CRIT = 6, + RG_SENSOR_RANGE = 7, + RG_SENSOR_NOMINAL_VAL = 8, +} rg_sensor_type_t; + +typedef enum rg_sff_cpld_attr_e { + RG_SFF_POWER_ON = 0x01, + RG_SFF_TX_FAULT, + RG_SFF_TX_DIS, + RG_SFF_PRESENT_RESERVED, + RG_SFF_RX_LOS, + RG_SFF_RESET, + RG_SFF_LPMODE, + RG_SFF_MODULE_PRESENT, + RG_SFF_INTERRUPT, +} rg_sff_cpld_attr_t; + +typedef enum rg_led_e { + RG_SYS_LED_FRONT = 0, + RG_SYS_LED_REAR = 1, + RG_BMC_LED_FRONT = 2, + RG_BMC_LED_REAR = 3, + RG_FAN_LED_FRONT = 4, + RG_FAN_LED_REAR = 5, + RG_PSU_LED_FRONT = 6, + RG_PSU_LED_REAR = 7, + RG_ID_LED_FRONT = 8, + RG_ID_LED_REAR = 9, + RG_FAN_LED_MODULE = 10, + RG_PSU_LED_MODULE = 11, + RG_SLOT_LED_MODULE = 12, +} rg_led_t; + +extern int g_dfd_dbg_level; +extern int g_dfd_fan_dbg_level; +extern int g_dfd_fru_dbg_level; +extern int g_dfd_eeprom_dbg_level; +extern int g_dfd_cpld_dbg_level; +extern int g_dfd_fpga_dbg_level; +extern int g_dfd_sysled_dbg_level; +extern int g_dfd_slot_dbg_level; +extern int g_dfd_sensor_dbg_level; +extern int g_dfd_psu_dbg_level; +extern int g_dfd_sff_dbg_level; +extern int g_dfd_watchdog_dbg_level; + +#define DBG_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_FAN_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fan_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_FRU_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fru_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_EEPROM_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_eeprom_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_CPLD_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_cpld_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_FPGA_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_fpga_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DBG_SYSLED_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sysled_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SLOT_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_slot_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SENSOR_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sensor_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_PSU_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_psu_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_SFF_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_sff_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#define DFD_WDT_DEBUG(level, fmt, arg...) do { \ + if (g_dfd_watchdog_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +int32_t rg_dev_cfg_init(void); + +void rg_dev_cfg_exit(void); + +int dfd_get_dev_number(unsigned int main_dev_id, unsigned int minor_dev_id); +#endif /* _RG_MODULE_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_psu_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_psu_driver.h new file mode 100644 index 000000000000..13934e9c0221 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_psu_driver.h @@ -0,0 +1,14 @@ +#ifndef _RG_PSU_DRIVER_H_ +#define _RG_PSU_DRIVER_H_ + +ssize_t dfd_get_psu_info(unsigned int psu_index, uint8_t cmd, char *buf, size_t count); + +ssize_t dfd_get_psu_present_status_str(unsigned int psu_index, char *buf, size_t count); + +ssize_t dfd_get_psu_out_status_str(unsigned int psu_index, char *buf, size_t count); + +ssize_t dfd_get_psu_in_status_str(unsigned int psu_index, char *buf, size_t count); + +ssize_t dfd_get_psu_input_type(unsigned int psu_index, char *buf, size_t count); + +#endif /* _RG_PSU_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sensors_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sensors_driver.h new file mode 100644 index 000000000000..464e3bca0ed7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sensors_driver.h @@ -0,0 +1,15 @@ +#ifndef _RG_SENSORS_DRIVER_H_ +#define _RG_SENSORS_DRIVER_H_ + +ssize_t dfd_get_temp_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t temp_index, + uint8_t temp_attr, char *buf, size_t count); + +ssize_t dfd_get_voltage_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t in_index, + uint8_t in_attr, char *buf, size_t count); + +ssize_t dfd_get_current_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t curr_index, + uint8_t curr_attr, char *buf, size_t count); + +ssize_t dfd_get_psu_sensor_info(uint8_t psu_index, uint8_t sensor_type, char *buf, size_t count); + +#endif /* _RG_SENSORS_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sff_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sff_driver.h new file mode 100644 index 000000000000..d1c8e4e68f62 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_sff_driver.h @@ -0,0 +1,8 @@ +#ifndef _RG_SFF_DRIVER_H_ +#define _RG_SFF_DRIVER_H_ + +int dfd_set_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, int value); + +ssize_t dfd_get_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, char *buf, size_t count); + +#endif /* _RG_SFF_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_slot_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_slot_driver.h new file mode 100644 index 000000000000..8ce45618beea --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_slot_driver.h @@ -0,0 +1,8 @@ +#ifndef _RG_SLOT_DRIVER_H_ +#define _RG_SLOT_DRIVER_H_ + +ssize_t dfd_get_slot_status_str(unsigned int slot_index, char *buf, size_t count); + +ssize_t dfd_get_slot_info(unsigned int slot_index, uint8_t cmd, char *buf, size_t count); + +#endif /* _RG_SLOT_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_watchdog_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_watchdog_driver.h new file mode 100644 index 000000000000..3da88d2662f0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/rg_watchdog_driver.h @@ -0,0 +1,8 @@ +#ifndef _RG_WATCHDOG_DRIVER_H_ +#define _RG_WATCHDOG_DRIVER_H_ + +ssize_t dfd_get_watchdog_info(uint8_t type, char *buf, size_t count); + +ssize_t dfd_watchdog_get_status_str(char *buf, size_t count); + +#endif /* _RG_WATCHDOG_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/switch_driver.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/switch_driver.h new file mode 100644 index 000000000000..d7d9788ace75 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/include/switch_driver.h @@ -0,0 +1,61 @@ +#ifndef _SWITCH_DRIVER_H_ +#define _SWITCH_DRIVER_H_ + +#define SWITCH_DEV_NO_SUPPORT "NA" + +typedef enum dbg_level_e { + DBG_VERBOSE = 0x01, + DBG_WARN = 0x02, + DBG_ERROR = 0x04, +} dbg_level_t; + +typedef enum fan_status_e { + FAN_STATUS_ABSENT = 0, + FAN_STATUS_OK = 1, + FAN_STATUS_NOT_OK = 2, +} fan_status_t; + +typedef enum led_status_e { + LED_STATUS_DARK = 0, + LED_STATUS_GREEN = 1, + LED_STATUS_YELLOW = 2, + LED_STATUS_RED = 3, + LED_STATUS_BLUE = 4, + LED_STATUS_GREEN_FLASH = 5, + LED_STATUS_YELLOW_FLASH = 6, + LED_STATUS_RED_FLASH = 7, +} led_status_t; + +typedef enum air_flow_direction_e { + F2B = 0, /* air enters from the front of the cabinet, and exhausts from the back */ + B2F = 1, /* air enters from the back of the cabinet, and exhausts from the front */ +} air_flow_direction_t; + +typedef enum psu_input_type_e { + POWER_DC = 0, + POWER_AC = 1, +} psu_input_type_t; + +typedef enum psu_status_e { + PSU_STATUS_ABSENT = 0, + PSU_STATUS_PRESENT = 1, +} psu_status_t; + +typedef enum psu_io_status_e { + PSU_IO_STATUS_ABNORMAL = 0, + PSU_IO_STATUS_NORMAL = 1, +} psu_io_status_t; + +extern int g_switch_dbg_level; + +#define SWITCH_DEBUG(level, fmt, arg...) do { \ + if (g_switch_dbg_level & level) { \ + if(level >= DBG_ERROR) { \ + printk(KERN_ERR "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } else { \ + printk(KERN_INFO "[DBG-%d]:<%s, %d>:"fmt, level, __FUNCTION__, __LINE__, ##arg); \ + } \ + } \ +} while (0) + +#endif /* _SWITCH_DRIVER_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_cpld_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_cpld_driver.c new file mode 100644 index 000000000000..7a9cc184082a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_cpld_driver.c @@ -0,0 +1,196 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_cpld_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" + +int g_dfd_cpld_dbg_level = 0; +module_param(g_dfd_cpld_dbg_level, int, S_IRUGO | S_IWUSR); + +ssize_t dfd_get_cpld_name(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count) +{ + int key; + char *cpld_name; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL. main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_NAME, main_dev_id, cpld_index); + cpld_name = dfd_ko_cfg_get_item(key); + if (cpld_name == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, cpld%u name config error, key: 0x%08x\n", + main_dev_id, cpld_index, key); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%s\n", cpld_name); + snprintf(buf, count, "%s\n", cpld_name); + return strlen(buf); +} + +ssize_t dfd_get_cpld_type(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count) +{ + int key; + char *cpld_type; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TYPE, main_dev_id, cpld_index); + cpld_type = dfd_ko_cfg_get_item(key); + if (cpld_type == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, cpld%u type config error, key: 0x%08x\n", + main_dev_id, cpld_index, key); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "%s\n", cpld_type); + snprintf(buf, count, "%s\n", cpld_type); + return strlen(buf); +} + +ssize_t dfd_get_cpld_fw_version(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count) +{ + int key, rv; + uint32_t value; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_VERSION, main_dev_id, cpld_index); + rv = dfd_info_get_int(key, &value, NULL); + if (rv < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, cpld%u fw config error, key: 0x%08x, ret: %d\n", + main_dev_id, cpld_index, key, rv); + if (rv == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return rv; + } + + DBG_CPLD_DEBUG(DBG_VERBOSE, "main_dev_id: %u, cpld%u firmware version: %x\n", + main_dev_id, cpld_index, value); + snprintf(buf, count, "%08x\n", value); + return strlen(buf); +} + +ssize_t dfd_get_cpld_hw_version(uint8_t main_dev_id, unsigned int cpld_index, char *buf, size_t count) +{ + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + DBG_CPLD_DEBUG(DBG_VERBOSE, "main_dev_id: %u, cpld%u hardware version not support\n", + main_dev_id, cpld_index); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +int dfd_set_cpld_testreg(uint8_t main_dev_id, unsigned int cpld_index, int value) +{ + int key, ret; + + if (value < 0 || value > 0xff) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, can't set cpld%u test reg value = 0x%02x\n", + main_dev_id, cpld_index, value); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TEST_REG, main_dev_id, cpld_index); + ret = dfd_info_set_int(key, value); + if (ret < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, set cpld%u test reg error, key: 0x%x, ret:%d\n", + main_dev_id, cpld_index, key, ret); + return ret; + } + return DFD_RV_OK; +} + +int dfd_get_cpld_testreg(uint8_t main_dev_id, unsigned int cpld_index, int *value) +{ + int key, ret; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_CPLD_TEST_REG, main_dev_id, cpld_index); + ret = dfd_info_get_int(key, value, NULL); + if (ret < 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "main_dev_id: %u, get cpld%u test reg error, key: 0x%x, ret: %d\n", + main_dev_id, cpld_index, key, ret); + return ret; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_cpld_testreg_str(uint8_t main_dev_id, unsigned int cpld_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DBG_CPLD_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, cpld index: %u\n", + main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_CPLD_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, cpld index: %u\n", + count, main_dev_id, cpld_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_cpld_testreg(main_dev_id, cpld_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "0x%02x\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_eeprom_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_eeprom_driver.c new file mode 100644 index 000000000000..745ed88b482e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_eeprom_driver.c @@ -0,0 +1,107 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_eeprom_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_tlveeprom.h" + +int g_dfd_eeprom_dbg_level = 0; +module_param(g_dfd_eeprom_dbg_level, int, S_IRUGO | S_IWUSR); + +int dfd_get_eeprom_size(int e2_type, int index) +{ + int key; + int *p_eeprom_size; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_EEPROM_SIZE, e2_type, index); + + p_eeprom_size = dfd_ko_cfg_get_item(key); + if (p_eeprom_size == NULL) { + DBG_EEPROM_DEBUG(DBG_ERROR, "get eeprom size error. key:0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + return *p_eeprom_size; +} + +ssize_t dfd_read_eeprom_data(int e2_type, int index, char *buf, loff_t offset, size_t count) +{ + int key; + ssize_t rd_len; + char *eeprom_path; + + if (buf == NULL || offset < 0 || count <= 0) { + DBG_EEPROM_DEBUG(DBG_ERROR, "params error, offset: 0x%llx, rd_count: %lu.\n", + offset, count); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_EEPROM_PATH, e2_type, index); + eeprom_path = dfd_ko_cfg_get_item(key); + if (eeprom_path == NULL) { + DBG_EEPROM_DEBUG(DBG_ERROR, "get eeprom path error, e2_type: %d, index: %d, key: 0x%08x\n", + e2_type, index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_EEPROM_DEBUG(DBG_VERBOSE, "e2_type: %d, index: %d, path: %s, offset: 0x%llx, \ + rd_count: %lu\n", e2_type, index, eeprom_path, offset, count); + + memset(buf, 0, count); + rd_len = dfd_ko_read_file(eeprom_path, offset, buf, count); + if (rd_len < 0) { + DBG_EEPROM_DEBUG(DBG_ERROR, "read eeprom data failed, loc: %s, offset: 0x%llx, \ + rd_count: %lu, ret: %ld,\n", eeprom_path, offset, count, rd_len); + } else { + DBG_EEPROM_DEBUG(DBG_VERBOSE, "read eeprom data success, loc: %s, offset: 0x%llx, \ + rd_count: %lu, rd_len: %ld,\n", eeprom_path, offset, count, rd_len); + } + + return rd_len; +} + +ssize_t dfd_write_eeprom_data(int e2_type, int index, char *buf, loff_t offset, size_t count) +{ + int key; + ssize_t wr_len; + char *eeprom_path; + + if (buf == NULL || offset < 0 || count <= 0) { + DBG_EEPROM_DEBUG(DBG_ERROR, "params error, offset: 0x%llx, count: %lu.\n", offset, count); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_EEPROM_PATH, e2_type, index); + eeprom_path = dfd_ko_cfg_get_item(key); + if (eeprom_path == NULL) { + DBG_EEPROM_DEBUG(DBG_ERROR, "get eeprom path error, e2_type: %d, index: %d, key: 0x%08x\n", + e2_type, index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DBG_EEPROM_DEBUG(DBG_VERBOSE, "e2_type: %d, index: %d, path: %s, offset: 0x%llx, \ + wr_count: %lu.\n", e2_type, index, eeprom_path, offset, count); + + wr_len = dfd_ko_write_file(eeprom_path, offset, buf, count); + if (wr_len < 0) { + DBG_EEPROM_DEBUG(DBG_ERROR, "write eeprom data failed, loc:%s, offset: 0x%llx, \ + wr_count: %lu, ret: %ld.\n", eeprom_path, offset, count, wr_len); + } else { + DBG_EEPROM_DEBUG(DBG_VERBOSE, "write eeprom data success, loc:%s, offset: 0x%llx, \ + wr_count: %lu, wr_len: %ld.\n", eeprom_path, offset, count, wr_len); + } + + return wr_len; +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fan_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fan_driver.c new file mode 100644 index 000000000000..1174a2489014 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fan_driver.c @@ -0,0 +1,724 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_fan_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" +#include "dfd_frueeprom.h" + +#define DFD_FAN_EEPROM_MODE_TLV_STRING "tlv" +#define DFD_FAN_EEPROM_MODE_FRU_STRING "fru" +#define FAN_SIZE (256) + +typedef enum fan_present_status_e { + ABSENT = 0, + PRESENT = 1, +} fan_present_status_t; + +typedef enum fan_motor_status_e { + MOTOR_STALL = 0, + MOTOR_ROLL = 1, +} fan_motor_status_t; + +typedef enum fan_eeprom_mode_e { + FAN_EEPROM_MODE_TLV, /* TLV */ + FAN_EEPROM_MODE_FRU, /*FRU*/ +} fan_eeprom_mode_t; + +typedef struct dfd_dev_head_info_s { + uint8_t ver; + uint8_t flag; + uint8_t hw_ver; + uint8_t type; + int16_t tlv_len; +} dfd_dev_head_info_t; + +typedef struct dfd_dev_tlv_info_s { + uint8_t type; + uint8_t len; + uint8_t data[0]; +} dfd_dev_tlv_info_t; + +int g_dfd_fan_dbg_level = 0; +module_param(g_dfd_fan_dbg_level, int, S_IRUGO | S_IWUSR); + +static char *dfd_get_fan_sysfs_name(void) +{ + int key; + char *sysfs_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SYSFS_NAME, 0, 0); + sysfs_name = dfd_ko_cfg_get_item(key); + if (sysfs_name == NULL) { + DFD_FAN_DEBUG(DBG_VERBOSE, "key=0x%08x, sysfs_name is NULL, use default way.\n", key); + } else { + DFD_FAN_DEBUG(DBG_VERBOSE, "sysfs_name: %s.\n", sysfs_name); + } + return sysfs_name; +} + +static int dfd_get_fan_eeprom_mode(void) +{ + int key, mode; + char *name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_E2_MODE, 0, 0); + name = dfd_ko_cfg_get_item(key); + if (name == NULL) { + DFD_FAN_DEBUG(DBG_WARN, "get fan eeprom mode fail, key=0x%08x\n", key); + return FAN_EEPROM_MODE_TLV; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan eeprom mode_name %s.\n", name); + if (!strncmp(name, DFD_FAN_EEPROM_MODE_TLV_STRING, strlen(DFD_FAN_EEPROM_MODE_TLV_STRING))) { + mode = FAN_EEPROM_MODE_TLV; + } else if (!strncmp(name, DFD_FAN_EEPROM_MODE_FRU_STRING, strlen(DFD_FAN_EEPROM_MODE_FRU_STRING))) { + mode = FAN_EEPROM_MODE_FRU; + } else { + mode = FAN_EEPROM_MODE_TLV; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "fan eeprom mode %d.\n", mode); + return mode; +} + +static int dfd_fan_tlv_eeprom_read(int bus, int addr, uint8_t cmd, char *buf, int len, + const char *sysfs_name) +{ + dfd_dev_head_info_t info; + char tmp_tlv_len[sizeof(uint16_t)]; + char *tlv_data; + dfd_dev_tlv_info_t *tlv; + int buf_len; + int rv, match_flag; + + rv = dfd_ko_i2c_read(bus, addr, 0, (uint8_t *)&info, sizeof(dfd_dev_head_info_t), sysfs_name); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "read fan i2c failed, bus: %d, addr: 0x%x, rv: %d\n", + bus, addr, rv); + return -DFD_RV_DEV_FAIL; + } + + memcpy(tmp_tlv_len, (uint8_t *)&info.tlv_len, sizeof(uint16_t)); + info.tlv_len = (tmp_tlv_len[0] << 8) + tmp_tlv_len[1]; + + if ((info.tlv_len <= 0 ) || (info.tlv_len > 0xFF)) { + DFD_FAN_DEBUG(DBG_ERROR, "fan maybe not set mac.\n"); + return -DFD_RV_TYPE_ERR; + } + DFD_FAN_DEBUG(DBG_VERBOSE, "info.tlv_len: %d\n", info.tlv_len); + + tlv_data = (uint8_t *)kmalloc(info.tlv_len, GFP_KERNEL); + if (tlv_data == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "tlv_data kmalloc failed \n"); + return -DFD_RV_NO_MEMORY; + } + memset(tlv_data, 0, info.tlv_len); + + rv = dfd_ko_i2c_read(bus, addr, sizeof(dfd_dev_head_info_t), tlv_data, info.tlv_len, sysfs_name); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR,"fan eeprom read failed\n"); + kfree(tlv_data); + return -DFD_RV_DEV_FAIL; + } + + buf_len = len - 1; + match_flag = 0; + for (tlv = (dfd_dev_tlv_info_t *)tlv_data; (ulong)tlv < (ulong)tlv_data + info.tlv_len;) { + DFD_FAN_DEBUG(DBG_VERBOSE, "tlv: %p, tlv->type: 0x%x, tlv->len: 0x%x info->tlv_len: 0x%x\n", + tlv, tlv->type, tlv->len, info.tlv_len); + if (tlv->type == cmd && tlv->len <= buf_len ) { + DFD_FAN_DEBUG(DBG_VERBOSE, "find tlv data, copy...\n"); + memcpy(buf, (uint8_t *)tlv->data, tlv->len); + buf_len = (uint32_t)tlv->len; + match_flag = 1; + break; + } + tlv = (dfd_dev_tlv_info_t *)((uint8_t* )tlv + sizeof(dfd_dev_tlv_info_t) + tlv->len); + } + kfree(tlv_data); + if (match_flag == 0) { + DFD_FAN_DEBUG(DBG_ERROR,"can't find fan tlv date. bus: %d, addr: 0x%02x, tlv type: %d.\n", + bus, addr, cmd); + return -DFD_RV_TYPE_ERR; + } + return buf_len; +} + +static int dfd_get_fan_roll_status(unsigned int fan_index, unsigned int motor_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_ROLL_STATUS, fan_index, motor_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan roll status error, fan: %u, motor: %u\n", + fan_index, motor_index); + return ret; + } + return status; +} + +static int dfd_get_fan_present_status(unsigned int fan_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_PRESENT_STATUS, RG_MAIN_DEV_FAN, fan_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan present status error, key: 0x%x\n", key); + return ret; + } + return status; +} + +static int dfd_get_fan_status(unsigned int fan_index) +{ + int motor_num, motor_index, status, errcnt; + + status = dfd_get_fan_present_status(fan_index); + if (status != PRESENT) { + DFD_FAN_DEBUG(DBG_ERROR, "fan index: %u, status: %d\n", fan_index, status); + return status; + } + + motor_num = dfd_get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_MOTOR); + if (motor_num <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get motor number error: %d\n", motor_num); + return -DFD_RV_DEV_FAIL; + } + errcnt = 0; + for (motor_index = 1; motor_index <= motor_num; motor_index++) { + status = dfd_get_fan_roll_status(fan_index, motor_index); + if (status < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan roll status error, fan index: %u, motor index: %d, status: %d\n", + fan_index, motor_index, status); + return status; + } + if (status != MOTOR_ROLL) { + DFD_FAN_DEBUG(DBG_ERROR, + "stall:fan index: %u, motor index: %d, status: %d\n",fan_index, motor_index, status); + errcnt++; + } + } + if (errcnt > 0) { + return FAN_STATUS_NOT_OK; + } + return FAN_STATUS_OK; +} + +ssize_t dfd_get_fan_status_str(unsigned int fan_index, char *buf, size_t count) +{ + int ret; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "params error, fan_index: %u count: %lu", + fan_index, count); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u\n", + count, fan_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_fan_status(fan_index); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan status error, ret: %d, fan_index: %u\n", + ret, fan_index); + return ret; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", ret); +} + +static int dfd_fan_product_name_decode(char *fan_buf, int buf_len) +{ + int key, i, j; + char *p_fan_name, *p_decode_name; + int *fan_type_num; + int *fan_display_num; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_NUM, RG_MAIN_DEV_FAN, RG_MINOR_DEV_FAN); + fan_display_num = dfd_ko_cfg_get_item(key); + if (fan_display_num == NULL) { + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan display name number error, key:0x%x, \ + skip fan name decode\n", key); + return DFD_RV_OK; + } + + for (i = 1; i <= *fan_display_num; i++) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_TYPE_NUM, i, 0); + fan_type_num = dfd_ko_cfg_get_item(key); + if (fan_type_num == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "config error, get fan type number error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + for (j = 1; j <= *fan_type_num; j++) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_NAME, i, j); + p_fan_name = dfd_ko_cfg_get_item(key); + if (p_fan_name == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "config error, get fan origin name error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + if (!strncmp(fan_buf, p_fan_name, strlen(p_fan_name))) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_DECODE_FAN_NAME, i, 0); + p_decode_name = dfd_ko_cfg_get_item(key); + if (p_decode_name == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "config error, get fan decode name error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + memset(fan_buf, 0, buf_len); + strncpy(fan_buf, p_decode_name, buf_len -1); + DFD_FAN_DEBUG(DBG_VERBOSE, "fan name match ok, display fan name: %s.\n", fan_buf); + return DFD_RV_OK; + } + } + } + + DFD_FAN_DEBUG(DBG_ERROR, "fan name: %s error, can't match.\n", fan_buf); + return -DFD_RV_DEV_NOTSUPPORT; +} + +ssize_t dfd_get_fan_info(unsigned int fan_index, uint8_t cmd, char *buf, size_t count) +{ + int key, rv, eeprom_mode; + char fan_buf[FAN_SIZE]; + dfd_i2c_dev_t *i2c_dev; + const char *sysfs_name; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, cmd: 0x%x.\n", fan_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, cmd: 0x%x.\n", + count, fan_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_FAN, fan_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_FAN_DEBUG(DBG_VERBOSE, "can't find fan%u I2C dfd config, key: 0x%08x\n", fan_index, key); + return snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + sysfs_name = dfd_get_fan_sysfs_name(); + eeprom_mode = dfd_get_fan_eeprom_mode(); + memset(fan_buf, 0, FAN_SIZE); + if (eeprom_mode == FAN_EEPROM_MODE_TLV) { + if (cmd == DFD_DEV_INFO_TYPE_PART_NUMBER) { + DFD_FAN_DEBUG(DBG_VERBOSE, "fan tlv not have part_number attributes\n"); + return snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + rv = dfd_fan_tlv_eeprom_read(i2c_dev->bus, i2c_dev->addr, cmd, fan_buf, FAN_SIZE, sysfs_name); + } else { + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, cmd, fan_buf, FAN_SIZE, sysfs_name); + } + + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + + DFD_FAN_DEBUG(DBG_VERBOSE, "%s\n", fan_buf); + if (cmd == DFD_DEV_INFO_TYPE_NAME) { + rv = dfd_fan_product_name_decode(fan_buf, FAN_SIZE); + if (rv < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "fan name decode error. rv: %d\n", rv); + return rv; + } + } + + snprintf(buf, count, "%s\n", fan_buf); + return strlen(buf); +} + +int dfd_get_fan_speed(unsigned int fan_index, unsigned int motor_index, unsigned int *speed) +{ + int key, ret, speed_tmp; + + if (speed == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED, fan_index, motor_index); + ret = dfd_info_get_int(key, &speed_tmp, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed error, key: 0x%x, ret: %d\n", + fan_index, motor_index, key, ret); + return ret; + } + + if (speed_tmp == 0 || speed_tmp == 0xffff) { + *speed = 0; + } else { + *speed = 15000000 / speed_tmp; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_speed_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret; + unsigned int speed; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_fan_speed(fan_index, motor_index, &speed); + if (ret < 0) { + return ret; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", speed); +} + +int dfd_set_fan_pwm(unsigned int fan_index, int pwm) +{ + int key, ret, data; + + if (pwm < 0 || pwm > 100) { + DFD_FAN_DEBUG(DBG_ERROR, "can not set pwm = %d.\n", pwm); + return -DFD_RV_INVALID_VALUE; + } + + data = pwm * 255 / 100; + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_RATIO, fan_index, 0); + ret = dfd_info_set_int(key, data); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "set fan%u ratio error, key: 0x%x,ret: %d\n", + fan_index, key, ret); + return ret; + } + return DFD_RV_OK; +} + +int dfd_get_fan_pwm(unsigned int fan_index, int *pwm) +{ + int key, ret, ratio; + + if (pwm == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_RATIO, fan_index, 0); + ret = dfd_info_get_int(key, &ratio, NULL); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u ratio error, key: 0x%x,ret: %d\n", + fan_index, key, ret); + return ret; + } + if ((ratio * 100) % 255 > 0) { + *pwm = ratio * 100 / 255 + 1; + } else { + *pwm = ratio * 100 / 255; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_pwm_str(unsigned int fan_index, char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u\n", count, + fan_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_pwm(fan_index, &value); + if (ret < 0) { + return ret; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +static int dfd_get_fan_motor_speed_tolerance(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_tolerance; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u, motor index: %u.\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_TOLERANCE, fan_index, motor_index); + p_fan_speed_tolerance = dfd_ko_cfg_get_item(key); + if (p_fan_speed_tolerance == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed tolerance failed, key: 0x%x\n", + fan_index, motor_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_tolerance; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u motor%u speed tolerance ok, key: 0x%x, value: %d\n", + fan_index, motor_index, key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_motor_speed_tolerance_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fan_motor_speed_tolerance(fan_index, motor_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +int dfd_get_fan_speed_target(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_target; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_TARGET, fan_index, motor_index); + p_fan_speed_target = dfd_ko_cfg_get_item(key); + if (p_fan_speed_target == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed target failed, key: 0x%x\n", + fan_index, motor_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_target; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u motor%u speed target ok, key: 0x%x, value: %d\n", + fan_index, motor_index, key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_motor_speed_target_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fan_speed_target(fan_index, motor_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +static int dfd_get_fan_direction(unsigned int fan_index, int *value) +{ + int fan_direction, ret; + char fan_name[FAN_SIZE]; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error, fan index: %u\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_NAME, fan_name, FAN_SIZE); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u name error, ret: %d\n", fan_index, ret); + return ret; + } + dfd_ko_cfg_del_space_lf_cr(fan_name); + DFD_FAN_DEBUG(DBG_VERBOSE, "fan%u name: %s\n", fan_index, fan_name); + + ret = dfd_ko_cfg_get_fan_direction_by_name(fan_name, &fan_direction); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u direction failde, fan name: %s, ret: %d\n", + fan_index, fan_name, ret); + return ret; + } + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u direction ok, fan name: %s, direction: %d\n", + fan_index, fan_name, fan_direction); + *value = fan_direction; + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_direction_str(unsigned int fan_index, char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error, buf is NULL, fan index: %u.\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "param error, buf is NULL, fan index: %u.\n", fan_index); + return -DFD_RV_INVALID_VALUE; + } + + ret = dfd_get_fan_direction(fan_index, &value); + if (ret < 0) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan direction string failed, ret: %d, fan_index: %u\n", + ret, fan_index); + return ret; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +static int dfd_get_fan_motor_speed_max(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_max; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_MAX, fan_index, motor_index); + p_fan_speed_max = dfd_ko_cfg_get_item(key); + if (p_fan_speed_max == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed max failed, key: 0x%x\n", + fan_index, motor_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_max; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u motor%u speed max success, key: 0x%x, value: %d\n", + fan_index, motor_index, key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_motor_speed_max_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fan_motor_speed_max(fan_index, motor_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} + +static int dfd_get_fan_motor_speed_min(unsigned int fan_index, unsigned int motor_index, int *value) +{ + int key; + int *p_fan_speed_min; + + if (value == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "param error. fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FAN_SPEED_MIN, fan_index, motor_index); + p_fan_speed_min = dfd_ko_cfg_get_item(key); + if (p_fan_speed_min == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "get fan%u motor%u speed min failed, key: 0x%x\n", + fan_index, motor_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + *value = *p_fan_speed_min; + DFD_FAN_DEBUG(DBG_VERBOSE, "get fan%u motor%u speed min success, key: 0x%x, value: %d\n", + fan_index, motor_index, key, *value); + return DFD_RV_OK; +} + +ssize_t dfd_get_fan_motor_speed_min_str(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DFD_FAN_DEBUG(DBG_ERROR, "buf is NULL, fan index: %u, motor index: %u\n", + fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_FAN_DEBUG(DBG_ERROR, "buf size error, count: %lu, fan index: %u, motor index: %u\n", + count, fan_index, motor_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fan_motor_speed_min(fan_index, motor_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fpga_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fpga_driver.c new file mode 100644 index 000000000000..20883e20e2eb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_fpga_driver.c @@ -0,0 +1,275 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_fpga_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" + +#define FPGA_REG_WIDTH_MAX (4) + +int g_dfd_fpga_dbg_level = 0; +module_param(g_dfd_fpga_dbg_level, int, S_IRUGO | S_IWUSR); + +ssize_t dfd_get_fpga_name(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + int key; + char *fpga_name; + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL. main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_NAME, main_dev_id, fpga_index); + fpga_name = dfd_ko_cfg_get_item(key); + if (fpga_name == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, fpga%u name config error, key: 0x%08x\n", + main_dev_id, fpga_index, key); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, "%s\n", fpga_name); + snprintf(buf, count, "%s\n", fpga_name); + return strlen(buf); +} + +static ssize_t dfd_get_fpga_model(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + int key, ret, fpga_model_val; + char *fpga_type; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_MODEL_REG, main_dev_id, fpga_index); + ret = dfd_info_get_int(key, &fpga_model_val, NULL); + if (ret < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "get main_dev_id: %u, fpga%u model failed, key: 0x%08x, ret: %d\n", + main_dev_id, fpga_index, key, ret); + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_MODEL_DECODE, fpga_model_val, 0); + fpga_type = dfd_ko_cfg_get_item(key); + if (fpga_type == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, fpga%u decode fpga model val 0x%08x failed\n", + main_dev_id, fpga_index, fpga_model_val); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, + "main_dev_id: %u, fpga%u decode fpga model success, origin value: 0x%08x decode value: %s\n", + main_dev_id, fpga_index, fpga_model_val, fpga_type); + snprintf(buf, count, "%s\n", fpga_type); + return strlen(buf); +} + +ssize_t dfd_get_fpga_type(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + int key; + char *fpga_type; + ssize_t ret; + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_TYPE, main_dev_id, fpga_index); + fpga_type = dfd_ko_cfg_get_item(key); + if (fpga_type == NULL) { + DBG_FPGA_DEBUG(DBG_VERBOSE, + "main_dev_id: %u, fpga%u type config is NULL, try to get fpga type from fpga model\n", + main_dev_id, fpga_index); + ret = dfd_get_fpga_model(main_dev_id, fpga_index, buf, count); + return ret; + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, "%s\n", fpga_type); + snprintf(buf, count, "%s\n", fpga_type); + return strlen(buf); +} + +ssize_t dfd_get_fpga_fw_version(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + int key, rv; + uint32_t value; + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_VERSION, main_dev_id, fpga_index); + rv = dfd_info_get_int(key, &value, NULL); + if (rv < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, fpga%u fw config error, key: 0x%08x, ret: %d\n", + main_dev_id, fpga_index, key, rv); + if (rv == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return rv; + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u firmware version: %x\n", + main_dev_id, fpga_index, value); + snprintf(buf, count, "0x%08x\n", value); + return strlen(buf); +} + +ssize_t dfd_get_fpga_hw_version(uint8_t main_dev_id, unsigned int fpga_index, char *buf, size_t count) +{ + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u hardware version not support\n", + main_dev_id, fpga_index); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +static int value_convert_to_buf(unsigned int value, uint8_t *buf, int len, int pola) +{ + int i; + + if ((pola != INFO_POLA_POSI) && (pola != INFO_POLA_NEGA)) { + DBG_FPGA_DEBUG(DBG_ERROR, "unsupport pola mode: %d\n", pola); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, len); + if (pola == INFO_POLA_POSI) { + for (i = 0; i < len; i++) { + buf[i] = (value >> ((len - i - 1) * 8)) & 0xff; + } + } else { + for (i = 0; i < len; i++) { + buf[i] = (value >> (i * 8)) & 0xff; + } + } + return DFD_RV_OK; +} + +int dfd_set_fpga_testreg(uint8_t main_dev_id, unsigned int fpga_index, unsigned int value) +{ + int key, ret; + uint8_t wr_buf[FPGA_REG_WIDTH_MAX]; + info_ctrl_t *info_ctrl; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_TEST_REG, main_dev_id, fpga_index); + info_ctrl = dfd_ko_cfg_get_item(key); + if (info_ctrl == NULL) { + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u get info ctrl failed, key: 0x%08x\n", + main_dev_id, fpga_index, key); + return -DFD_RV_DEV_NOTSUPPORT; + } + if (info_ctrl->fpath == NULL) { + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u get fpath failed\n", main_dev_id, + fpga_index); + return -DFD_RV_INVALID_VALUE; + } + if (info_ctrl->len > FPGA_REG_WIDTH_MAX) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, fpga%u info_ctrl len: %d, unsupport\n", + main_dev_id, fpga_index, info_ctrl->len); + return -DFD_RV_INVALID_VALUE; + } + + ret = value_convert_to_buf(value, wr_buf, FPGA_REG_WIDTH_MAX, info_ctrl->pola); + if (ret < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "value: 0x%x convert to buf failed, pola:%d, ret: %d\n", + value, info_ctrl->pola, ret); + return ret; + } + + DBG_FPGA_DEBUG(DBG_VERBOSE, "main_dev_id: %u, fpga%u fpath: %s, addr: 0x%x, len: %d value: 0x%x\n", + main_dev_id, fpga_index, info_ctrl->fpath, info_ctrl->addr, info_ctrl->len, value); + ret = dfd_ko_write_file(info_ctrl->fpath, info_ctrl->addr, wr_buf, info_ctrl->len); + if (ret < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "set fpga test reg failed, ret: %d", ret); + return ret; + } + return DFD_RV_OK; +} + +int dfd_get_fpga_testreg(uint8_t main_dev_id, unsigned int fpga_index, int *value) +{ + int key, ret; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_FPGA_TEST_REG, main_dev_id, fpga_index); + ret = dfd_info_get_int(key, value, NULL); + if (ret < 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "main_dev_id: %u, get fpga%u test reg error, key: 0x%x, ret: %d\n", + main_dev_id, fpga_index, key, ret); + return ret; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_fpga_testreg_str(uint8_t main_dev_id, unsigned int fpga_index, + char *buf, size_t count) +{ + int ret, value; + + if (buf == NULL) { + DBG_FPGA_DEBUG(DBG_ERROR, "param error, buf is NULL, main_dev_id: %u, fpga index: %u\n", + main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_FPGA_DEBUG(DBG_ERROR, "buf size error, count: %lu, main_dev_id: %u, fpga index: %u\n", + count, main_dev_id, fpga_index); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + ret = dfd_get_fpga_testreg(main_dev_id, fpga_index, &value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "0x%08x\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_led_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_led_driver.c new file mode 100644 index 000000000000..88e05876dc40 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_led_driver.c @@ -0,0 +1,103 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_led_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_adapter.h" + +int g_dfd_sysled_dbg_level = 0; +module_param(g_dfd_sysled_dbg_level, int, S_IRUGO | S_IWUSR); + +static int dfd_get_led_status_value(uint16_t led_id, uint8_t led_index, int *value) +{ + int key, ori_value, ret; + int *p_decode_value; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS, led_id, led_index); + ret = dfd_info_get_int(key, &ori_value, NULL); + if (ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status error, key: 0x%x, ret: %d\n", key, ret); + return ret; + } + + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS_DECODE, led_id, ori_value); + p_decode_value = dfd_ko_cfg_get_item(key); + if (p_decode_value != NULL) { + DBG_SYSLED_DEBUG(DBG_VERBOSE, "led id: %u index: %u, ori_value: 0x%x, decode value :0x%x\n", + led_id, led_index, ori_value, *p_decode_value); + *value = *p_decode_value; + return DFD_RV_OK; + } + return -DFD_RV_INVALID_VALUE; +} + +ssize_t dfd_get_led_status(uint16_t led_id, uint8_t led_index, char *buf, size_t count) +{ + int ret, led_value; + + if (buf == NULL) { + DBG_SYSLED_DEBUG(DBG_ERROR, "param error, buf is NULL. led_id: %u, led_index: %u\n", + led_id, led_index); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "buf size error, count: %lu, led_id: %u, led_index: %u\n", + count, led_id, led_index); + return -DFD_RV_INVALID_VALUE; + } + memset(buf, 0 , count); + ret = dfd_get_led_status_value(led_id, led_index, &led_value); + if (ret < 0) { + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + DBG_SYSLED_DEBUG(DBG_VERBOSE, "led_id: %u, led_index: %u, can't find config.\n", + led_id, led_index); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status error, ret: %d, led_id: %u, led_index: %u\n", + ret, led_id, led_index); + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", led_value); +} + +ssize_t dfd_set_led_status(uint16_t led_id, uint8_t led_index, int value) +{ + int ret, led_value, key; + + if (value < 0 || value > 0xff) { + DBG_SYSLED_DEBUG(DBG_ERROR, "can not set led status value = %d.\n", value); + return -DFD_RV_INVALID_VALUE; + } + + DBG_SYSLED_DEBUG(DBG_VERBOSE, "set led id: %u index: %u, status[%d].\n", + led_id, led_index, value); + ret = dfd_ko_cfg_get_led_status_decode2_by_regval(value, led_id, &led_value); + if(ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "get led status register error, ret: %d, led_id: %u, value: %d\n", + ret, led_id, value); + return ret; + } + + DBG_SYSLED_DEBUG(DBG_VERBOSE, "get led[%u] index[%u] status[%d] decode value[%d]\n", + led_id, led_index, value, led_value); + key = DFD_CFG_KEY(DFD_CFG_ITEM_LED_STATUS, led_id, led_index); + ret = dfd_info_set_int(key, led_value); + if (ret < 0) { + DBG_SYSLED_DEBUG(DBG_ERROR, "set led status error, key: 0x%x, ret: %d\n", key, ret); + return ret; + } + + return DFD_RV_OK; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_module.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_module.c new file mode 100644 index 000000000000..03f03e8791fa --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_module.c @@ -0,0 +1,47 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_module.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + * * v1.1 sonic_rd@ruijie.com.cn 2021-08-26 S3IP sysfs + */ +#include + +#include "rg_module.h" +#include "dfd_cfg.h" + +int g_dfd_dbg_level = 0; +module_param(g_dfd_dbg_level, int, S_IRUGO | S_IWUSR); + +int32_t rg_dev_cfg_init(void) +{ + return dfd_dev_cfg_init(); +} + +void rg_dev_cfg_exit(void) +{ + dfd_dev_cfg_exit(); + return; +} + +int dfd_get_dev_number(unsigned int main_dev_id, unsigned int minor_dev_id) +{ + int key,dev_num; + int *p_dev_num; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_NUM, main_dev_id, minor_dev_id); + p_dev_num = dfd_ko_cfg_get_item(key); + if (p_dev_num == NULL) { + DBG_DEBUG(DBG_ERROR, "get device number failed, key:0x%x\n",key); + return -DFD_RV_DEV_NOTSUPPORT; + } + dev_num = *p_dev_num; + DBG_DEBUG(DBG_VERBOSE, "get device number ok, number:%d\n",dev_num); + return dev_num; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_psu_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_psu_driver.c new file mode 100644 index 000000000000..3df87ac58b30 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_psu_driver.c @@ -0,0 +1,390 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_psu_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" +#include "dfd_frueeprom.h" + +#define PSU_SIZE (256) +#define RG_GET_PSU_PMBUS_BUS(addr) (((addr) >> 24) & 0xff) +#define RG_GET_PSU_PMBUS_ADDR(addr) (((addr) >> 8) & 0xffff) +#define RG_GET_PSU_PMBUS_OFFSET(addr) ((addr) & 0xff) + +typedef enum dfd_psu_pmbus_type_e { + DFD_PSU_PMBUS_TYPE_AC = 1, + DFD_PSU_PMBUS_TYPE_DC = 2, +} dfd_psu_pmbus_type_t; + +typedef enum dfd_psu_sysfs_type_e { + DFD_PSU_SYSFS_TYPE_DC = 0, + DFD_PSU_SYSFS_TYPE_AC = 1, +} dfd_psu_sysfs_type_t; + +typedef enum dfd_psu_status_e { + DFD_PSU_PRESENT_STATUS = 0, + DFD_PSU_OUTPUT_STATUS = 1, + DFD_PSU_ALERT_STATUS = 2, +} dfd_psu_status_t; + +int g_dfd_psu_dbg_level = 0; +module_param(g_dfd_psu_dbg_level, int, S_IRUGO | S_IWUSR); + +static char *dfd_get_psu_sysfs_name(void) +{ + int key; + char *sysfs_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_SYSFS_NAME, 0, 0); + sysfs_name = dfd_ko_cfg_get_item(key); + if (sysfs_name == NULL) { + DFD_PSU_DEBUG(DBG_VERBOSE, "key=0x%08x, sysfs_name is NULL, use default way.\n", key); + } else { + DFD_PSU_DEBUG(DBG_VERBOSE, "sysfs_name: %s.\n", sysfs_name); + } + return sysfs_name; +} + +static void dfd_psu_del_no_print_string(char *buf) +{ + int i, len; + + len = strlen(buf); + for (i = 0; i < len; i++) { + if ((buf[i] < 0x21) || (buf[i] > 0x7E)) { + buf[i] = '\0'; + break; + } + } + return ; +} + +static int dfd_get_psu_present_status(unsigned int psu_index) +{ + int present_key, present_status; + int ret; + + present_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_PRESENT_STATUS); + ret = dfd_info_get_int(present_key, &present_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "dfd_get_psu_status error. psu_index: %u, ret: %d\n", + psu_index, ret); + return ret; + } + + return present_status; +} + +ssize_t dfd_get_psu_present_status_str(unsigned int psu_index, char *buf, size_t count) +{ + int ret; + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "params error.psu_index: %u.",psu_index); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u\n", + count, psu_index); + return -EINVAL; + } + + ret = dfd_get_psu_present_status(psu_index); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu status error, ret: %d, psu_index: %u\n", ret, psu_index); + return -EIO; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", ret); +} + +ssize_t dfd_get_psu_out_status_str(unsigned int psu_index, char *buf, size_t count) +{ + int ret; + int output_key, output_status; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "params error, psu_index: %u", psu_index); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u\n", + count, psu_index); + return -EINVAL; + } + + output_key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_STATUS, psu_index, DFD_PSU_OUTPUT_STATUS); + ret = dfd_info_get_int(output_key, &output_status, NULL); + if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu out status error, ret: %d, psu_index: %u\n", + ret, psu_index); + return -EIO; + } + memset(buf, 0, count); + return (ssize_t)snprintf(buf, count, "%d\n", output_status); +} + +ssize_t dfd_get_psu_in_status_str(unsigned int psu_index, char *buf, size_t count) +{ + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "params error, psu_index: %u", psu_index); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u\n", + count, psu_index); + return -EINVAL; + } + + memset(buf, 0 , count); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +static int dfd_psu_product_name_decode(int power_type, char *psu_buf, int buf_len) +{ + int key; + char *p_decode_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DECODE_POWER_NAME, power_type, 0); + p_decode_name = dfd_ko_cfg_get_item(key); + if (p_decode_name == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error, get psu decode name error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + memset(psu_buf, 0, buf_len); + strncpy(psu_buf, p_decode_name, buf_len - 1); + DFD_PSU_DEBUG(DBG_VERBOSE, "psu name match ok, display psu name: %s\n", psu_buf); + return DFD_RV_OK; +} + +static int dfd_psu_fan_direction_decode(int power_type, char *psu_buf, int buf_len) +{ + int key; + char *p_decode_direction; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DECODE_POWER_FAN_DIR, power_type, 0); + p_decode_direction = dfd_ko_cfg_get_item(key); + if (p_decode_direction == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error, get psu decode direction error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + memset(psu_buf, 0, buf_len); + snprintf(psu_buf, buf_len, "%d", *p_decode_direction); + DFD_PSU_DEBUG(DBG_VERBOSE, "psu%u fan direction match ok, display psu direction: %s\n", + power_type, psu_buf); + return DFD_RV_OK; +} + +static int dfd_psu_max_output_power(int power_type, char *psu_buf, int buf_len) +{ + int key, value; + int *p_power_max_output_power; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_POWER_RSUPPLY, power_type, 0); + p_power_max_output_power = dfd_ko_cfg_get_item(key); + if (p_power_max_output_power == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "config error, get psu input type error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + value = *p_power_max_output_power; + memset(psu_buf, 0, buf_len); + snprintf(psu_buf, buf_len, "%d", value); + DFD_PSU_DEBUG(DBG_VERBOSE, "psu name %s match max output power %d\n", psu_buf, value); + return DFD_RV_OK; +} + +static int dfd_get_psu_type(unsigned int psu_index, dfd_i2c_dev_t *i2c_dev, int *power_type, + const char *sysfs_name) +{ + int rv; + char psu_buf[PSU_SIZE]; + + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, DFD_DEV_INFO_TYPE_PART_NUMBER, psu_buf, + PSU_SIZE, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu type from eeprom read failed, rv: %d\n", rv); + return -DFD_RV_DEV_FAIL; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "%s\n", psu_buf); + dfd_psu_del_no_print_string(psu_buf); + + DFD_PSU_DEBUG(DBG_VERBOSE, "dfd_psu_product_name_decode get psu name %s\n", psu_buf); + rv = dfd_ko_cfg_get_power_type_by_name((char *)psu_buf, power_type); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get power type by name[%s] fail, rv: %d\n", psu_buf, rv); + return -DFD_RV_NO_NODE; + } + + DFD_PSU_DEBUG(DBG_VERBOSE, "get psu[%u] bus[%d] addr[0x%x] return power_type[0x%x]\n", + psu_index, i2c_dev->bus, i2c_dev->addr, *power_type); + return DFD_RV_OK; +} + +ssize_t dfd_get_psu_info(unsigned int psu_index, uint8_t cmd, char *buf, size_t count) +{ + int key, rv; + char psu_buf[PSU_SIZE]; + dfd_i2c_dev_t *i2c_dev; + int power_type; + const char *sysfs_name; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "buf is NULL, psu index: %u, cmd: 0x%x\n", psu_index, cmd); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u, cmd: 0x%x\n", + count, psu_index, cmd); + return -EINVAL; + } + + memset(buf, 0, count); + memset(psu_buf, 0, PSU_SIZE); + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_PSU, psu_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "psu i2c dev config error, key: 0x%08x\n", key); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + sysfs_name = dfd_get_psu_sysfs_name(); + if (cmd == DFD_DEV_INFO_TYPE_PART_NAME) { + rv = dfd_get_psu_type(psu_index, i2c_dev, &power_type, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu get type error, rv: %d\n", rv); + return -EIO; + } + rv = dfd_psu_product_name_decode(power_type, psu_buf, PSU_SIZE); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu name decode error, power_type[0x%x] rv: %d\n", + power_type, rv); + return -EIO; + } + } else if (cmd == DFD_DEV_INFO_TYPE_FAN_DIRECTION) { + rv = dfd_get_psu_type(psu_index, i2c_dev, &power_type, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu get type error, rv: %d\n", rv); + return -EIO; + } + rv = dfd_psu_fan_direction_decode(power_type, psu_buf, PSU_SIZE); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu input type decode error, power_type[0x%x] rv: %d\n", + power_type, rv); + return -EIO; + } + } else if (cmd == DFD_DEV_INFO_TYPE_MAX_OUTPUT_POWRER) { + rv = dfd_get_psu_type(psu_index, i2c_dev, &power_type, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu get type error, rv:%d\n", rv); + return -EIO; + } + rv = dfd_psu_max_output_power(power_type, psu_buf, PSU_SIZE); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu max ouput power error, power_type[0x%x] rv: %d\n", + power_type, rv); + return -EIO; + } + } else { + rv = dfd_get_fru_data(i2c_dev->bus, i2c_dev->addr, cmd, psu_buf, PSU_SIZE, sysfs_name); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "psu eeprom read failed, rv: %d\n", rv); + return -EIO; + } + } + snprintf(buf, count, "%s\n", psu_buf); + return strlen(buf); +} + +static int dfd_get_psu_pmbus_id(unsigned int psu_index, uint8_t type, uint32_t *p_psu_pmbus_id) +{ + int key; + int *p_psu_pmbus_id_buf; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_PSU_PMBUS_ID, psu_index, type); + p_psu_pmbus_id_buf = dfd_ko_cfg_get_item(key); + if (p_psu_pmbus_id_buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu pmbus id error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + *p_psu_pmbus_id = *p_psu_pmbus_id_buf; + DFD_PSU_DEBUG(DBG_VERBOSE, "get psu pmbus id ok, psu index: %u, id: 0x%x\n", + psu_index, *p_psu_pmbus_id); + return DFD_RV_OK; +} + +static int dfd_get_psu_pmbus_byte(unsigned int psu_index, uint8_t cmd, uint8_t *buf) +{ + int rv; + uint8_t bus, offset; + uint16_t addr; + uint32_t p_psu_pmbus_id; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "buf is NULL, psu index: %u, cmd: 0x%x\n", psu_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_get_psu_pmbus_id(psu_index, cmd, &p_psu_pmbus_id); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_WARN, "get psu%u pmbus %u info failed, rv: %d\n", psu_index, cmd, rv); + return -DFD_RV_DEV_NOTSUPPORT; + } + + bus = RG_GET_PSU_PMBUS_BUS(p_psu_pmbus_id); + addr = RG_GET_PSU_PMBUS_ADDR(p_psu_pmbus_id); + offset = RG_GET_PSU_PMBUS_OFFSET(p_psu_pmbus_id); + rv = dfd_ko_i2c_read(bus, addr, offset, buf, 1, NULL); + if (rv < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "read psu%u pmbus %u info(bus: %d, addr: 0x%02x, offset:%d) failed, rv: %d\n", + psu_index, cmd, bus, addr, offset, rv); + return -DFD_RV_DEV_FAIL; + } + return DFD_RV_OK; +} + +ssize_t dfd_get_psu_input_type(unsigned int psu_index, char *buf, size_t count) +{ + int ret; + uint8_t data; + + if (buf == NULL) { + DFD_PSU_DEBUG(DBG_ERROR, "buf is NULL, psu index: %u\n", psu_index); + return -EINVAL; + } + if (count <= 0) { + DFD_PSU_DEBUG(DBG_ERROR, "buf size error, count: %lu, psu index: %u\n", count, psu_index); + return -EINVAL; + } + + ret = dfd_get_psu_pmbus_byte(psu_index, PSU_IN_TYPE, &data); + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + DFD_PSU_DEBUG(DBG_WARN, "get psu%u pmbus type info don't support\n", psu_index); + return snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } else if (ret < 0) { + DFD_PSU_DEBUG(DBG_ERROR, "get psu%u pmbus type info failed, ret: %d\n", psu_index, ret); + return -EIO; + } + + if (data == DFD_PSU_PMBUS_TYPE_AC) { + return snprintf(buf, count, "%d\n", DFD_PSU_SYSFS_TYPE_AC); + } else if (data == DFD_PSU_PMBUS_TYPE_DC) { + return snprintf(buf, count, "%d\n", DFD_PSU_SYSFS_TYPE_DC); + } + + DFD_PSU_DEBUG(DBG_ERROR, "get psu%u pmbus type data[%u] unknow, ret: %d\n", + psu_index, data, ret); + return -EIO; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sensors_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sensors_driver.c new file mode 100644 index 000000000000..0a4b92497bea --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sensors_driver.c @@ -0,0 +1,230 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_sensor_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" +#include "dfd_frueeprom.h" +#include "dfd_cfg_file.h" + +#define DFD_GET_TEMP_SENSOR_KEY1(dev_index, temp_index) \ + (((dev_index & 0xff) << 8) | (temp_index & 0xff)) +#define DFD_GET_TEMP_SENSOR_KEY2(main_dev_id, temp_type) \ + (((main_dev_id & 0x0f) << 4) | (temp_type & 0x0f)) +#define DFD_FORMAT_STR_MAX_LEN (32) + +int g_dfd_sensor_dbg_level = 0; +module_param(g_dfd_sensor_dbg_level, int, S_IRUGO | S_IWUSR); + +static int dfd_deal_hwmon_buf(uint8_t *buf, int buf_len, uint8_t *buf_new, int *buf_len_new, + info_ctrl_t *info_ctrl, int coefficient, int addend) +{ + int i, tmp_len; + int exp, decimal, divisor; + int org_value, tmp_value; + int div_result, div_mod; + char fmt_str[DFD_FORMAT_STR_MAX_LEN]; + + exp = info_ctrl->int_cons; + decimal = info_ctrl->bit_offset; + + if (exp <= 0) { + DBG_DEBUG(DBG_VERBOSE, "exponent %d, don't need transform, buf_len: %d, buf_len_new: %d\n", + exp, buf_len, *buf_len_new); + snprintf(buf_new, *buf_len_new, "%s", buf); + *buf_len_new = strlen(buf_new); + return DFD_RV_OK; + } + divisor = 1; + for (i = 0; i < exp; i++) { + divisor *= 10; + } + org_value = simple_strtol(buf, NULL, 10); + org_value = (org_value + addend) * coefficient; + if (org_value < 0) { + tmp_value = 0 - org_value; + } else { + tmp_value = org_value; + } + div_result = tmp_value / divisor; + div_mod = tmp_value % divisor; + DBG_DEBUG(DBG_VERBOSE, "exp: %d, decimal: %d, original value: %d, coefficient: %d, \ + divisor: %d, result: %d, mod: %d\n", exp, decimal, org_value, coefficient, divisor, + div_result, div_mod); + + if (decimal == 0) { + snprintf(buf_new, *buf_len_new, "%d\n", div_result); + *buf_len_new = strlen(buf_new); + return DFD_RV_OK; + } + memset(fmt_str, 0, sizeof(fmt_str)); + if (org_value < 0) { + snprintf(fmt_str, sizeof(fmt_str), "-%%d.%%0%dd\n",exp); + } else { + snprintf(fmt_str, sizeof(fmt_str), "%%d.%%0%dd\n",exp); + } + DBG_DEBUG(DBG_VERBOSE, "format string: %s",fmt_str); + snprintf(buf_new, *buf_len_new, fmt_str, div_result, div_mod); + *buf_len_new = strlen(buf_new); + tmp_len = *buf_len_new; + + if (decimal > 0) { + for (i = 0; i < *buf_len_new; i++) { + if (buf_new[i] == '.') { + if ( i + decimal + 2 <= *buf_len_new ) { + buf_new[i + decimal + 1 ] = '\n'; + buf_new[i + decimal + 2 ] = '\0'; + *buf_len_new = strlen(buf_new); + DBG_DEBUG(DBG_VERBOSE, "deal decimal[%d] ok, str len:%d, value:%s\n", + decimal, *buf_len_new, buf_new); + } + break; + } + } + if (tmp_len == *buf_len_new) { + DBG_DEBUG(DBG_WARN, "deal decimal[%d] failed, use original value:%s\n", decimal, + buf_new); + } + } + return DFD_RV_OK; +} + +static int dfd_get_sensor_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t sensor_type, + uint8_t sensor_index, uint8_t sensor_attr, char *buf, size_t count) +{ + uint32_t key; + uint16_t key_index1; + uint8_t key_index2; + int rv; + info_hwmon_buf_f pfunc; + + key_index1 = DFD_GET_TEMP_SENSOR_KEY1(dev_index, sensor_index); + key_index2 = DFD_GET_TEMP_SENSOR_KEY2(main_dev_id, sensor_attr); + if (sensor_type == RG_MINOR_DEV_TEMP ) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_TEMP, key_index1, key_index2); + } else if (sensor_type == RG_MINOR_DEV_IN) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_IN, key_index1, key_index2); + }else if (sensor_type == RG_MINOR_DEV_CURR) { + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_CURR, key_index1, key_index2); + } else { + DFD_SENSOR_DEBUG(DBG_ERROR, "Unknow sensor type: %u\n",sensor_type); + return -DFD_RV_INVALID_VALUE; + } + + DFD_SENSOR_DEBUG(DBG_VERBOSE, "main_dev_id: %u, dev_index: 0x%x, sensor_index: 0x%x, \ + sensor_attr: 0x%x, key: 0x%x\n", main_dev_id, dev_index, sensor_index, sensor_attr, key); + + pfunc = dfd_deal_hwmon_buf; + rv = dfd_info_get_sensor(key, buf, count, pfunc); + return rv; +} + +ssize_t dfd_get_temp_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t temp_index, + uint8_t temp_attr, char *buf, size_t count) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error, buf is NULL\n"); + return -DFD_RV_INVALID_VALUE; + } + + if (count <= 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "buf size error, count: %lu\n", count); + return -DFD_RV_INVALID_VALUE; + } + + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_TEMP, temp_index, temp_attr, + buf, count); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get temp info error, rv: %d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get temp info success, value: %s\n", buf); + } + return rv; +} + +ssize_t dfd_get_voltage_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t in_index, + uint8_t in_attr, char *buf, size_t count) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "buf size error, count: %lu\n", count); + return -DFD_RV_INVALID_VALUE; + } + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_IN, in_index, in_attr, buf, + count); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get voltage info error, rv: %d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get voltage info success, value: %s\n", buf); + } + return rv; +} + +ssize_t dfd_get_current_info(uint8_t main_dev_id, uint8_t dev_index, uint8_t curr_index, + uint8_t curr_attr, char *buf, size_t count) +{ + int rv; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "buf size error, count: %lu\n", count); + return -DFD_RV_INVALID_VALUE; + } + rv = dfd_get_sensor_info(main_dev_id, dev_index, RG_MINOR_DEV_CURR, curr_index, curr_attr, + buf, count); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get current info error, rv: %d\n", rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get current info success, value: %s\n", buf); + } + return rv; +} + +ssize_t dfd_get_psu_sensor_info(uint8_t psu_index, uint8_t sensor_type, char *buf, size_t count) +{ + int rv, key; + info_hwmon_buf_f pfunc; + + if (buf == NULL) { + DFD_SENSOR_DEBUG(DBG_ERROR, "param error. buf is NULL.\n"); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "buf size error, count: %lu\n", count); + return -DFD_RV_INVALID_VALUE; + } + key = DFD_CFG_KEY(DFD_CFG_ITEM_HWMON_PSU, psu_index, sensor_type); + DFD_SENSOR_DEBUG(DBG_VERBOSE, "psu index: %d, sensor type: %d, key: 0x%x,\n", psu_index, + sensor_type, key); + pfunc = dfd_deal_hwmon_buf; + rv = dfd_info_get_sensor(key, buf, count, pfunc); + if (rv < 0) { + DFD_SENSOR_DEBUG(DBG_ERROR, "get psu sensor info error, key: 0x%x, rv: %d\n", key, rv); + } else { + DFD_SENSOR_DEBUG(DBG_VERBOSE, "get psu sensor info success, value: %s\n", buf); + } + return rv; +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sff_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sff_driver.c new file mode 100644 index 000000000000..3a05b131d4a0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_sff_driver.c @@ -0,0 +1,69 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_sff_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_adapter.h" + +int g_dfd_sff_dbg_level = 0; +module_param(g_dfd_sff_dbg_level, int, S_IRUGO | S_IWUSR); + +int dfd_set_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, int value) +{ + int key, ret; + + if ((value != 0) && (value != 1)) { + DFD_SFF_DEBUG(DBG_ERROR, "sff%u cpld reg type %d, can't set invalid value: %d\n", + sff_index, cpld_reg_type, value); + return -DFD_RV_INVALID_VALUE; + } + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_CPLD_REG, sff_index, cpld_reg_type); + ret = dfd_info_set_int(key, value); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "set sff%u cpld reg type %d error, key: 0x%x, ret: %d.\n", + sff_index, cpld_reg_type, key, ret); + return ret; + } + + return DFD_RV_OK; +} + +ssize_t dfd_get_sff_cpld_info(unsigned int sff_index, int cpld_reg_type, char *buf, size_t count) +{ + int key, ret, value; + + if (buf == NULL) { + DFD_SFF_DEBUG(DBG_ERROR, "param error, buf is NULL. sff_index: %u, cpld_reg_type: %d\n", + sff_index, cpld_reg_type); + return -DFD_RV_INVALID_VALUE; + } + if (count <= 0) { + DFD_SFF_DEBUG(DBG_ERROR, "buf size error, count: %lu, sff index: %u, cpld_reg_type: %d\n", + count, sff_index, cpld_reg_type); + return -DFD_RV_INVALID_VALUE; + } + memset(buf, 0 , count); + key = DFD_CFG_KEY(DFD_CFG_ITEM_SFF_CPLD_REG, sff_index, cpld_reg_type); + ret = dfd_info_get_int(key, &value, NULL); + if (ret < 0) { + DFD_SFF_DEBUG(DBG_ERROR, "get sff%u cpld reg type %d error, key: 0x%x, ret: %d\n", + sff_index, cpld_reg_type, key, ret); + if (ret == -DFD_RV_DEV_NOTSUPPORT) { + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + return ret; + } + return (ssize_t)snprintf(buf, count, "%d\n", value); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_slot_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_slot_driver.c new file mode 100644 index 000000000000..ee934fd5d47d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_slot_driver.c @@ -0,0 +1,104 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_slot_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2020-02-17 Initial version + */ + +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_adapter.h" +#include "dfd_cfg_info.h" +#include "dfd_frueeprom.h" + +#define SLOT_SIZE (256) + +int g_dfd_slot_dbg_level = 0; +module_param(g_dfd_slot_dbg_level, int, S_IRUGO | S_IWUSR); + +static char *dfd_get_slot_sysfs_name(void) +{ + int key; + char *sysfs_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_SLOT_SYSFS_NAME, 0, 0); + sysfs_name = dfd_ko_cfg_get_item(key); + if (sysfs_name == NULL) { + DFD_SLOT_DEBUG(DBG_VERBOSE, "key=0x%08x, sysfs_name is NULL, use default way.\n", key); + } else { + DFD_SLOT_DEBUG(DBG_VERBOSE, "sysfs_name: %s.\n", sysfs_name); + } + return sysfs_name; +} + +static int dfd_get_slot_status(unsigned int slot_index) +{ + int key, ret; + int status; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_DEV_PRESENT_STATUS, RG_MAIN_DEV_SLOT, slot_index); + ret = dfd_info_get_int(key, &status, NULL); + if (ret < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "get slot status error, key:0x%x\n",key); + return ret; + } + return status; +} + +ssize_t dfd_get_slot_status_str(unsigned int slot_index, char *buf, size_t count) +{ + int ret; + if (buf == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "params error.slot_index:%d.",slot_index); + return -DFD_RV_INVALID_VALUE; + } + ret = dfd_get_slot_status(slot_index); + if (ret < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "get slot status error,ret:%d, slot_index:%d\n", ret, slot_index); + return ret; + } + memset(buf, 0 , count); + return (ssize_t)snprintf(buf, count, "%d\n", ret); +} + +ssize_t dfd_get_slot_info(unsigned int slot_index, uint8_t cmd, char *buf, size_t count) +{ + int key, rv; + char slot_buf[SLOT_SIZE]; + dfd_i2c_dev_t *i2c_dev; + const char *sysfs_name; + + if (buf == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "buf is NULL, slot index:%d, cmd:%d\n", slot_index, cmd); + return -DFD_RV_INVALID_VALUE; + } + + memset(buf, 0, count); + memset(slot_buf, 0, SLOT_SIZE); + + key = DFD_CFG_KEY(DFD_CFG_ITEM_OTHER_I2C_DEV, RG_MAIN_DEV_SLOT, slot_index); + i2c_dev = dfd_ko_cfg_get_item(key); + if (i2c_dev == NULL) { + DFD_SLOT_DEBUG(DBG_ERROR, "slot i2c dev config error, key=0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + sysfs_name = dfd_get_slot_sysfs_name(); + rv = dfd_get_fru_board_data(i2c_dev->bus, i2c_dev->addr, cmd, slot_buf, SLOT_SIZE, sysfs_name); + + if (rv < 0) { + DFD_SLOT_DEBUG(DBG_ERROR, "slot eeprom read failed"); + return -DFD_RV_DEV_FAIL; + } + + DFD_SLOT_DEBUG(DBG_VERBOSE, "%s\n", slot_buf); + snprintf(buf, count, "%s\n", slot_buf); + return strlen(buf); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_watchdog_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_watchdog_driver.c new file mode 100644 index 000000000000..2207ebf7cf54 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/rg_watchdog_driver.c @@ -0,0 +1,155 @@ +/* + * Copyright(C) 2001-2022 Ruijie Network. All rights reserved. + */ +/* + * rg_watchdog_driver.c + * Original Author: sonic_rd@ruijie.com.cn 2020-02-17 + * + * History + * [Version] [Author] [Date] [Description] + * * v1.0 sonic_rd@ruijie.com.cn 2021-09-05 S3IP sysfs Initial version + */ + +#include +#include +#include + +#include "rg_module.h" +#include "dfd_cfg.h" +#include "dfd_cfg_info.h" +#include "dfd_cfg_adapter.h" + +#define WDT_FILE_NAME_LEN (64) +#define WDT_ABSOLUTE_PATH_NAME_LEN (256) +#define WDT_SYSFS_FILE_DIR ("/sys/class/watchdog/watchdog%d/") + +typedef enum rg_wdt_enable_status_e { + RG_WDT_DISENABLE = 0, /* close watchdog */ + RG_WDT_ENABLE = 1, /* open watchdog */ +} rg_wdt_enable_status_t; + +struct wdt_file_enable_status_s { + rg_wdt_enable_status_t value; + char state[WDT_FILE_NAME_LEN]; +}; + +struct wdt_file_enable_status_s wdt_file_enable_status_match[] = { + {RG_WDT_DISENABLE, "inactive"}, + {RG_WDT_ENABLE, "active"}, +}; + +int g_dfd_watchdog_dbg_level = 0; +module_param(g_dfd_watchdog_dbg_level, int, S_IRUGO | S_IWUSR); + +static int watchdog_file_read(char *fpath, char *buf, int size) +{ + int ret; + struct file *filp; + loff_t pos; + + filp = filp_open(fpath, O_RDONLY, 0); + if (IS_ERR(filp)) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog can't open %s.\n", fpath); + filp = NULL; + ret = -ENOENT; + return ret; + } + + memset(buf, 0, size); + pos = 0; + ret = kernel_read(filp, buf, size - 1, &pos); + if (ret < 0) { + DFD_WDT_DEBUG(DBG_ERROR, "kernel_read failed, path=%s, addr=0, size=%d, ret=%d\n", + fpath, size -1, ret); + } + + filp_close(filp, NULL); + filp = NULL; + return ret; +} + +static int dfd_get_watchdog_id(unsigned int wdt_index) +{ + int key; + int *p_watchdog_id; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_WATCHDOG_ID, wdt_index, 0); + p_watchdog_id = dfd_ko_cfg_get_item(key); + if (p_watchdog_id == NULL) { + DFD_WDT_DEBUG(DBG_ERROR, "get watchdog id error, key: 0x%x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + DFD_WDT_DEBUG(DBG_VERBOSE, "get watchdog id ok, watchdog index:%u, id:0x%x.\n", + wdt_index, *p_watchdog_id); + return *p_watchdog_id; +} + +static int watchdog_get_file_name(unsigned int wdt_index, rg_wdt_type_t type, char *buf, int len) +{ + int key; + char *watchdog_name; + + key = DFD_CFG_KEY(DFD_CFG_ITEM_WATCHDOG_NAME, wdt_index, type); + watchdog_name = dfd_ko_cfg_get_item(key); + if (watchdog_name == NULL) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog name config error, key: 0x%08x\n", key); + return -DFD_RV_DEV_NOTSUPPORT; + } + + DFD_WDT_DEBUG(DBG_VERBOSE, "get watchdog%u %s\n", wdt_index, watchdog_name); + snprintf(buf, len, "%s", watchdog_name); + return DFD_RV_OK; +} + +ssize_t dfd_get_watchdog_info(uint8_t type, char *buf, size_t count) +{ + char fpath[WDT_ABSOLUTE_PATH_NAME_LEN]; + int watchdog_id, len, ret; + + watchdog_id = dfd_get_watchdog_id(0); + memset(fpath, 0, WDT_ABSOLUTE_PATH_NAME_LEN); + snprintf(fpath, WDT_ABSOLUTE_PATH_NAME_LEN - 1, WDT_SYSFS_FILE_DIR, watchdog_id); + len = strlen(fpath); + ret = watchdog_get_file_name(watchdog_id, type, &fpath[len], WDT_ABSOLUTE_PATH_NAME_LEN - len); + if (ret < 0) { + DFD_WDT_DEBUG(DBG_WARN, "watchdog type[%u] don't support to get sysfs name.\n", type); + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); + } + + ret = watchdog_file_read(fpath, buf, count - 1); + if (ret < 0) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog read file %s error, ret: %d\n", fpath, ret); + } + + return ret; +} + +ssize_t dfd_watchdog_get_status_str(char *buf, size_t count) +{ + int ret, i; + int enable_status; + + ret = dfd_get_watchdog_info(RG_WDT_TYPE_STATE, buf, count); + if (ret < 0) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog type[%d] get sysfs name failed.\n", RG_WDT_TYPE_STATE); + return -DFD_RV_DEV_FAIL; + } + + enable_status = -1; + for (i = 0; i < ARRAY_SIZE(wdt_file_enable_status_match); i++) { + if (strncmp(wdt_file_enable_status_match[i].state, buf, \ + strlen(wdt_file_enable_status_match[i].state)) == 0) { + enable_status = wdt_file_enable_status_match[i].value; + DFD_WDT_DEBUG(DBG_VERBOSE, "watchdog read state file %s match enable status[%d].\n", + buf, enable_status); + break; + } + } + + if (enable_status < 0) { + DFD_WDT_DEBUG(DBG_ERROR, "watchdog read state file %s don't match enable status\n", buf); + return -DFD_RV_DEV_FAIL; + } + + return (ssize_t)snprintf(buf, count, "%d\n", enable_status); +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/switch_driver.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/switch_driver.c new file mode 100644 index 000000000000..bdef9840a9dc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/switch_driver/switch_driver.c @@ -0,0 +1,2546 @@ +/* + * switch_driver.c + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ +#include + +#include "dfd_sysfs_common.h" +#include "switch_driver.h" +#include "rg_module.h" +#include "rg_fan_driver.h" +#include "rg_eeprom_driver.h" +#include "rg_cpld_driver.h" +#include "rg_fpga_driver.h" +#include "rg_led_driver.h" +#include "rg_slot_driver.h" +#include "rg_sensors_driver.h" +#include "rg_psu_driver.h" +#include "rg_sff_driver.h" +#include "rg_watchdog_driver.h" + +int g_switch_dbg_level = 0; + +/* change the following parameter by your switch. */ +#define MAIN_BOARD_TEMP_SENSOR_NUMBER (10) +#define MAIN_BOARD_VOL_SENSOR_NUMBER (10) +#define MAIN_BOARD_CURR_SENSOR_NUMBER (0) +#define SYSEEPROM_SIZE (256) +#define FAN_NUMBER (6) +#define FAN_MOTOR_NUMBER (2) +#define PSU_NUMBER (2) +#define PSU_TEMP_SENSOR_NUMBER (3) +#define ETH_NUMBER (32) +#define ETH_EEPROM_SIZE (0x8180) +#define MAIN_BOARD_FPGA_NUMBER (1) +#define MAIN_BOARD_CPLD_NUMBER (5) +#define SLOT_NUMBER (0) +#define SLOT_TEMP_NUMBER (0) +#define SLOT_VOL_NUMBER (0) +#define SLOT_CURR_NUMBER (0) +#define SLOT_FPGA_NUMBER (0) +#define SLOT_CPLD_NUMBER (0) + +/***************************************main board temp*****************************************/ +/* + * dfd_get_main_board_temp_number - Used to get main board temperature sensors number, + * + * This function returns main board temperature sensors by your switch, + * If there is no main board temperature sensors, returns 0, + * otherwise it returns a negative value on failed. + */ +static int dfd_get_main_board_temp_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_TEMP); + return ret; +} + +/* + * dfd_get_main_board_temp_alias - Used to identify the location of the temperature sensor, + * such as air_inlet, air_outlet and so on. + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_alias(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_temp_type - Used to get the model of temperature sensor, + * such as lm75, tmp411 and so on + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_type(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_temp_max - Used to get the maximum threshold of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_max(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_temp_min - Used to get the minimum threshold of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_min(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_temp_value - Used to get the input value of temperature sensor + * filled the value to buf, the value is integer with millidegree Celsius + * @temp_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_temp_value(unsigned int temp_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, temp_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} +/***********************************end of main board temp*************************************/ + +/*************************************main board voltage***************************************/ +static int dfd_get_main_board_vol_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_IN); + return ret; +} + +/* + * dfd_get_main_board_vol_alias - Used to identify the location of the voltage sensor, + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_alias(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_type - Used to get the model of voltage sensor, + * such as udc90160, tps53622 and so on + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_type(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_max - Used to get the maximum threshold of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_max(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_min - Used to get the minimum threshold of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_min(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_range - Used to get the output error value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_range(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, + RG_SENSOR_RANGE, buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_nominal_value - Used to get the nominal value of voltage sensor + * filled the value to buf + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_nominal_value(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, + RG_SENSOR_NOMINAL_VAL, buf, count); + return ret; +} + +/* + * dfd_get_main_board_vol_value - Used to get the input value of voltage sensor + * filled the value to buf, the value is integer with mV + * @vol_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_vol_value(unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, vol_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} +/*********************************end of main board voltage************************************/ +/*************************************main board current***************************************/ +static int dfd_get_main_board_curr_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_CURR); + return ret; +} + +/* + * dfd_get_main_board_curr_alias - Used to identify the location of the current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_alias(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_curr_type - Used to get the model of current sensor, + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_type(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_curr_max - Used to get the maximum threshold of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_max(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_curr_min - Used to get the minimum threshold of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_min(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* + * dfd_get_main_board_curr_value - Used to get the input value of current sensor + * filled the value to buf, the value is integer with mA + * @curr_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_curr_value(unsigned int curr_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_NONE, curr_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} +/*********************************end of main board current************************************/ + +/*****************************************syseeprom*******************************************/ +/* + * dfd_get_syseeprom_size - Used to get syseeprom size + * + * This function returns the size of syseeprom by your switch, + * otherwise it returns a negative value on failed. + */ +static int dfd_get_syseeprom_size(void) +{ + int ret; + + ret = dfd_get_eeprom_size(RG_MAIN_DEV_MAINBOARD, 0); + return ret; +} + +/* + * dfd_read_syseeprom_data - Used to read syseeprom data, + * @buf: Data read buffer + * @offset: offset address to read syseeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_read_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + ssize_t ret; + + ret = dfd_read_eeprom_data(RG_MAIN_DEV_MAINBOARD, 0, buf, offset, count); + return ret; +} + +/* + * dfd_write_syseeprom_data - Used to write syseeprom data + * @buf: Data write buffer + * @offset: offset address to write syseeprom data + * @count: length of buf + * + * This function returns the written length of syseeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_write_syseeprom_data(char *buf, loff_t offset, size_t count) +{ + ssize_t ret; + + ret = dfd_write_eeprom_data(RG_MAIN_DEV_MAINBOARD, 0, buf, offset, count); + return ret; +} +/*************************************end of syseeprom****************************************/ + +/********************************************fan**********************************************/ +static int dfd_get_fan_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_NONE); + return ret; +} + +static int dfd_get_fan_motor_number(unsigned int fan_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_FAN, RG_MINOR_DEV_MOTOR); + return ret; +} + +/* + * dfd_get_fan_model_name - Used to get fan model name, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_model_name(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_NAME, buf, count); + return ret; +} + +/* + * dfd_get_fan_serial_number - Used to get fan serial number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_serial_number(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_SN, buf, count); + return ret; +} + +/* + * dfd_get_fan_part_number - Used to get fan part number, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_part_number(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_PART_NUMBER, buf, count); + return ret; +} + +/* + * dfd_get_fan_hardware_version - Used to get fan hardware version, + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_hardware_version(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_info(fan_index, DFD_DEV_INFO_TYPE_HW_INFO, buf, count); + return ret; +} + +/* + * dfd_get_fan_status - Used to get fan status, + * filled the value to buf, fan status define see enum status_e + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_status(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_status_str(fan_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_led_status - Used to get fan led status + * filled the value to buf, led status value define see enum fan_status_e + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_led_status(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_led_status(RG_FAN_LED_MODULE, fan_index, buf, count); + return ret; +} + +/* + * dfd_set_fan_led_status - Used to set fan led status + * @fan_index: start with 1 + * @status: led status, led status value define see enum led_status_e + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_fan_led_status(unsigned int fan_index, int status) +{ + int ret; + + ret = dfd_set_led_status(RG_FAN_LED_MODULE, fan_index, status); + return ret; +} + +/* + * dfd_get_fan_direction - Used to get fan air flow direction, + * filled the value to buf, air flow direction define see enum air_flow_direction_e + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_direction(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_direction_str(fan_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed - Used to get fan motor speed + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_speed_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed_tolerance - Used to get fan motor speed tolerance + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed_tolerance(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_motor_speed_tolerance_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed_target - Used to get fan motor speed target + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed_target(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_motor_speed_target_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed_max - Used to get the maximum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed_max(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_motor_speed_max_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_motor_speed_min - Used to get the minimum threshold of fan motor + * filled the value to buf + * @fan_index: start with 1 + * @motor_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_motor_speed_min(unsigned int fan_index, unsigned int motor_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_motor_speed_min_str(fan_index, motor_index, buf, count); + return ret; +} + +/* + * dfd_get_fan_ratio - Used to get the ratio of fan + * filled the value to buf + * @fan_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_fan_ratio(unsigned int fan_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fan_pwm_str(fan_index, buf, count); + return ret; +} + +/* + * dfd_set_fan_ratio - Used to set the ratio of fan + * @fan_index: start with 1 + * @ratio: motor speed ratio, from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_fan_ratio(unsigned int fan_index, int ratio) +{ + int ret; + + /* add vendor codes here */ + ret = dfd_set_fan_pwm(fan_index, ratio); + return ret; +} +/****************************************end of fan*******************************************/ +/********************************************psu**********************************************/ +static int dfd_get_psu_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_PSU, RG_MINOR_DEV_NONE); + return ret; +} + +static int dfd_get_psu_temp_number(unsigned int psu_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_PSU, RG_MINOR_DEV_TEMP); + return ret; +} + +/* Similar to dfd_get_psu_model_name */ +static ssize_t dfd_get_psu_model_name(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_PART_NAME, buf, count); + return ret; +} + +/* Similar to rg_get_fan_serial_number */ +static ssize_t dfd_get_psu_serial_number(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_SN, buf, count); + return ret; +} + +/* Similar to rg_get_fan_part_number */ +static ssize_t dfd_get_psu_part_number(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_PART_NUMBER, buf, count); + return ret; +} + +/* Similar to rg_get_fan_hardware_version */ +static ssize_t dfd_get_psu_hardware_version(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_HW_INFO, buf, count); + return ret; +} + +/* + * dfd_get_psu_type - Used to get the input type of psu + * filled the value to buf, input type value define see enum psu_input_type_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_type(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_input_type(psu_index, buf, count); + return ret; +} + +/* + * dfd_get_psu_in_curr - Used to get the input current of psu + * filled the value to buf, the value is integer with mA + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_in_curr(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_IN_CURR, buf, count); + return ret; +} + +/* + * dfd_get_psu_in_vol - Used to get the input voltage of psu + * filled the value to buf, the value is integer with mV + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_in_vol(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_IN_VOL, buf, count); + return ret; +} + +/* + * dfd_get_psu_in_power - Used to get the input power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_in_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_IN_POWER, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_curr - Used to get the output current of psu + * filled the value to buf, the value is integer with mA + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_curr(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_OUT_CURR, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_vol - Used to get the output voltage of psu + * filled the value to buf, the value is integer with mV + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_vol(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_OUT_VOL, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_power - Used to get the output power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_OUT_POWER, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_max_power - Used to get the output max power of psu + * filled the value to buf, the value is integer with uW + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_max_power(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_MAX_OUTPUT_POWRER, buf, count); + return ret; +} + +/* + * dfd_get_psu_present_status - Used to get psu present status + * filled the value to buf, psu present status define see enum psu_status_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_present_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_present_status_str(psu_index, buf, count); + return ret; +} + +/* + * dfd_get_psu_in_status - Used to get psu input status + * filled the value to buf, psu input status define see enum psu_io_status_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_in_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_in_status_str(psu_index, buf, count); + return ret; +} + +/* + * dfd_get_psu_out_status - Used to get psu output status + * filled the value to buf, psu output status define see enum psu_io_status_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_out_status(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_out_status_str(psu_index, buf, count); + return ret; +} + +/* + * dfd_get_psu_fan_speed - Used to get psu fan speed + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_fan_speed(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_sensor_info(psu_index, PSU_FAN_SPEED, buf, count); + return ret; +} + +/* + * dfd_get_psu_fan_ratio - Used to get the ratio of psu fan + * filled the value to buf + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_fan_ratio(unsigned int psu_index, char *buf, size_t count) +{ + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +/* + * dfd_set_psu_fan_ratio - Used to set the ratio of psu fan + * @psu_index: start with 1 + * @ratio: from 0 to 100 + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_psu_fan_ratio(unsigned int psu_index, int ratio) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * dfd_get_psu_fan_direction - Used to get psu air flow direction, + * filled the value to buf, air flow direction define enum air_flow_direction_e + * @psu_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_psu_fan_direction(unsigned int psu_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_psu_info(psu_index, DFD_DEV_INFO_TYPE_FAN_DIRECTION, buf, count); + return ret; +} + +/* Similar to dfd_get_fan_led_status */ +static ssize_t dfd_get_psu_led_status(unsigned int psu_index, char *buf, size_t count) +{ + return (ssize_t)snprintf(buf, count, "%s\n", SWITCH_DEV_NO_SUPPORT); +} + +/* Similar to dfd_get_main_board_temp_alias */ +static ssize_t dfd_get_psu_temp_alias(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_type */ +static ssize_t dfd_get_psu_temp_type(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_TYPE, + buf, count); + return ret; + +} + +/* Similar to dfd_get_main_board_temp_max */ +static ssize_t dfd_get_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* Similar to dfd_set_main_board_temp_max */ +static int dfd_set_psu_temp_max(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to dfd_get_main_board_temp_min */ +static ssize_t dfd_get_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* Similar to dfd_set_main_board_temp_min */ +static int dfd_set_psu_temp_min(unsigned int psu_index, unsigned int temp_index, + const char *buf, size_t count) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* Similar to dfd_get_main_board_temp_value */ +static ssize_t dfd_get_psu_temp_value(unsigned int psu_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_PSU, psu_index, temp_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} +/****************************************end of psu*******************************************/ +/****************************************transceiver******************************************/ +static int dfd_get_eth_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SFF, RG_MINOR_DEV_NONE); + return ret; +} + +/* + * dfd_get_transceiver_power_on_status - Used to get the whole machine port power on status, + * filled the value to buf, 0: power off, 1: power on + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_transceiver_power_on_status(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(0, RG_SFF_POWER_ON, buf, count); + return ret; +} + +/* + * dfd_set_transceiver_power_on_status - Used to set the whole machine port power on status, + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_transceiver_power_on_status(int status) +{ + int ret; + + ret = dfd_set_sff_cpld_info(0, RG_SFF_POWER_ON, status); + return ret; +} + +/* + * dfd_get_eth_power_on_status - Used to get single port power on status, + * filled the value to buf, 0: power off, 1: power on + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_power_on_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_POWER_ON, buf, count); + return ret; +} + +/* + * dfd_set_eth_power_on_status - Used to set single port power on status, + * @eth_index: start with 1 + * @status: power on status, 0: power off, 1: power on + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_eth_power_on_status(unsigned int eth_index, int status) +{ + int ret; + + ret = dfd_set_sff_cpld_info(eth_index, RG_SFF_POWER_ON, status); + return ret; +} + +/* + * dfd_get_eth_tx_fault_status - Used to get port tx_fault status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_tx_fault_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_TX_FAULT, buf, count); + return ret; +} + +/* + * dfd_get_eth_tx_disable_status - Used to get port tx_disable status, + * filled the value to buf, 0: tx_enable, 1: tx_disable + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_tx_disable_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_TX_DIS, buf, count); + return ret; +} + +/* + * dfd_set_eth_tx_disable_status - Used to set port tx_disable status, + * @eth_index: start with 1 + * @status: tx_disable status, 0: tx_enable, 1: tx_disable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_eth_tx_disable_status(unsigned int eth_index, int status) +{ + int ret; + + ret = dfd_set_sff_cpld_info(eth_index, RG_SFF_TX_DIS, status); + return ret; +} + +/* + * dfd_get_eth_present_status - Used to get port present status, + * filled the value to buf, 1: present, 0: absent + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_present_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_MODULE_PRESENT, buf, count); + return ret; +} + +/* + * dfd_get_eth_rx_los_status - Used to get port rx_los status, + * filled the value to buf, 0: normal, 1: abnormal + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_rx_los_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_RX_LOS, buf, count); + return ret; +} + +/* + * dfd_get_eth_reset_status - Used to get port reset status, + * filled the value to buf, 0: unreset, 1: reset + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_reset_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_RESET, buf, count); + return ret; +} + +/* + * dfd_set_eth_reset_status - Used to set port reset status, + * @eth_index: start with 1 + * @status: reset status, 0: unreset, 1: reset + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_eth_reset_status(unsigned int eth_index, int status) +{ + int ret; + + ret = dfd_set_sff_cpld_info(eth_index, RG_SFF_RESET, status); + return ret; +} + +/* + * dfd_get_eth_low_power_mode_status - Used to get port low power mode status, + * filled the value to buf, 0: high power mode, 1: low power mode + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_low_power_mode_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_LPMODE, buf, count); + return ret; +} + +/* + * dfd_get_eth_interrupt_status - Used to get port interruption status, + * filled the value to buf, 0: no interruption, 1: interruption + * @eth_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_eth_interrupt_status(unsigned int eth_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_sff_cpld_info(eth_index, RG_SFF_INTERRUPT, buf, count); + return ret; +} + +/* + * dfd_get_eth_eeprom_size - Used to get port eeprom size + * + * This function returns the size of port eeprom, + * otherwise it returns a negative value on failed. + */ +static int dfd_get_eth_eeprom_size(unsigned int eth_index) +{ + int ret; + + ret = dfd_get_eeprom_size(RG_MAIN_DEV_SFF, eth_index); + return ret; +} + +/* + * dfd_read_eth_eeprom_data - Used to read port eeprom data, + * @buf: Data read buffer + * @offset: offset address to read port eeprom data + * @count: length of buf + * + * This function returns the length of the filled buffer, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_read_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + ssize_t ret; + + ret = dfd_read_eeprom_data(RG_MAIN_DEV_SFF, eth_index, buf, offset, count); + return ret; +} + +/* + * dfd_write_eth_eeprom_data - Used to write port eeprom data + * @buf: Data write buffer + * @offset: offset address to write port eeprom data + * @count: length of buf + * + * This function returns the written length of port eeprom, + * returns 0 means EOF, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_write_eth_eeprom_data(unsigned int eth_index, char *buf, loff_t offset, + size_t count) +{ + ssize_t ret; + + ret = dfd_write_eeprom_data(RG_MAIN_DEV_SFF, eth_index, buf, offset, count); + return ret; +} +/************************************end of transceiver***************************************/ +/*****************************************sysled**********************************************/ +/* + * dfd_get_sys_led_status - Used to get sys led status + * filled the value to buf, led status value define see enum fan_status_e + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_sys_led_status(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_led_status(RG_SYS_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* + * dfd_set_sys_led_status - Used to set sys led status + * @status: led status, led status value define see enum led_status_e + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_sys_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_SYS_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/* Similar to dfd_get_sys_led_status */ +static ssize_t dfd_get_bmc_led_status(char *buf, size_t count) +{ + int ret; + + ret = dfd_get_led_status(RG_BMC_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* Similar to dfd_set_sys_led_status */ +static int dfd_set_bmc_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_BMC_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/* Similar to dfd_get_sys_led_status */ +static ssize_t dfd_get_sys_fan_led_status(char *buf, size_t count) +{ + int ret; + + ret = dfd_get_led_status(RG_FAN_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* Similar to dfd_set_sys_led_status */ +static int dfd_set_sys_fan_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_FAN_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/* Similar to dfd_get_sys_led_status */ +static ssize_t dfd_get_sys_psu_led_status(char *buf, size_t count) +{ + int ret; + + ret = dfd_get_led_status(RG_PSU_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* Similar to dfd_set_sys_led_status */ +static int dfd_set_sys_psu_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_PSU_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/* Similar to dfd_get_sys_led_status */ +static ssize_t dfd_get_id_led_status(char *buf, size_t count) +{ + int ret; + + ret = dfd_get_led_status(RG_ID_LED_FRONT, RG_MINOR_DEV_NONE, buf, count); + return ret; +} + +/* Similar to dfd_set_sys_led_status */ +static int dfd_set_id_led_status(int status) +{ + int ret; + + ret = dfd_set_led_status(RG_ID_LED_FRONT, RG_MINOR_DEV_NONE, status); + return ret; +} + +/**************************************end of sysled******************************************/ +/******************************************FPGA***********************************************/ +static int dfd_get_main_board_fpga_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_FPGA); + return ret; +} + +/* + * dfd_get_main_board_fpga_alias - Used to identify the location of fpga, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_alias(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_name(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_fpga_type - Used to get fpga model name + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_type(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_type(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_fpga_firmware_version - Used to get fpga firmware version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_firmware_version(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_fw_version(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_fpga_board_version - Used to get fpga board version, + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_board_version(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_hw_version(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_fpga_test_reg - Used to test fpga register read + * filled the value to buf, value is hexadecimal, start with 0x + * @fpga_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_fpga_test_reg(unsigned int fpga_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_testreg_str(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, buf, count); + return ret; +} + +/* + * dfd_set_main_board_fpga_test_reg - Used to test fpga register write + * @fpga_index: start with 1 + * @value: value write to fpga + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_main_board_fpga_test_reg(unsigned int fpga_index, unsigned int value) +{ + int ret; + + ret = dfd_set_fpga_testreg(RG_MAIN_DEV_MAINBOARD, fpga_index - 1, value); + return ret; +} +/***************************************end of FPGA*******************************************/ +/******************************************CPLD***********************************************/ +static int dfd_get_main_board_cpld_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_MAINBOARD, RG_MINOR_DEV_CPLD); + return ret; +} + +/* + * dfd_get_main_board_cpld_alias - Used to identify the location of cpld, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_alias(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_name(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_cpld_type - Used to get cpld model name + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_type(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_type(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_cpld_firmware_version - Used to get cpld firmware version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_firmware_version(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_fw_version(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_cpld_board_version - Used to get cpld board version, + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_board_version(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_hw_version(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_get_main_board_cpld_test_reg - Used to test cpld register read + * filled the value to buf, value is hexadecimal, start with 0x + * @cpld_index: start with 1 + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * if not support this attributes filled "NA" to buf, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_main_board_cpld_test_reg(unsigned int cpld_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_testreg_str(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, buf, count); + return ret; +} + +/* + * dfd_set_main_board_cpld_test_reg - Used to test cpld register write + * @cpld_index: start with 1 + * @value: value write to cpld + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_main_board_cpld_test_reg(unsigned int cpld_index, unsigned int value) +{ + int ret; + + ret = dfd_set_cpld_testreg(RG_MAIN_DEV_MAINBOARD, cpld_index - 1, value); + return ret; +} +/***************************************end of CPLD*******************************************/ +/****************************************watchdog*********************************************/ +/* + * dfd_get_watchdog_identify - Used to get watchdog identify, such as iTCO_wdt + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_watchdog_identify(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_watchdog_info(RG_WDT_TYPE_NAME, buf, count); + return ret; +} + +/* + * dfd_get_watchdog_timeleft - Used to get watchdog timeleft, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_watchdog_timeleft(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_watchdog_info(RG_WDT_TYPE_TIMELEFT, buf, count); + return ret; +} + +/* + * dfd_get_watchdog_timeout - Used to get watchdog timeout, + * filled the value to buf + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_watchdog_timeout(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_watchdog_info(RG_WDT_TYPE_TIMEOUT, buf, count); + return ret; +} + +/* + * dfd_set_watchdog_timeout - Used to set watchdog timeout, + * @value: timeout value + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_watchdog_timeout(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * dfd_get_watchdog_enable_status - Used to get watchdog enable status, + * filled the value to buf, 0: disable, 1: enable + * @buf: Data receiving buffer + * @count: length of buf + * + * This function returns the length of the filled buffer, + * otherwise it returns a negative value on failed. + */ +static ssize_t dfd_get_watchdog_enable_status(char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_watchdog_get_status_str(buf, count); + return ret; +} + +/* + * dfd_set_watchdog_enable_status - Used to set watchdog enable status, + * @value: enable status value, 0: disable, 1: enable + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_watchdog_enable_status(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} + +/* + * dfd_set_watchdog_reset - Used to feed watchdog, + * @value: any value to feed watchdog + * + * This function returns 0 on success, + * otherwise it returns a negative value on failed. + */ +static int dfd_set_watchdog_reset(int value) +{ + /* add vendor codes here */ + return -ENOSYS; +} +/*************************************end of watchdog*****************************************/ +/******************************************slot***********************************************/ +static int dfd_get_slot_number(void) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_NONE); + return ret; +} + +static int dfd_get_slot_temp_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_TEMP); + return ret; +} + +static int dfd_get_slot_vol_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_IN); + return ret; +} + +static int dfd_get_slot_curr_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_CURR); + return ret; +} + +static int dfd_get_slot_fpga_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_FPGA); + return ret; +} + +static int dfd_get_slot_cpld_number(unsigned int slot_index) +{ + int ret; + + ret = dfd_get_dev_number(RG_MAIN_DEV_SLOT, RG_MINOR_DEV_CPLD); + return ret; +} + +/* Similar to dfd_get_fan_model_name */ +static ssize_t dfd_get_slot_model_name(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_info(slot_index, DFD_DEV_INFO_TYPE_NAME, buf, count); + return ret; +} + +/* Similar to rg_get_fan_serial_number */ +static ssize_t dfd_get_slot_serial_number(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_info(slot_index, DFD_DEV_INFO_TYPE_SN, buf, count); + return ret; +} + +/* Similar to rg_get_fan_part_number */ +static ssize_t dfd_get_slot_part_number(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_info(slot_index, DFD_DEV_INFO_TYPE_PART_NUMBER, buf, count); + return ret; +} + +/* Similar to rg_get_fan_hardware_version */ +static ssize_t dfd_get_slot_hardware_version(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_info(slot_index, DFD_DEV_INFO_TYPE_HW_INFO, buf, count); + return ret; +} + +/* Similar to dfd_get_fan_status */ +static ssize_t dfd_get_slot_status(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_slot_status_str(slot_index, buf, count); + return ret; +} + +/* Similar to dfd_get_fan_led_status */ +static ssize_t dfd_get_slot_led_status(unsigned int slot_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_led_status(RG_SLOT_LED_MODULE, slot_index, buf, count); + return ret; +} + +/* Similar to dfd_set_fan_led_status */ +static int dfd_set_slot_led_status(unsigned int slot_index, int status) +{ + int ret; + + ret = dfd_set_led_status(RG_SLOT_LED_MODULE, slot_index, status); + return ret; +} + +/* Similar to dfd_get_main_board_temp_alias */ +static ssize_t dfd_get_slot_temp_alias(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_type */ +static ssize_t dfd_get_slot_temp_type(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_max */ +static ssize_t dfd_get_slot_temp_max(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_min */ +static ssize_t dfd_get_slot_temp_min(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_temp_value */ +static ssize_t dfd_get_slot_temp_value(unsigned int slot_index, unsigned int temp_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_temp_info(RG_MAIN_DEV_SLOT, slot_index, temp_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_alias */ +static ssize_t dfd_get_slot_vol_alias(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_type */ +static ssize_t dfd_get_slot_vol_type(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_max */ +static ssize_t dfd_get_slot_vol_max(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_min */ +static ssize_t dfd_get_slot_vol_min(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_range */ +static ssize_t dfd_get_slot_vol_range(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_RANGE, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_nominal_value */ +static ssize_t dfd_get_slot_vol_nominal_value(unsigned int slot_index, + unsigned int vol_index, char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_NOMINAL_VAL, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_vol_value */ +static ssize_t dfd_get_slot_vol_value(unsigned int slot_index, unsigned int vol_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_voltage_info(RG_MAIN_DEV_SLOT, slot_index, vol_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_alias */ +static ssize_t dfd_get_slot_curr_alias(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_ALIAS, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_type */ +static ssize_t dfd_get_slot_curr_type(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_TYPE, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_max */ +static ssize_t dfd_get_slot_curr_max(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_MAX, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_min */ +static ssize_t dfd_get_slot_curr_min(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_MIN, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_curr_value */ +static ssize_t dfd_get_slot_curr_value(unsigned int slot_index, unsigned int curr_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_current_info(RG_MAIN_DEV_SLOT, slot_index, curr_index, RG_SENSOR_INPUT, + buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_alias */ +static ssize_t dfd_get_slot_fpga_alias(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_name(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_type */ +static ssize_t dfd_get_slot_fpga_type(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_type(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_firmware_version */ +static ssize_t dfd_get_slot_fpga_firmware_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_fw_version(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_board_version */ +static ssize_t dfd_get_slot_fpga_board_version(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_hw_version(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_fpga_test_reg */ +static ssize_t dfd_get_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_fpga_testreg_str(slot_index, fpga_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_set_main_board_fpga_test_reg */ +static int dfd_set_slot_fpga_test_reg(unsigned int slot_index, unsigned int fpga_index, + unsigned int value) +{ + int ret; + + ret = dfd_set_fpga_testreg(slot_index, fpga_index - 1, value); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_alias */ +static ssize_t dfd_get_slot_cpld_alias(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_name(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_type */ +static ssize_t dfd_get_slot_cpld_type(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_type(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_firmware_version */ +static ssize_t dfd_get_slot_cpld_firmware_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_fw_version(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_board_version */ +static ssize_t dfd_get_slot_cpld_board_version(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_hw_version(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_get_main_board_cpld_test_reg */ +static ssize_t dfd_get_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + char *buf, size_t count) +{ + ssize_t ret; + + ret = dfd_get_cpld_testreg_str(slot_index, cpld_index - 1, buf, count); + return ret; +} + +/* Similar to dfd_set_main_board_cpld_test_reg */ +static int dfd_set_slot_cpld_test_reg(unsigned int slot_index, unsigned int cpld_index, + unsigned int value) +{ + int ret; + + ret = dfd_set_cpld_testreg(slot_index, cpld_index - 1, value); + return ret; +} +/***************************************end of slot*******************************************/ +static struct switch_drivers_s switch_drivers = { + /* + * set odm switch drivers, + * if not support the function, set corresponding hook to NULL. + */ + /* temperature sensors */ + .get_main_board_temp_number = dfd_get_main_board_temp_number, + .get_main_board_temp_alias = dfd_get_main_board_temp_alias, + .get_main_board_temp_type = dfd_get_main_board_temp_type, + .get_main_board_temp_max = dfd_get_main_board_temp_max, + .get_main_board_temp_min = dfd_get_main_board_temp_min, + .get_main_board_temp_value = dfd_get_main_board_temp_value, + /* voltage sensors */ + .get_main_board_vol_number = dfd_get_main_board_vol_number, + .get_main_board_vol_alias = dfd_get_main_board_vol_alias, + .get_main_board_vol_type = dfd_get_main_board_vol_type, + .get_main_board_vol_max = dfd_get_main_board_vol_max, + .get_main_board_vol_min = dfd_get_main_board_vol_min, + .get_main_board_vol_range = dfd_get_main_board_vol_range, + .get_main_board_vol_nominal_value = dfd_get_main_board_vol_nominal_value, + .get_main_board_vol_value = dfd_get_main_board_vol_value, + /* current sensors */ + .get_main_board_curr_number = dfd_get_main_board_curr_number, + .get_main_board_curr_alias = dfd_get_main_board_curr_alias, + .get_main_board_curr_type = dfd_get_main_board_curr_type, + .get_main_board_curr_max = dfd_get_main_board_curr_max, + .get_main_board_curr_min = dfd_get_main_board_curr_min, + .get_main_board_curr_value = dfd_get_main_board_curr_value, + /* syseeprom */ + .get_syseeprom_size = dfd_get_syseeprom_size, + .read_syseeprom_data = dfd_read_syseeprom_data, + .write_syseeprom_data = dfd_write_syseeprom_data, + /* fan */ + .get_fan_number = dfd_get_fan_number, + .get_fan_motor_number = dfd_get_fan_motor_number, + .get_fan_model_name = dfd_get_fan_model_name, + .get_fan_serial_number = dfd_get_fan_serial_number, + .get_fan_part_number = dfd_get_fan_part_number, + .get_fan_hardware_version = dfd_get_fan_hardware_version, + .get_fan_status = dfd_get_fan_status, + .get_fan_led_status = dfd_get_fan_led_status, + .set_fan_led_status = dfd_set_fan_led_status, + .get_fan_direction = dfd_get_fan_direction, + .get_fan_motor_speed = dfd_get_fan_motor_speed, + .get_fan_motor_speed_tolerance = dfd_get_fan_motor_speed_tolerance, + .get_fan_motor_speed_target = dfd_get_fan_motor_speed_target, + .get_fan_motor_speed_max = dfd_get_fan_motor_speed_max, + .get_fan_motor_speed_min = dfd_get_fan_motor_speed_min, + .get_fan_ratio = dfd_get_fan_ratio, + .set_fan_ratio = dfd_set_fan_ratio, + /* psu */ + .get_psu_number = dfd_get_psu_number, + .get_psu_temp_number = dfd_get_psu_temp_number, + .get_psu_model_name = dfd_get_psu_model_name, + .get_psu_serial_number = dfd_get_psu_serial_number, + .get_psu_part_number = dfd_get_psu_part_number, + .get_psu_hardware_version = dfd_get_psu_hardware_version, + .get_psu_type = dfd_get_psu_type, + .get_psu_in_curr = dfd_get_psu_in_curr, + .get_psu_in_vol = dfd_get_psu_in_vol, + .get_psu_in_power = dfd_get_psu_in_power, + .get_psu_out_curr = dfd_get_psu_out_curr, + .get_psu_out_vol = dfd_get_psu_out_vol, + .get_psu_out_power = dfd_get_psu_out_power, + .get_psu_out_max_power = dfd_get_psu_out_max_power, + .get_psu_present_status = dfd_get_psu_present_status, + .get_psu_in_status = dfd_get_psu_in_status, + .get_psu_out_status = dfd_get_psu_out_status, + .get_psu_fan_speed = dfd_get_psu_fan_speed, + .get_psu_fan_ratio = dfd_get_psu_fan_ratio, + .set_psu_fan_ratio = dfd_set_psu_fan_ratio, + .get_psu_fan_direction = dfd_get_psu_fan_direction, + .get_psu_led_status = dfd_get_psu_led_status, + .get_psu_temp_alias = dfd_get_psu_temp_alias, + .get_psu_temp_type = dfd_get_psu_temp_type, + .get_psu_temp_max = dfd_get_psu_temp_max, + .set_psu_temp_max = dfd_set_psu_temp_max, + .get_psu_temp_min = dfd_get_psu_temp_min, + .set_psu_temp_min = dfd_set_psu_temp_min, + .get_psu_temp_value = dfd_get_psu_temp_value, + /* transceiver */ + .get_eth_number = dfd_get_eth_number, + .get_transceiver_power_on_status = dfd_get_transceiver_power_on_status, + .set_transceiver_power_on_status = dfd_set_transceiver_power_on_status, + .get_eth_power_on_status = dfd_get_eth_power_on_status, + .set_eth_power_on_status = dfd_set_eth_power_on_status, + .get_eth_tx_fault_status = dfd_get_eth_tx_fault_status, + .get_eth_tx_disable_status = dfd_get_eth_tx_disable_status, + .set_eth_tx_disable_status = dfd_set_eth_tx_disable_status, + .get_eth_present_status = dfd_get_eth_present_status, + .get_eth_rx_los_status = dfd_get_eth_rx_los_status, + .get_eth_reset_status = dfd_get_eth_reset_status, + .set_eth_reset_status = dfd_set_eth_reset_status, + .get_eth_low_power_mode_status = dfd_get_eth_low_power_mode_status, + .get_eth_interrupt_status = dfd_get_eth_interrupt_status, + .get_eth_eeprom_size = dfd_get_eth_eeprom_size, + .read_eth_eeprom_data = dfd_read_eth_eeprom_data, + .write_eth_eeprom_data = dfd_write_eth_eeprom_data, + /* sysled */ + .get_sys_led_status = dfd_get_sys_led_status, + .set_sys_led_status = dfd_set_sys_led_status, + .get_bmc_led_status = dfd_get_bmc_led_status, + .set_bmc_led_status = dfd_set_bmc_led_status, + .get_sys_fan_led_status = dfd_get_sys_fan_led_status, + .set_sys_fan_led_status = dfd_set_sys_fan_led_status, + .get_sys_psu_led_status = dfd_get_sys_psu_led_status, + .set_sys_psu_led_status = dfd_set_sys_psu_led_status, + .get_id_led_status = dfd_get_id_led_status, + .set_id_led_status = dfd_set_id_led_status, + /* FPGA */ + .get_main_board_fpga_number = dfd_get_main_board_fpga_number, + .get_main_board_fpga_alias = dfd_get_main_board_fpga_alias, + .get_main_board_fpga_type = dfd_get_main_board_fpga_type, + .get_main_board_fpga_firmware_version = dfd_get_main_board_fpga_firmware_version, + .get_main_board_fpga_board_version = dfd_get_main_board_fpga_board_version, + .get_main_board_fpga_test_reg = dfd_get_main_board_fpga_test_reg, + .set_main_board_fpga_test_reg = dfd_set_main_board_fpga_test_reg, + /* CPLD */ + .get_main_board_cpld_number = dfd_get_main_board_cpld_number, + .get_main_board_cpld_alias = dfd_get_main_board_cpld_alias, + .get_main_board_cpld_type = dfd_get_main_board_cpld_type, + .get_main_board_cpld_firmware_version = dfd_get_main_board_cpld_firmware_version, + .get_main_board_cpld_board_version = dfd_get_main_board_cpld_board_version, + .get_main_board_cpld_test_reg = dfd_get_main_board_cpld_test_reg, + .set_main_board_cpld_test_reg = dfd_set_main_board_cpld_test_reg, + /* watchdog */ + .get_watchdog_identify = dfd_get_watchdog_identify, + .get_watchdog_timeleft = dfd_get_watchdog_timeleft, + .get_watchdog_timeout = dfd_get_watchdog_timeout, + .set_watchdog_timeout = dfd_set_watchdog_timeout, + .get_watchdog_enable_status = dfd_get_watchdog_enable_status, + .set_watchdog_enable_status = dfd_set_watchdog_enable_status, + .set_watchdog_reset = dfd_set_watchdog_reset, + /* slot */ + .get_slot_number = dfd_get_slot_number, + .get_slot_temp_number = dfd_get_slot_temp_number, + .get_slot_vol_number = dfd_get_slot_vol_number, + .get_slot_curr_number = dfd_get_slot_curr_number, + .get_slot_cpld_number = dfd_get_slot_cpld_number, + .get_slot_fpga_number = dfd_get_slot_fpga_number, + .get_slot_model_name = dfd_get_slot_model_name, + .get_slot_serial_number = dfd_get_slot_serial_number, + .get_slot_part_number = dfd_get_slot_part_number, + .get_slot_hardware_version = dfd_get_slot_hardware_version, + .get_slot_status = dfd_get_slot_status, + .get_slot_led_status = dfd_get_slot_led_status, + .set_slot_led_status = dfd_set_slot_led_status, + .get_slot_temp_alias = dfd_get_slot_temp_alias, + .get_slot_temp_type = dfd_get_slot_temp_type, + .get_slot_temp_max = dfd_get_slot_temp_max, + .get_slot_temp_min = dfd_get_slot_temp_min, + .get_slot_temp_value = dfd_get_slot_temp_value, + .get_slot_vol_alias = dfd_get_slot_vol_alias, + .get_slot_vol_type = dfd_get_slot_vol_type, + .get_slot_vol_max = dfd_get_slot_vol_max, + .get_slot_vol_min = dfd_get_slot_vol_min, + .get_slot_vol_range = dfd_get_slot_vol_range, + .get_slot_vol_nominal_value = dfd_get_slot_vol_nominal_value, + .get_slot_vol_value = dfd_get_slot_vol_value, + .get_slot_curr_alias = dfd_get_slot_curr_alias, + .get_slot_curr_type = dfd_get_slot_curr_type, + .get_slot_curr_max = dfd_get_slot_curr_max, + .get_slot_curr_min = dfd_get_slot_curr_min, + .get_slot_curr_value = dfd_get_slot_curr_value, + .get_slot_fpga_alias = dfd_get_slot_fpga_alias, + .get_slot_fpga_type = dfd_get_slot_fpga_type, + .get_slot_fpga_firmware_version = dfd_get_slot_fpga_firmware_version, + .get_slot_fpga_board_version = dfd_get_slot_fpga_board_version, + .get_slot_fpga_test_reg = dfd_get_slot_fpga_test_reg, + .set_slot_fpga_test_reg = dfd_set_slot_fpga_test_reg, + .get_slot_cpld_alias = dfd_get_slot_cpld_alias, + .get_slot_cpld_type = dfd_get_slot_cpld_type, + .get_slot_cpld_firmware_version = dfd_get_slot_cpld_firmware_version, + .get_slot_cpld_board_version = dfd_get_slot_cpld_board_version, + .get_slot_cpld_test_reg = dfd_get_slot_cpld_test_reg, + .set_slot_cpld_test_reg = dfd_set_slot_cpld_test_reg, +}; + +struct switch_drivers_s * switch_driver_get(void) { + return &switch_drivers; +} + +static int32_t __init switch_driver_init(void) +{ + int ret; + + SWITCH_DEBUG(DBG_VERBOSE, "Enter.\n"); + ret = rg_dev_cfg_init(); + if (ret < 0) { + SWITCH_DEBUG(DBG_ERROR, "rg_dev_cfg_init failed ret %d.\n", ret); + return ret; + } + SWITCH_DEBUG(DBG_VERBOSE, "success.\n"); + return 0; +} + +static void __exit switch_driver_exit(void) +{ + SWITCH_DEBUG(DBG_VERBOSE, "switch_driver_exit.\n"); + rg_dev_cfg_exit(); + return; +} + +module_init(switch_driver_init); +module_exit(switch_driver_exit); +EXPORT_SYMBOL(switch_driver_get); +module_param(g_switch_dbg_level, int, S_IRUGO | S_IWUSR); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/Makefile new file mode 100755 index 000000000000..23d988470719 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/Makefile @@ -0,0 +1,27 @@ +PWD = $(shell pwd) + +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall + +s3ip_sysfs-objs := switch.o cpld_sysfs.o \ +curr_sensor_sysfs.o \ +fan_sysfs.o \ +fpga_sysfs.o \ +psu_sysfs.o \ +slot_sysfs.o \ +sysled_sysfs.o \ +temp_sensor_sysfs.o \ +transceiver_sysfs.o \ +vol_sensor_sysfs.o \ +watchdog_sysfs.o \ + +obj-m := s3ip_sysfs.o + +all: + $(MAKE) -C $(KERNEL_SRC)/build M=$(PWD) modules + @if [ ! -d $(sysfs_out_put_dir) ]; then mkdir -p $(sysfs_out_put_dir) ;fi + cp -p $(PWD)/*.ko $(sysfs_out_put_dir) +clean: + rm -f $(PWD)/*.o $(PWD)/*.ko $(PWD)/*.mod.c $(PWD)/.*.cmd $(PWD)/*.mod + rm -f $(PWD)/Module.markers $(PWD)/Module.symvers $(PWD)/modules.order + rm -rf $(PWD)/.tmp_versions diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/cpld_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/cpld_sysfs.c new file mode 100644 index 000000000000..9e3efaca497a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/cpld_sysfs.c @@ -0,0 +1,365 @@ +/* + * cpld_sysfs.c + * + * This module create cpld kobjects and attributes in /sys/s3ip/cpld + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "cpld_sysfs.h" + +static int g_cpld_loglevel = 0; + +#define CPLD_INFO(fmt, args...) do { \ + if (g_cpld_loglevel & INFO) { \ + printk(KERN_INFO "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CPLD_ERR(fmt, args...) do { \ + if (g_cpld_loglevel & ERR) { \ + printk(KERN_ERR "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CPLD_DBG(fmt, args...) do { \ + if (g_cpld_loglevel & DBG) { \ + printk(KERN_DEBUG "[CPLD_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct cpld_obj_s { + struct switch_obj *obj; +}; + +struct cpld_s { + unsigned int cpld_number; + struct cpld_obj_s *cpld; +}; + +static struct cpld_s g_cpld; +static struct switch_obj *g_cpld_obj = NULL; +static struct s3ip_sysfs_cpld_drivers_s *g_cpld_drv = NULL; + +static ssize_t cpld_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_cpld.cpld_number); +} + +static ssize_t cpld_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_alias); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_alias(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u alias failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_type); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_type(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u type failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_firmware_version); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_firmware_version(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u firmware version failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_board_version); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_board_version(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u board version failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int cpld_index; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->get_main_board_cpld_test_reg); + + cpld_index = obj->index; + CPLD_DBG("cpld index: %u\n", cpld_index); + ret = g_cpld_drv->get_main_board_cpld_test_reg(cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + CPLD_ERR("get cpld%u test register failed, ret: %d\n", cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t cpld_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int cpld_index, value; + int ret; + + check_p(g_cpld_drv); + check_p(g_cpld_drv->set_main_board_cpld_test_reg); + + cpld_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_cpld_drv->set_main_board_cpld_test_reg(cpld_index, value); + if (ret < 0) { + CPLD_ERR("set cpld%u test reg failed, value:0x%x, ret: %d.\n", cpld_index, value, ret); + return -EIO; + } + CPLD_DBG("set cpld%u test reg success, value: 0x%x.\n", cpld_index, value); + return count; +} + +/************************************cpld dir and attrs*******************************************/ +static struct switch_attribute cpld_number_att = __ATTR(number, S_IRUGO, cpld_number_show, NULL); + +static struct attribute *cpld_dir_attrs[] = { + &cpld_number_att.attr, + NULL, +}; + +static struct attribute_group cpld_root_attr_group = { + .attrs = cpld_dir_attrs, +}; + +/*******************************cpld[1-n] dir and attrs*******************************************/ +static struct switch_attribute cpld_alias_attr = __ATTR(alias, S_IRUGO, cpld_alias_show, NULL); +static struct switch_attribute cpld_type_attr = __ATTR(type, S_IRUGO, cpld_type_show, NULL); +static struct switch_attribute cpld_fw_version_attr = __ATTR(firmware_version, S_IRUGO, cpld_fw_version_show, NULL); +static struct switch_attribute cpld_board_version_attr = __ATTR(board_version, S_IRUGO, cpld_board_version_show, NULL); +static struct switch_attribute cpld_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, cpld_test_reg_show, cpld_test_reg_store); + +static struct attribute *cpld_attrs[] = { + &cpld_alias_attr.attr, + &cpld_type_attr.attr, + &cpld_fw_version_attr.attr, + &cpld_board_version_attr.attr, + &cpld_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group cpld_attr_group = { + .attrs = cpld_attrs, +}; + +static int cpld_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct cpld_obj_s *curr_cpld; + + curr_cpld = &g_cpld.cpld[index - 1]; + if (curr_cpld->obj) { + sysfs_remove_group(&curr_cpld->obj->kobj, &cpld_attr_group); + switch_kobject_delete(&curr_cpld->obj); + CPLD_DBG("delete cpld%u dir and attrs success.\n", index); + } + + return 0; +} + +static int cpld_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct cpld_obj_s *curr_cpld; + + curr_cpld = &g_cpld.cpld[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "cpld%u", index); + curr_cpld->obj = switch_kobject_create(name, parent); + if (!curr_cpld->obj) { + CPLD_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_cpld->obj->index = index; + if (sysfs_create_group(&curr_cpld->obj->kobj, &cpld_attr_group) != 0) { + CPLD_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_cpld->obj); + return -EBADRQC; + } + CPLD_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int cpld_sub_create_kobj_and_attrs(struct kobject *parent, int cpld_num) +{ + unsigned int cpld_index, i; + + g_cpld.cpld = kzalloc(sizeof(struct cpld_obj_s) * cpld_num, GFP_KERNEL); + if (!g_cpld.cpld) { + CPLD_ERR("kzalloc g_cpld.cpld error, cpld number = %d.\n", cpld_num); + return -ENOMEM; + } + + for(cpld_index = 1; cpld_index <= cpld_num; cpld_index++) { + if(cpld_sub_single_create_kobj_and_attrs(parent, cpld_index) != 0) { + goto error; + } + } + return 0; +error: + for(i = cpld_index; i > 0; i--) { + cpld_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_cpld.cpld); + g_cpld.cpld = NULL; + return -EBADRQC; +} + +/* create cpld[1-n] directory and attributes*/ +static int cpld_sub_create(void) +{ + int ret; + + ret = cpld_sub_create_kobj_and_attrs(&g_cpld_obj->kobj, g_cpld.cpld_number); + return ret; +} + +/* delete cpld[1-n] directory and attributes*/ +static void cpld_sub_remove(void) +{ + unsigned int cpld_index; + + if (g_cpld.cpld) { + for (cpld_index = g_cpld.cpld_number; cpld_index > 0; cpld_index--) { + cpld_sub_single_remove_kobj_and_attrs(cpld_index); + } + kfree(g_cpld.cpld); + g_cpld.cpld = NULL; + } + g_cpld.cpld_number = 0; + return; +} + +/* create cpld directory and number attributes */ +static int cpld_root_create(void) +{ + g_cpld_obj = switch_kobject_create("cpld", NULL); + if (!g_cpld_obj) { + CPLD_ERR("switch_kobject_create cpld error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_cpld_obj->kobj, &cpld_root_attr_group) != 0) { + switch_kobject_delete(&g_cpld_obj); + CPLD_ERR("create cpld dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete cpld directory and number attributes */ +static void cpld_root_remove(void) +{ + if (g_cpld_obj) { + sysfs_remove_group(&g_cpld_obj->kobj, &cpld_root_attr_group); + switch_kobject_delete(&g_cpld_obj); + } + + return; +} + +int s3ip_sysfs_cpld_drivers_register(struct s3ip_sysfs_cpld_drivers_s *drv) +{ + int ret, cpld_num; + + CPLD_INFO("s3ip_sysfs_cpld_drivers_register...\n"); + if (g_cpld_drv) { + CPLD_ERR("g_cpld_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_cpld_number); + g_cpld_drv = drv; + + cpld_num = g_cpld_drv->get_main_board_cpld_number(); + if (cpld_num <= 0) { + CPLD_ERR("cpld number: %d, don't need to create cpld dirs and attrs.\n", cpld_num); + g_cpld_drv = NULL; + return -EINVAL; + } + + memset(&g_cpld, 0, sizeof(struct cpld_s)); + g_cpld.cpld_number = cpld_num; + ret = cpld_root_create(); + if (ret < 0) { + CPLD_ERR("create cpld root dir and attrs failed, ret: %d\n", ret); + g_cpld_drv = NULL; + return ret; + } + ret = cpld_sub_create(); + if (ret < 0) { + CPLD_ERR("create cpld sub dir and attrs failed, ret: %d\n", ret); + cpld_root_remove(); + g_cpld_drv = NULL; + return ret; + } + CPLD_INFO("s3ip_sysfs_cpld_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_cpld_drivers_unregister(void) +{ + if (g_cpld_drv) { + cpld_sub_remove(); + cpld_root_remove(); + g_cpld_drv = NULL; + CPLD_DBG("s3ip_sysfs_cpld_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_cpld_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_cpld_drivers_unregister); +module_param(g_cpld_loglevel, int, 0644); +MODULE_PARM_DESC(g_cpld_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/curr_sensor_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/curr_sensor_sysfs.c new file mode 100644 index 000000000000..7972dd9b3ee1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/curr_sensor_sysfs.c @@ -0,0 +1,391 @@ +/* + * curr_sensor_sysfs.c + * + * This module create curr sensor kobjects and attributes in /sys/s3ip/curr_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "curr_sensor_sysfs.h" + +static int g_curr_sensor_loglevel = 0; + +#define CURR_SENSOR_INFO(fmt, args...) do { \ + if (g_curr_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CURR_SENSOR_ERR(fmt, args...) do { \ + if (g_curr_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define CURR_SENSOR_DBG(fmt, args...) do { \ + if (g_curr_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[CURR_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct curr_sensor_obj_s { + struct switch_obj *obj; +}; + +struct curr_sensor_s { + unsigned int curr_number; + struct curr_sensor_obj_s *curr; +}; + +static struct s3ip_sysfs_curr_sensor_drivers_s *g_curr_sensor_drv = NULL; +static struct curr_sensor_s g_curr_sensor; +static struct switch_obj *g_curr_sensor_obj = NULL; + +static ssize_t curr_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_curr_sensor.curr_number); +} + +static ssize_t curr_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_value); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_value(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u value failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_alias); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_alias(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u alias failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_type); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_type(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u type failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_max); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_max(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u max threshold failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->set_main_board_curr_max); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->set_main_board_curr_max(curr_index, buf, count); + if (ret < 0) { + CURR_SENSOR_ERR("set curr%u max threshold failed, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return -EIO; + } + CURR_SENSOR_DBG("set curr%u max threshold success, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return count; +} + +static ssize_t curr_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->get_main_board_curr_min); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->get_main_board_curr_min(curr_index, buf, PAGE_SIZE); + if (ret < 0) { + CURR_SENSOR_ERR("get curr%u min threshold failed, ret: %d\n", curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t curr_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int curr_index; + int ret; + + check_p(g_curr_sensor_drv); + check_p(g_curr_sensor_drv->set_main_board_curr_min); + + curr_index = obj->index; + CURR_SENSOR_DBG("curr index: %u\n", curr_index); + ret = g_curr_sensor_drv->set_main_board_curr_min(curr_index, buf, count); + if (ret < 0) { + CURR_SENSOR_ERR("set curr%u min threshold failed, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return -EIO; + } + CURR_SENSOR_DBG("set curr%u min threshold success, value: %s, count: %lu, ret: %d\n", + curr_index, buf, count, ret); + return count; +} + +/************************************curr_sensor dir and attrs*******************************************/ +static struct switch_attribute num_curr_att = __ATTR(number, S_IRUGO, curr_sensor_number_show, NULL); + +static struct attribute *curr_sensor_dir_attrs[] = { + &num_curr_att.attr, + NULL, +}; + +static struct attribute_group curr_sensor_root_attr_group = { + .attrs = curr_sensor_dir_attrs, +}; + +/*******************************curr1 curr2 dir and attrs*******************************************/ +static struct switch_attribute curr_value_attr = __ATTR(value, S_IRUGO, curr_sensor_value_show, NULL); +static struct switch_attribute curr_alias_attr = __ATTR(alias, S_IRUGO, curr_sensor_alias_show, NULL); +static struct switch_attribute curr_type_attr = __ATTR(type, S_IRUGO, curr_sensor_type_show, NULL); +static struct switch_attribute curr_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, curr_sensor_max_show, curr_sensor_max_store); +static struct switch_attribute curr_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, curr_sensor_min_show, curr_sensor_min_store); + +static struct attribute *curr_sensor_attrs[] = { + &curr_value_attr.attr, + &curr_alias_attr.attr, + &curr_type_attr.attr, + &curr_max_attr.attr, + &curr_min_attr.attr, + NULL, +}; + +static struct attribute_group curr_sensor_attr_group = { + .attrs = curr_sensor_attrs, +}; + +static int curr_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct curr_sensor_obj_s *curr_sensor; + + curr_sensor = &g_curr_sensor.curr[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "curr%u", index); + curr_sensor->obj = switch_kobject_create(name, parent); + if (!curr_sensor->obj) { + CURR_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + curr_sensor->obj->index = index; + if (sysfs_create_group(&curr_sensor->obj->kobj, &curr_sensor_attr_group) != 0) { + CURR_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_sensor->obj); + return -EBADRQC; + } + CURR_SENSOR_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static void curr_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct curr_sensor_obj_s *curr_sensor; + + curr_sensor = &g_curr_sensor.curr[index - 1]; + if (curr_sensor->obj) { + sysfs_remove_group(&curr_sensor->obj->kobj, &curr_sensor_attr_group); + switch_kobject_delete(&curr_sensor->obj); + CURR_SENSOR_DBG("delete curr%u dir and attrs success.\n", index); + } + + return; +} + +static int curr_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int curr_num) +{ + unsigned int curr_index, i; + + g_curr_sensor.curr = kzalloc(sizeof(struct curr_sensor_obj_s) * curr_num, GFP_KERNEL); + if (!g_curr_sensor.curr) { + CURR_SENSOR_ERR("kzalloc g_curr_sensor.curr error, curr number: %d.\n", curr_num); + return -ENOMEM; + } + + for (curr_index = 1; curr_index <= curr_num; curr_index++) { + if (curr_sensor_sub_single_create_kobj_and_attrs(parent, curr_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = curr_index; i > 0; i--) { + curr_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_curr_sensor.curr); + g_curr_sensor.curr = NULL; + return -EBADRQC; +} + +/* create curr[1-n] directory and attributes*/ +static int curr_sensor_sub_create(void) +{ + int ret; + + ret = curr_sensor_sub_create_kobj_and_attrs(&g_curr_sensor_obj->kobj, + g_curr_sensor.curr_number); + return ret; +} + +/* delete curr[1-n] directory and attributes*/ +static void curr_sensor_sub_remove(void) +{ + unsigned int curr_index; + + if (g_curr_sensor.curr) { + for (curr_index = g_curr_sensor.curr_number; curr_index > 0; curr_index--) { + curr_sensor_sub_single_remove_kobj_and_attrs(curr_index); + } + kfree(g_curr_sensor.curr); + g_curr_sensor.curr = NULL; + } + g_curr_sensor.curr_number = 0; + return; +} + +/* create curr_sensor directory and number attributes */ +static int curr_sensor_root_create(void) +{ + g_curr_sensor_obj = switch_kobject_create("curr_sensor", NULL); + if (!g_curr_sensor_obj) { + CURR_SENSOR_ERR("switch_kobject_create curr_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_curr_sensor_obj->kobj, &curr_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_curr_sensor_obj); + CURR_SENSOR_ERR("create curr_sensor dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete curr_sensor directory and number attributes */ +static void curr_sensor_root_remove(void) +{ + if (g_curr_sensor_obj) { + sysfs_remove_group(&g_curr_sensor_obj->kobj, &curr_sensor_root_attr_group); + switch_kobject_delete(&g_curr_sensor_obj); + } + + return; +} + +int s3ip_sysfs_curr_sensor_drivers_register(struct s3ip_sysfs_curr_sensor_drivers_s *drv) +{ + int ret, curr_num; + + CURR_SENSOR_INFO("s3ip_sysfs_curr_sensor_drivers_register...\n"); + if (g_curr_sensor_drv) { + CURR_SENSOR_ERR("g_curr_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_curr_number); + g_curr_sensor_drv = drv; + + curr_num = g_curr_sensor_drv->get_main_board_curr_number(); + if (curr_num <= 0) { + CURR_SENSOR_ERR("curr sensor number: %d, don't need to create curr_sensor dirs and attrs.\n", + curr_num); + return -EINVAL; + } + memset(&g_curr_sensor, 0, sizeof(struct curr_sensor_s)); + g_curr_sensor.curr_number = curr_num; + ret = curr_sensor_root_create(); + if (ret < 0) { + CURR_SENSOR_ERR("create curr_sensor root dir and attrs failed, ret: %d\n", ret); + g_curr_sensor_drv = NULL; + return ret; + } + + ret = curr_sensor_sub_create(); + if (ret < 0) { + CURR_SENSOR_ERR("create curr_sensor sub dir and attrs failed, ret: %d\n", ret); + curr_sensor_root_remove(); + g_curr_sensor_drv = NULL; + return ret; + } + CURR_SENSOR_INFO("s3ip_sysfs_curr_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_curr_sensor_drivers_unregister(void) +{ + if (g_curr_sensor_drv) { + curr_sensor_sub_remove(); + curr_sensor_root_remove(); + g_curr_sensor_drv = NULL; + CURR_SENSOR_DBG("s3ip_sysfs_curr_sensor_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_curr_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_curr_sensor_drivers_unregister); +module_param(g_curr_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_curr_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fan_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fan_sysfs.c new file mode 100644 index 000000000000..ec3c85b68dcb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fan_sysfs.c @@ -0,0 +1,753 @@ +/* + * fan_sysfs.c + * + * This module create fan kobjects and attributes in /sys/s3ip/fan + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "fan_sysfs.h" + +static int g_fan_loglevel = 0; + +#define FAN_INFO(fmt, args...) do { \ + if (g_fan_loglevel & INFO) { \ + printk(KERN_INFO "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FAN_ERR(fmt, args...) do { \ + if (g_fan_loglevel & ERR) { \ + printk(KERN_ERR "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FAN_DBG(fmt, args...) do { \ + if (g_fan_loglevel & DBG) { \ + printk(KERN_DEBUG "[FAN_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct motor_obj_s { + struct switch_obj *obj; +}; + +struct fan_obj_s { + unsigned int motor_number; + struct motor_obj_s *motor; + struct switch_obj *obj; +}; + +struct fan_s { + unsigned int fan_number; + struct fan_obj_s *fan; +}; + +static struct fan_s g_fan; +static struct switch_obj *g_fan_obj = NULL; +static struct s3ip_sysfs_fan_drivers_s *g_fan_drv = NULL; + +static ssize_t fan_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_fan.fan_number); +} + +static ssize_t fan_motor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + FAN_DBG("fan_motor_number_show, fan index: %u\n", index); + + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_fan.fan[index - 1].motor_number); +} + +static ssize_t fan_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_model_name); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_model_name(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u model name failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_serial_number); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_serial_number(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u serial number failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_part_number); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_part_number(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u part number failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_hardware_version); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_hardware_version(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u hardware version failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_status); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_status(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u status failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_led_status); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_led_status(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u led status failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + unsigned int fan_index; + int ret, led_status; + + check_p(g_fan_drv); + check_p(g_fan_drv->set_fan_led_status); + + fan_index = obj->index; + sscanf(buf, "%d", &led_status); + FAN_DBG("fan index: %u, led_status: %d\n", fan_index, led_status); + ret = g_fan_drv->set_fan_led_status(fan_index, led_status); + if (ret < 0) { + FAN_ERR("set fan%u led_status: %d failed, ret: %d\n", fan_index, led_status, ret); + return -EIO; + } + FAN_DBG("set fan%u led_status: %d success\n", fan_index, led_status); + return count; +} + +static ssize_t fan_motor_speed_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed failed, ret: %d\n", fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_tolerance_show(struct switch_obj *obj, + struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_tolerance); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_tolerance(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed tolerance failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_target_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_target); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_target(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed target failed, ret: %d\n", fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_max_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_max); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_max(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed max threshold failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_motor_speed_min_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int fan_index, motor_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_motor_speed_min); + + p_obj = to_switch_obj(obj->kobj.parent); + fan_index = p_obj->index; + motor_index = obj->index; + FAN_DBG("fan index: %u, motor index: %d\n", fan_index, motor_index); + ret = g_fan_drv->get_fan_motor_speed_min(fan_index, motor_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u motor%u speed min threshold failed, ret: %d\n", + fan_index, motor_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +ssize_t fan_ratio_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_ratio); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_ratio(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u ratio failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fan_ratio_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int fan_index; + int ret, ratio; + + check_p(g_fan_drv); + check_p(g_fan_drv->set_fan_ratio); + + fan_index = obj->index; + sscanf(buf, "%d", &ratio); + if (ratio < 0 || ratio > 100) { + FAN_ERR("param invalid, can not set ratio: %d.\n", ratio); + return -EINVAL; + } + FAN_DBG("fan index: %u, ratio: %d\n", fan_index, ratio); + ret = g_fan_drv->set_fan_ratio(fan_index, ratio); + if (ret < 0) { + FAN_ERR("set fan%u ratio: %d failed, ret: %d\n", fan_index, ratio, ret); + return -EIO; + } + FAN_DBG("set fan%u, ratio: %d success\n", fan_index, ratio); + return count; +} + +ssize_t fan_direction_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fan_index; + int ret; + + check_p(g_fan_drv); + check_p(g_fan_drv->get_fan_direction); + + fan_index = obj->index; + FAN_DBG("fan index: %u\n", fan_index); + ret = g_fan_drv->get_fan_direction(fan_index, buf, PAGE_SIZE); + if (ret < 0) { + FAN_ERR("get fan%u direction failed, ret: %d\n", fan_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +/************************************fan dir and attrs*******************************************/ +static struct switch_attribute fan_number_att = __ATTR(number, S_IRUGO, fan_number_show, NULL); + +static struct attribute *fan_dir_attrs[] = { + &fan_number_att.attr, + NULL, +}; + +static struct attribute_group fan_root_attr_group = { + .attrs = fan_dir_attrs, +}; + +/*******************************fan1 fan2 dir and attrs*******************************************/ +static struct switch_attribute fan_model_name_attr = __ATTR(model_name, S_IRUGO, fan_model_name_show, NULL); +static struct switch_attribute fan_sn_attr = __ATTR(serial_number, S_IRUGO, fan_sn_show, NULL); +static struct switch_attribute fan_pn_attr = __ATTR(part_number, S_IRUGO, fan_pn_show, NULL); +static struct switch_attribute fan_hw_attr = __ATTR(hardware_version, S_IRUGO, fan_hw_show, NULL); +static struct switch_attribute fan_num_motors_attr = __ATTR(motor_number, S_IRUGO, fan_motor_number_show, NULL); +static struct switch_attribute fan_status_attr = __ATTR(status, S_IRUGO, fan_status_show, NULL); +static struct switch_attribute fan_led_status_attr = __ATTR(led_status, S_IRUGO | S_IWUSR, fan_led_status_show, fan_led_status_store); +static struct switch_attribute fan_direction_attr = __ATTR(direction, S_IRUGO, fan_direction_show, NULL); +static struct switch_attribute fan_ratio_attr = __ATTR(ratio, S_IRUGO | S_IWUSR, fan_ratio_show, fan_ratio_store); + +static struct attribute *fan_attrs[] = { + &fan_model_name_attr.attr, + &fan_sn_attr.attr, + &fan_pn_attr.attr, + &fan_hw_attr.attr, + &fan_num_motors_attr.attr, + &fan_status_attr.attr, + &fan_led_status_attr.attr, + &fan_direction_attr.attr, + &fan_ratio_attr.attr, + NULL, +}; + +static struct attribute_group fan_attr_group = { + .attrs = fan_attrs, +}; + +/*******************************motor1 motor2 dir and attrs*******************************************/ +static struct switch_attribute motor_speed_attr = __ATTR(speed, S_IRUGO, fan_motor_speed_show, NULL); +static struct switch_attribute motor_speed_tolerance_attr = __ATTR(speed_tolerance, S_IRUGO, fan_motor_speed_tolerance_show, NULL); +static struct switch_attribute motor_speed_target_attr = __ATTR(speed_target, S_IRUGO, fan_motor_speed_target_show, NULL); +static struct switch_attribute motor_speed_max_attr = __ATTR(speed_max, S_IRUGO, fan_motor_speed_max_show, NULL); +static struct switch_attribute motor_speed_min_attr = __ATTR(speed_min, S_IRUGO, fan_motor_speed_min_show, NULL); + +static struct attribute *motor_attrs[] = { + &motor_speed_attr.attr, + &motor_speed_tolerance_attr.attr, + &motor_speed_target_attr.attr, + &motor_speed_max_attr.attr, + &motor_speed_min_attr.attr, + NULL, +}; + +static struct attribute_group motor_attr_group = { + .attrs = motor_attrs, +}; + +static void fanindex_single_motor_remove_kobj_and_attrs(struct fan_obj_s *curr_fan, unsigned int motor_index) +{ + struct motor_obj_s *curr_motor; /* point to motor1 motor2...*/ + + curr_motor = &curr_fan->motor[motor_index - 1]; + if (curr_motor->obj) { + sysfs_remove_group(&curr_motor->obj->kobj, &motor_attr_group); + switch_kobject_delete(&curr_motor->obj); + FAN_DBG("delete fan%u motor%u dir and attrs success.\n", curr_fan->obj->index, + motor_index); + } + return; +} + +static int fanindex_single_motor_create_kobj_and_attrs(struct fan_obj_s *curr_fan, unsigned int motor_index) +{ + char name[8]; + struct motor_obj_s *curr_motor; /* point to motor1 motor2...*/ + + curr_motor = &curr_fan->motor[motor_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "motor%u", motor_index); + curr_motor->obj = switch_kobject_create(name, &curr_fan->obj->kobj); + if (!curr_motor->obj) { + FAN_ERR("create fan%u, motor%u object error!\n", curr_fan->obj->index, motor_index); + return -ENOMEM; + } + + curr_motor->obj->index = motor_index; + if (sysfs_create_group(&curr_motor->obj->kobj, &motor_attr_group) != 0) { + FAN_ERR("create fan%u, motor%u attrs error.\n", curr_fan->obj->index, motor_index); + switch_kobject_delete(&curr_motor->obj); + return -EBADRQC; + } + FAN_DBG("create fan%u, motor%u dir and attrs success.\n", curr_fan->obj->index, motor_index); + return 0; +} + +/* create motor[1-n] directory and attributes in fan directory */ +static int fanindex_motor_create_kobj_and_attrs(struct fan_obj_s *curr_fan) +{ + unsigned int motor_index, i, motor_num; + + motor_num = curr_fan->motor_number; + curr_fan->motor = kzalloc(sizeof(struct motor_obj_s) * motor_num, GFP_KERNEL); + if (!curr_fan->motor) { + FAN_ERR("kzalloc motor error, fan index: %u, motor number: %d.\n", + curr_fan->obj->index, motor_num); + return -ENOMEM; + } + for(motor_index = 1; motor_index <= motor_num; motor_index++) { + if(fanindex_single_motor_create_kobj_and_attrs(curr_fan, motor_index) != 0 ) { + goto motor_error; + } + } + return 0; +motor_error: + for(i = motor_index; i > 0; i--) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, i); + } + kfree(curr_fan->motor); + curr_fan->motor = NULL; + return -EBADRQC; +} + +/* delete motor[1-n] directory and attributes in fan directory */ +static void fanindex_motor_remove_kobj_and_attrs(struct fan_obj_s *curr_fan) +{ + unsigned int motor_index, motor_num; + + if (curr_fan->motor) { + motor_num = curr_fan->motor_number; + for(motor_index = motor_num; motor_index > 0; motor_index--) { + fanindex_single_motor_remove_kobj_and_attrs(curr_fan, motor_index); + } + kfree(curr_fan->motor); + curr_fan->motor = NULL; + } + + return; +} + +/* create motor[1-n] directory and attributes */ +static int fan_motor_create(void) +{ + int fan_num, motor_num; + unsigned int fan_index, i; + struct fan_obj_s *curr_fan; /* point to fan1 fan2...*/ + + fan_num = g_fan.fan_number; + if (fan_num <= 0) { + FAN_DBG("fan number: %d, skip to create motor* dirs and attrs.\n", fan_num); + return 0; + } + + check_p(g_fan_drv->get_fan_motor_number); + + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + motor_num = g_fan_drv->get_fan_motor_number(fan_index); + if (motor_num <= 0) { + FAN_DBG("fan%u motor number: %d, don't need to create motor* dirs and attrs.\n", + fan_index, motor_num); + continue; + } + curr_fan = &g_fan.fan[fan_index - 1]; + curr_fan->motor_number = motor_num; + if(fanindex_motor_create_kobj_and_attrs(curr_fan) != 0) { + goto error; + } + } + return 0; +error: + for(i = fan_index; i > 0; i--) { + curr_fan = &g_fan.fan[i - 1]; + fanindex_motor_remove_kobj_and_attrs(curr_fan); + } + return -EBADRQC; +} + +/* delete motor[1-n] directory and attributes */ +static void fan_motor_remove(void) +{ + unsigned int fan_index; + struct fan_obj_s *curr_fan; + + if (g_fan.fan) { + for (fan_index = g_fan.fan_number; fan_index > 0; fan_index--) { + curr_fan = &g_fan.fan[fan_index - 1]; + fanindex_motor_remove_kobj_and_attrs(curr_fan); + curr_fan->motor_number = 0; + } + } + return; +} + +static int fan_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct fan_obj_s *curr_fan; + + curr_fan = &g_fan.fan[index - 1]; + if (curr_fan->obj) { + sysfs_remove_group(&curr_fan->obj->kobj, &fan_attr_group); + switch_kobject_delete(&curr_fan->obj); + FAN_DBG("delete fan%u dir and attrs success.\n", index); + } + return 0; +} + +static int fan_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct fan_obj_s *curr_fan; + + curr_fan = &g_fan.fan[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fan%u", index); + curr_fan->obj = switch_kobject_create(name, parent); + if (!curr_fan->obj) { + FAN_ERR("create %s object error!\n", name); + return -ENOMEM; + } + + curr_fan->obj->index = index; + if (sysfs_create_group(&curr_fan->obj->kobj, &fan_attr_group) != 0) { + FAN_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_fan->obj); + return -EBADRQC; + } + FAN_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +/* create fan[1-n] directory and attributes */ +static int fan_sub_create_kobj_and_attrs(struct kobject *parent, int fan_num) +{ + unsigned int fan_index, i; + + g_fan.fan = kzalloc(sizeof(struct fan_obj_s) * fan_num, GFP_KERNEL); + if (!g_fan.fan) { + FAN_ERR("kzalloc fan.fan error, fan number: %d.\n", fan_num); + return -ENOMEM; + } + + for(fan_index = 1; fan_index <= fan_num; fan_index++) { + if(fan_sub_single_create_kobj_and_attrs(parent, fan_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = fan_index; i > 0; i--) { + fan_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_fan.fan); + g_fan.fan = NULL; + return -EBADRQC; +} + +static int fan_sub_create(void) +{ + int ret; + + ret = fan_sub_create_kobj_and_attrs(&g_fan_obj->kobj, g_fan.fan_number); + return ret; +} + +/* delete fan[1-n] directory and attributes */ +static void fan_sub_remove(void) +{ + unsigned int fan_index; + + if (g_fan.fan) { + for (fan_index = g_fan.fan_number; fan_index > 0; fan_index--) { + fan_sub_single_remove_kobj_and_attrs(fan_index); + } + kfree(g_fan.fan); + g_fan.fan = NULL; + } + g_fan.fan_number = 0; + + return; +} + +/* create fan directory and number attributes */ +static int fan_root_create(void) +{ + g_fan_obj = switch_kobject_create("fan", NULL); + if (!g_fan_obj) { + FAN_ERR("switch_kobject_create fan error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_fan_obj->kobj, &fan_root_attr_group) != 0) { + switch_kobject_delete(&g_fan_obj); + FAN_ERR("create fan dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete fan directory and number attributes */ +static void fan_root_remove(void) +{ + if (g_fan_obj) { + sysfs_remove_group(&g_fan_obj->kobj, &fan_root_attr_group); + switch_kobject_delete(&g_fan_obj); + FAN_DBG("delete fan dir and attrs success.\n"); + } + return; +} + +int s3ip_sysfs_fan_drivers_register(struct s3ip_sysfs_fan_drivers_s *drv) +{ + int ret, fan_num; + + FAN_INFO("s3ip_sysfs_fan_drivers_register...\n"); + if (g_fan_drv) { + FAN_ERR("g_fan_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_fan_number); + g_fan_drv = drv; + + fan_num = g_fan_drv->get_fan_number(); + if (fan_num <= 0) { + FAN_ERR("fan number: %d, don't need to create fan dirs and attrs.\n", fan_num); + g_fan_drv = NULL; + return -EINVAL; + } + + memset(&g_fan, 0, sizeof(struct fan_s)); + g_fan.fan_number = fan_num; + ret = fan_root_create(); + if (ret < 0) { + FAN_ERR("create fan root dir and attrs failed, ret: %d\n", ret); + g_fan_drv = NULL; + return ret; + } + + ret = fan_sub_create(); + if (ret < 0) { + FAN_ERR("create fan sub dir and attrs failed, ret: %d\n", ret); + fan_root_remove(); + g_fan_drv = NULL; + return ret; + } + + ret = fan_motor_create(); + if (ret < 0) { + FAN_ERR("create fan motor dir and attrs failed, ret: %d\n", ret); + fan_sub_remove(); + fan_root_remove(); + g_fan_drv = NULL; + return ret; + } + FAN_INFO("s3ip_sysfs_fan_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_fan_drivers_unregister(void) +{ + if (g_fan_drv) { + fan_motor_remove(); + fan_sub_remove(); + fan_root_remove(); + g_fan_drv = NULL; + FAN_DBG("s3ip_sysfs_fan_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_fan_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_fan_drivers_unregister); +module_param(g_fan_loglevel, int, 0644); +MODULE_PARM_DESC(g_fan_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fpga_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fpga_sysfs.c new file mode 100644 index 000000000000..8a202c767acc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/fpga_sysfs.c @@ -0,0 +1,365 @@ +/* + * fpga_sysfs.c + * + * This module create fpga kobjects and attributes in /sys/s3ip/fpga + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "fpga_sysfs.h" + +static int g_fpga_loglevel = 0; + +#define FPGA_INFO(fmt, args...) do { \ + if (g_fpga_loglevel & INFO) { \ + printk(KERN_INFO "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_ERR(fmt, args...) do { \ + if (g_fpga_loglevel & ERR) { \ + printk(KERN_ERR "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define FPGA_DBG(fmt, args...) do { \ + if (g_fpga_loglevel & DBG) { \ + printk(KERN_DEBUG "[FPGA_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct fpga_obj_s { + struct switch_obj *obj; +}; + +struct fpga_s { + unsigned int fpga_number; + struct fpga_obj_s *fpga; +}; + +static struct fpga_s g_fpga; +static struct switch_obj *g_fpga_obj = NULL; +static struct s3ip_sysfs_fpga_drivers_s *g_fpga_drv = NULL; + +static ssize_t fpga_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_fpga.fpga_number); +} + +static ssize_t fpga_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_alias); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_alias(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u alias failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_type); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_type(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u type failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_firmware_version); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_firmware_version(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u firmware version failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_board_version); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_board_version(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u board version failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int fpga_index; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->get_main_board_fpga_test_reg); + + fpga_index = obj->index; + FPGA_DBG("fpga index: %u\n", fpga_index); + ret = g_fpga_drv->get_main_board_fpga_test_reg(fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + FPGA_ERR("get fpga%u test register failed, ret: %d\n", fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t fpga_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int fpga_index, value; + int ret; + + check_p(g_fpga_drv); + check_p(g_fpga_drv->set_main_board_fpga_test_reg); + + fpga_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_fpga_drv->set_main_board_fpga_test_reg(fpga_index, value); + if (ret < 0) { + FPGA_ERR("set fpga%u test reg failed, value:0x%x, ret: %d.\n", fpga_index, value, ret); + return -EIO; + } + FPGA_DBG("set fpga%u test reg success, value: 0x%x.\n", fpga_index, value); + return count; +} + +/************************************fpga dir and attrs*******************************************/ +static struct switch_attribute fpga_number_att = __ATTR(number, S_IRUGO, fpga_number_show, NULL); + +static struct attribute *fpga_dir_attrs[] = { + &fpga_number_att.attr, + NULL, +}; + +static struct attribute_group fpga_root_attr_group = { + .attrs = fpga_dir_attrs, +}; + +/*******************************fpga[1-n] dir and attrs*******************************************/ +static struct switch_attribute fpga_alias_attr = __ATTR(alias, S_IRUGO, fpga_alias_show, NULL); +static struct switch_attribute fpga_type_attr = __ATTR(type, S_IRUGO, fpga_type_show, NULL); +static struct switch_attribute fpga_fw_version_attr = __ATTR(firmware_version, S_IRUGO, fpga_fw_version_show, NULL); +static struct switch_attribute fpga_board_version_attr = __ATTR(board_version, S_IRUGO, fpga_board_version_show, NULL); +static struct switch_attribute fpga_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, fpga_test_reg_show, fpga_test_reg_store); + +static struct attribute *fpga_attrs[] = { + &fpga_alias_attr.attr, + &fpga_type_attr.attr, + &fpga_fw_version_attr.attr, + &fpga_board_version_attr.attr, + &fpga_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group fpga_attr_group = { + .attrs = fpga_attrs, +}; + +static int fpga_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct fpga_obj_s *curr_fpga; + + curr_fpga = &g_fpga.fpga[index - 1]; + if (curr_fpga->obj) { + sysfs_remove_group(&curr_fpga->obj->kobj, &fpga_attr_group); + switch_kobject_delete(&curr_fpga->obj); + FPGA_DBG("delete fpga%u dir and attrs success.\n", index); + } + return 0; +} + +static int fpga_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[8]; + struct fpga_obj_s *curr_fpga; + + curr_fpga = &g_fpga.fpga[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fpga%u", index); + curr_fpga->obj = switch_kobject_create(name, parent); + if (!curr_fpga->obj) { + FPGA_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_fpga->obj->index = index; + if (sysfs_create_group(&curr_fpga->obj->kobj, &fpga_attr_group) != 0) { + FPGA_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_fpga->obj); + return -EBADRQC; + } + FPGA_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int fpga_sub_create_kobj_and_attrs(struct kobject *parent, int fpga_num) +{ + unsigned int fpga_index, i; + + g_fpga.fpga = kzalloc(sizeof(struct fpga_obj_s) * fpga_num, GFP_KERNEL); + if (!g_fpga.fpga) { + FPGA_ERR("kzalloc g_fpga.fpga error, fpga number = %d.\n", fpga_num); + return -ENOMEM; + } + + for(fpga_index = 1; fpga_index <= fpga_num; fpga_index++) { + if(fpga_sub_single_create_kobj_and_attrs(parent, fpga_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = fpga_index; i > 0; i--) { + fpga_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_fpga.fpga); + g_fpga.fpga = NULL; + return -EBADRQC; +} + +/* create fpga[1-n] directory and attributes*/ +static int fpga_sub_create(void) +{ + int ret; + + ret = fpga_sub_create_kobj_and_attrs(&g_fpga_obj->kobj, g_fpga.fpga_number); + return ret; +} + +/* delete fpga[1-n] directory and attributes*/ +static void fpga_sub_remove(void) +{ + unsigned int fpga_index; + + if (g_fpga.fpga) { + for (fpga_index = g_fpga.fpga_number; fpga_index > 0; fpga_index--) { + fpga_sub_single_remove_kobj_and_attrs(fpga_index); + } + kfree(g_fpga.fpga); + g_fpga.fpga = NULL; + } + g_fpga.fpga_number = 0; + return; +} + +/* create fpga directory and number attributes */ +static int fpga_root_create(void) +{ + g_fpga_obj = switch_kobject_create("fpga", NULL); + if (!g_fpga_obj) { + FPGA_ERR("switch_kobject_create fpga error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_fpga_obj->kobj, &fpga_root_attr_group) != 0) { + switch_kobject_delete(&g_fpga_obj); + FPGA_ERR("create fpga dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete fpga directory and number attributes */ +static void fpga_root_remove(void) +{ + if (g_fpga_obj) { + sysfs_remove_group(&g_fpga_obj->kobj, &fpga_root_attr_group); + switch_kobject_delete(&g_fpga_obj); + } + + return; +} + +int s3ip_sysfs_fpga_drivers_register(struct s3ip_sysfs_fpga_drivers_s *drv) +{ + int ret, fpga_num; + + FPGA_INFO("s3ip_sysfs_fpga_drivers_register...\n"); + if (g_fpga_drv) { + FPGA_ERR("g_fpga_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_fpga_number); + g_fpga_drv = drv; + + fpga_num = g_fpga_drv->get_main_board_fpga_number(); + if (fpga_num <= 0) { + FPGA_ERR("fpga number: %d, don't need to create fpga dirs and attrs.\n", fpga_num); + g_fpga_drv = NULL; + return -EINVAL; + } + + memset(&g_fpga, 0, sizeof(struct fpga_s)); + g_fpga.fpga_number = fpga_num; + ret = fpga_root_create(); + if (ret < 0) { + FPGA_ERR("create fpga root dir and attrs failed, ret: %d\n", ret); + g_fpga_drv = NULL; + return ret; + } + ret = fpga_sub_create(); + if (ret < 0) { + FPGA_ERR("create fpga sub dir and attrs failed, ret: %d\n", ret); + fpga_root_remove(); + g_fpga_drv = NULL; + return ret; + } + FPGA_INFO("s3ip_sysfs_fpga_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_fpga_drivers_unregister(void) +{ + if (g_fpga_drv) { + fpga_sub_remove(); + fpga_root_remove(); + g_fpga_drv = NULL; + FPGA_DBG("s3ip_sysfs_fpga_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_fpga_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_fpga_drivers_unregister); +module_param(g_fpga_loglevel, int, 0644); +MODULE_PARM_DESC(g_fpga_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/cpld_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/cpld_sysfs.h new file mode 100644 index 000000000000..3d47a422ae01 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/cpld_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _CPLD_SYSFS_H_ +#define _CPLD_SYSFS_H_ + +struct s3ip_sysfs_cpld_drivers_s { + int (*get_main_board_cpld_number)(void); + ssize_t (*get_main_board_cpld_alias)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_type)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_firmware_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_board_version)(unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_main_board_cpld_test_reg)(unsigned int cpld_index, char *buf, size_t count); + int (*set_main_board_cpld_test_reg)(unsigned int cpld_index, unsigned int value); +}; + +extern int s3ip_sysfs_cpld_drivers_register(struct s3ip_sysfs_cpld_drivers_s *drv); +extern void s3ip_sysfs_cpld_drivers_unregister(void); +#endif /*_CPLD_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/curr_sensor_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/curr_sensor_sysfs.h new file mode 100644 index 000000000000..7a0b85a0fc3c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/curr_sensor_sysfs.h @@ -0,0 +1,17 @@ +#ifndef _CURR_SENSOR_SYSFS_H_ +#define _CURR_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_curr_sensor_drivers_s { + int (*get_main_board_curr_number)(void); + ssize_t (*get_main_board_curr_alias)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_type)(unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_main_board_curr_max)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_max)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_min)(unsigned int curr_index, char *buf, size_t count); + int (*set_main_board_curr_min)(unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_main_board_curr_value)(unsigned int curr_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_curr_sensor_drivers_register(struct s3ip_sysfs_curr_sensor_drivers_s *drv); +extern void s3ip_sysfs_curr_sensor_drivers_unregister(void); +#endif /*_CURR_SENSOR_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fan_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fan_sysfs.h new file mode 100644 index 000000000000..fbd5ea82eca0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fan_sysfs.h @@ -0,0 +1,26 @@ +#ifndef _FAN_SYSFS_H_ +#define _FAN_SYSFS_H_ + +struct s3ip_sysfs_fan_drivers_s { + int (*get_fan_number)(void); + int (*get_fan_motor_number)(unsigned int fan_index); + ssize_t (*get_fan_model_name)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_serial_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_part_number)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_hardware_version)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_status)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_led_status)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_led_status)(unsigned int fan_index, int status); + ssize_t (*get_fan_direction)(unsigned int fan_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_tolerance)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_target)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_max)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_motor_speed_min)(unsigned int fan_index, unsigned int motor_index, char *buf, size_t count); + ssize_t (*get_fan_ratio)(unsigned int fan_index, char *buf, size_t count); + int (*set_fan_ratio)(unsigned int fan_index, int ratio); +}; + +extern int s3ip_sysfs_fan_drivers_register(struct s3ip_sysfs_fan_drivers_s *drv); +extern void s3ip_sysfs_fan_drivers_unregister(void); +#endif /*_FAN_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fpga_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fpga_sysfs.h new file mode 100644 index 000000000000..c8a6935e4638 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/fpga_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _FPGA_SYSFS_H_ +#define _FPGA_SYSFS_H_ + +struct s3ip_sysfs_fpga_drivers_s { + int (*get_main_board_fpga_number)(void); + ssize_t (*get_main_board_fpga_alias)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_type)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_firmware_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_board_version)(unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_main_board_fpga_test_reg)(unsigned int fpga_index, char *buf, size_t count); + int (*set_main_board_fpga_test_reg)(unsigned int fpga_index, unsigned int value); +}; + +extern int s3ip_sysfs_fpga_drivers_register(struct s3ip_sysfs_fpga_drivers_s *drv); +extern void s3ip_sysfs_fpga_drivers_unregister(void); +#endif /*_FPGA_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/psu_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/psu_sysfs.h new file mode 100644 index 000000000000..4f6d1aba3d92 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/psu_sysfs.h @@ -0,0 +1,38 @@ +#ifndef _PSU_SYSFS_H_ +#define _PSU_SYSFS_H_ + +struct s3ip_sysfs_psu_drivers_s { + int (*get_psu_number)(void); + int (*get_psu_temp_number)(unsigned int psu_index); + ssize_t (*get_psu_model_name)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_serial_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_part_number)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_hardware_version)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_type)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_curr)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_vol)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_max_power)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_present_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_in_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_out_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_speed)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_fan_ratio)(unsigned int psu_index, char *buf, size_t count); + int (*set_psu_fan_ratio)(unsigned int psu_index, int ratio); + ssize_t (*get_psu_fan_direction)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_led_status)(unsigned int psu_index, char *buf, size_t count); + ssize_t (*get_psu_temp_alias)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_type)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_max)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); + int (*set_psu_temp_min)(unsigned int psu_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_psu_temp_value)(unsigned int psu_index, unsigned int temp_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_psu_drivers_register(struct s3ip_sysfs_psu_drivers_s *drv); +extern void s3ip_sysfs_psu_drivers_unregister(void); +#endif /*_PSU_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/slot_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/slot_sysfs.h new file mode 100644 index 000000000000..058ee450598b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/slot_sysfs.h @@ -0,0 +1,57 @@ +#ifndef _SLOT_SYSFS_H_ +#define _SLOT_SYSFS_H_ + +struct s3ip_sysfs_slot_drivers_s { + int (*get_slot_number)(void); + int (*get_slot_temp_number)(unsigned int slot_index); + int (*get_slot_vol_number)(unsigned int slot_index); + int (*get_slot_curr_number)(unsigned int slot_index); + int (*get_slot_cpld_number)(unsigned int slot_index); + int (*get_slot_fpga_number)(unsigned int slot_index); + ssize_t (*get_slot_model_name)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_serial_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_part_number)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_hardware_version)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_status)(unsigned int slot_index, char *buf, size_t count); + ssize_t (*get_slot_led_status)(unsigned int slot_index, char *buf, size_t count); + int (*set_slot_led_status)(unsigned int slot_index, int status); + ssize_t (*get_slot_temp_alias)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_type)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_max)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + int (*set_slot_temp_min)(unsigned int slot_index, unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_slot_temp_value)(unsigned int slot_index, unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_slot_vol_alias)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_type)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_max)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + int (*set_slot_vol_min)(unsigned int slot_index, unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_slot_vol_range)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_nominal_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_vol_value)(unsigned int slot_index, unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_slot_curr_alias)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_type)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_max)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + int (*set_slot_curr_min)(unsigned int slot_index, unsigned int curr_index, const char *buf, size_t count); + ssize_t (*get_slot_curr_value)(unsigned int slot_index, unsigned int curr_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_alias)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_type)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_firmware_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_board_version)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + ssize_t (*get_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, char *buf, size_t count); + int (*set_slot_fpga_test_reg)(unsigned int slot_index, unsigned int fpga_index, unsigned int value); + ssize_t (*get_slot_cpld_alias)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_type)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_firmware_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_board_version)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + ssize_t (*get_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, char *buf, size_t count); + int (*set_slot_cpld_test_reg)(unsigned int slot_index, unsigned int cpld_index, unsigned int value); +}; + +extern int s3ip_sysfs_slot_drivers_register(struct s3ip_sysfs_slot_drivers_s *drv); +extern void s3ip_sysfs_slot_drivers_unregister(void); +#endif /*_SLOT_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/switch.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/switch.h new file mode 100644 index 000000000000..ea0b1a266b1f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/switch.h @@ -0,0 +1,68 @@ +#ifndef _SWITCH_H_ +#define _SWITCH_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define DIR_NAME_MAX_LEN (64) +#define SYSFS_DEV_ERROR "NA" + +enum LOG_LEVEL{ + INFO = 0x1, + ERR = 0x2, + DBG = 0x4, + ALL = 0xf +}; + +extern int g_switch_loglevel; + +#define check_pfun(p) do { \ + if (p == NULL) { \ + if (g_switch_loglevel & ERR) { \ + printk( KERN_ERR "%s, %s is NULL.\n", __FUNCTION__, #p); \ + } \ + return -ENOSYS; \ + } \ +} while(0) + +#define check_p(p) check_pfun(p) + +#define to_switch_obj(x) container_of(x, struct switch_obj, kobj) +#define to_switch_attr(x) container_of(x, struct switch_attribute, attr) +#define to_switch_device_attr(x) container_of(x, struct switch_device_attribute, switch_attr) + +#define SWITCH_ATTR(_name, _mode, _show, _store, _type) \ + { .switch_attr = __ATTR(_name, _mode, _show, _store), \ + .type = _type } + +#define SWITCH_DEVICE_ATTR(_name, _mode, _show, _store, _type) \ +struct switch_device_attribute switch_dev_attr_##_name \ + = SWITCH_ATTR(_name, _mode, _show, _store, _type) + +struct switch_obj { + struct kobject kobj; + unsigned int index; +}; + +/* a custom attribute that works just for a struct switch_obj. */ +struct switch_attribute { + struct attribute attr; + ssize_t (*show)(struct switch_obj *foo, struct switch_attribute *attr, char *buf); + ssize_t (*store)(struct switch_obj *foo, struct switch_attribute *attr, const char *buf, size_t count); +}; + +struct switch_device_attribute { + struct switch_attribute switch_attr; + int type; +}; + +struct switch_obj *switch_kobject_create(const char *name, struct kobject *parent); +void switch_kobject_delete(struct switch_obj **obj); + +#endif /* _SWITCH_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/syseeprom_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/syseeprom_sysfs.h new file mode 100644 index 000000000000..c6b2c5c3456f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/syseeprom_sysfs.h @@ -0,0 +1,12 @@ +#ifndef _SYSEEPROM_SYSFS_H_ +#define _SYSEEPROM_SYSFS_H_ + +struct s3ip_sysfs_syseeprom_drivers_s { + int (*get_syseeprom_size)(void); + ssize_t (*read_syseeprom_data)(char *buf, loff_t offset, size_t count); + ssize_t (*write_syseeprom_data)(char *buf, loff_t offset, size_t count); +}; + +extern int s3ip_sysfs_syseeprom_drivers_register(struct s3ip_sysfs_syseeprom_drivers_s *drv); +extern void s3ip_sysfs_syseeprom_drivers_unregister(void); +#endif /*_SYSEEPROM_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/sysled_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/sysled_sysfs.h new file mode 100644 index 000000000000..e4383a4eea27 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/sysled_sysfs.h @@ -0,0 +1,19 @@ +#ifndef _SYSLED_SYSFS_H_ +#define _SYSLED_SYSFS_H_ + +struct s3ip_sysfs_sysled_drivers_s { + ssize_t (*get_sys_led_status)(char *buf, size_t count); + int (*set_sys_led_status)(int status); + ssize_t (*get_bmc_led_status)(char *buf, size_t count); + int (*set_bmc_led_status)(int status); + ssize_t (*get_sys_fan_led_status)(char *buf, size_t count); + int (*set_sys_fan_led_status)(int status); + ssize_t (*get_sys_psu_led_status)(char *buf, size_t count); + int (*set_sys_psu_led_status)(int status); + ssize_t (*get_id_led_status)(char *buf, size_t count); + int (*set_id_led_status)(int status); +}; + +extern int s3ip_sysfs_sysled_drivers_register(struct s3ip_sysfs_sysled_drivers_s *drv); +extern void s3ip_sysfs_sysled_drivers_unregister(void); +#endif /*_SYSLED_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/temp_sensor_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/temp_sensor_sysfs.h new file mode 100644 index 000000000000..db03a96a0cba --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/temp_sensor_sysfs.h @@ -0,0 +1,17 @@ +#ifndef _TEMP_SENSOR_SYSFS_H_ +#define _TEMP_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_temp_sensor_drivers_s { + int (*get_main_board_temp_number)(void); + ssize_t (*get_main_board_temp_alias)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_type)(unsigned int temp_index, char *buf, size_t count); + ssize_t (*get_main_board_temp_max)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_max)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_min)(unsigned int temp_index, char *buf, size_t count); + int (*set_main_board_temp_min)(unsigned int temp_index, const char *buf, size_t count); + ssize_t (*get_main_board_temp_value)(unsigned int temp_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_temp_sensor_drivers_register(struct s3ip_sysfs_temp_sensor_drivers_s *drv); +extern void s3ip_sysfs_temp_sensor_drivers_unregister(void); +#endif /*_TEMP_SENSOR_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/transceiver_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/transceiver_sysfs.h new file mode 100644 index 000000000000..7e8634c1ef01 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/transceiver_sysfs.h @@ -0,0 +1,26 @@ +#ifndef _TRANSCEIVER_SYSFS_H_ +#define _TRANSCEIVER_SYSFS_H_ + +struct s3ip_sysfs_transceiver_drivers_s { + int (*get_eth_number)(void); + ssize_t (*get_transceiver_power_on_status)(char *buf, size_t count); + int (*set_transceiver_power_on_status)(int status); + ssize_t (*get_eth_power_on_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_power_on_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_tx_fault_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_tx_disable_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_tx_disable_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_present_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_rx_los_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_reset_status)(unsigned int eth_index, char *buf, size_t count); + int (*set_eth_reset_status)(unsigned int eth_index, int status); + ssize_t (*get_eth_low_power_mode_status)(unsigned int eth_index, char *buf, size_t count); + ssize_t (*get_eth_interrupt_status)(unsigned int eth_index, char *buf, size_t count); + int (*get_eth_eeprom_size)(unsigned int eth_index); + ssize_t (*read_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); + ssize_t (*write_eth_eeprom_data)(unsigned int eth_index, char *buf, loff_t offset, size_t count); +}; + +extern int s3ip_sysfs_sff_drivers_register(struct s3ip_sysfs_transceiver_drivers_s *drv); +extern void s3ip_sysfs_sff_drivers_unregister(void); +#endif /*_TRANSCEIVER_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/vol_sensor_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/vol_sensor_sysfs.h new file mode 100644 index 000000000000..b2d7d615c421 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/vol_sensor_sysfs.h @@ -0,0 +1,19 @@ +#ifndef _VOL_SENSOR_SYSFS_H_ +#define _VOL_SENSOR_SYSFS_H_ + +struct s3ip_sysfs_vol_sensor_drivers_s { + int (*get_main_board_vol_number)(void); + ssize_t (*get_main_board_vol_alias)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_type)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_max)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_max)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_min)(unsigned int vol_index, char *buf, size_t count); + int (*set_main_board_vol_min)(unsigned int vol_index, const char *buf, size_t count); + ssize_t (*get_main_board_vol_range)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_nominal_value)(unsigned int vol_index, char *buf, size_t count); + ssize_t (*get_main_board_vol_value)(unsigned int vol_index, char *buf, size_t count); +}; + +extern int s3ip_sysfs_vol_sensor_drivers_register(struct s3ip_sysfs_vol_sensor_drivers_s *drv); +extern void s3ip_sysfs_vol_sensor_drivers_unregister(void); +#endif /*_VOL_SENSOR_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/watchdog_sysfs.h b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/watchdog_sysfs.h new file mode 100644 index 000000000000..7e86e4c006d9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/include/watchdog_sysfs.h @@ -0,0 +1,16 @@ +#ifndef _WATCHDOG_SYSFS_H_ +#define _WATCHDOG_SYSFS_H_ + +struct s3ip_sysfs_watchdog_drivers_s { + ssize_t (*get_watchdog_identify)(char *buf, size_t count); + ssize_t (*get_watchdog_timeleft)(char *buf, size_t count); + ssize_t (*get_watchdog_timeout)(char *buf, size_t count); + int (*set_watchdog_timeout)(int value); + ssize_t (*get_watchdog_enable_status)(char *buf, size_t count); + int (*set_watchdog_enable_status)(int value); + int (*set_watchdog_reset)(int value); +}; + +extern int s3ip_sysfs_watchdog_drivers_register(struct s3ip_sysfs_watchdog_drivers_s *drv); +extern void s3ip_sysfs_watchdog_drivers_unregister(void); +#endif /*_WATCHDOG_SYSFS_H_ */ diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/psu_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/psu_sysfs.c new file mode 100644 index 000000000000..50005f875345 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/psu_sysfs.c @@ -0,0 +1,990 @@ +/* + * psu_sysfs.c + * + * This module create psu kobjects and attributes in /sys/s3ip/psu + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "psu_sysfs.h" + +static int g_psu_loglevel = 0; + +#define PSU_INFO(fmt, args...) do { \ + if (g_psu_loglevel & INFO) { \ + printk(KERN_INFO "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define PSU_ERR(fmt, args...) do { \ + if (g_psu_loglevel & ERR) { \ + printk(KERN_ERR "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define PSU_DBG(fmt, args...) do { \ + if (g_psu_loglevel & DBG) { \ + printk(KERN_DEBUG "[PSU_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct temp_obj_s { + struct switch_obj *obj; +}; + +struct psu_obj_s { + unsigned int temp_number; + struct temp_obj_s *temp; + struct switch_obj *obj; +}; + +struct psu_s{ + unsigned int psu_number; + struct psu_obj_s *psu; +}; + +static struct psu_s g_psu; +static struct switch_obj *g_psu_obj = NULL; +static struct s3ip_sysfs_psu_drivers_s *g_psu_drv = NULL; + +static ssize_t psu_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%d\n", g_psu.psu_number); +} + +static ssize_t psu_temp_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int index; + + index = obj->index; + PSU_DBG("psu index: %u\n",index); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_psu.psu[index - 1].temp_number); +} + +static ssize_t psu_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_model_name); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_model_name(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u model name failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_hardware_version); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_hardware_version(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u hardware version failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_serial_number); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_serial_number(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u serial number failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_part_number); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_part_number(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u part number failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_type); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_type(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u type failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_curr_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_curr); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_curr(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input current failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_vol_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_vol); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_vol(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input voltage failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_curr_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_curr); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_curr(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u output current failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_vol_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_vol); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_vol(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u output voltage failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_max_power_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_max_power); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_max_power(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout max power failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_present_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_present_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_present_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u present status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_out_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_out_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_out_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u outout status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_in_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_in_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_in_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u input status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_fan_speed_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_speed); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_speed(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan speed failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +ssize_t psu_fan_ratio_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_ratio); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_ratio(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan ratio failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_fan_ratio_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index; + int ret, ratio; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_fan_ratio); + + psu_index = obj->index; + sscanf(buf, "%d", &ratio); + if (ratio < 0 || ratio > 100) { + PSU_ERR("param invalid, can not set ratio: %d.\n", ratio); + return -EINVAL; + } + PSU_DBG("psu index: %u, ratio: %d\n", psu_index, ratio); + ret = g_psu_drv->set_psu_fan_ratio(psu_index, ratio); + if (ret < 0) { + PSU_ERR("set psu%u ratio: %d failed, ret: %d\n", + psu_index, ratio, ret); + return -EIO; + } + PSU_DBG("set psu%u, ratio: %d success\n", psu_index, ratio); + return count; +} + +static ssize_t psu_fan_direction_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_fan_direction); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_fan_direction(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u fan direction failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index; + int ret; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_led_status); + + psu_index = obj->index; + PSU_DBG("psu index: %u\n", psu_index); + ret = g_psu_drv->get_psu_led_status(psu_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u led status failed, ret: %d\n", psu_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_value); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_value(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u value failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_alias(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u alias failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_type); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_type(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u type failed, ret: %d\n", psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_max(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u max threshold failed, ret: %d\n", + psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + ret = g_psu_drv->set_psu_temp_max(psu_index, temp_index, buf, count); + if (ret < 0) { + PSU_ERR("set psu%u temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return -EIO; + } + PSU_DBG("set psu%u temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return count; +} + +static ssize_t psu_temp_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->get_psu_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + + PSU_DBG("psu index: %u, temp index: %u\n", psu_index, temp_index); + ret = g_psu_drv->get_psu_temp_min(psu_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + PSU_ERR("get psu%u temp%u min threshold failed, ret: %d\n", + psu_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t psu_temp_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int psu_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_psu_drv); + check_p(g_psu_drv->set_psu_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + psu_index = p_obj->index; + temp_index = obj->index; + ret = g_psu_drv->set_psu_temp_min(psu_index, temp_index, buf, count); + if (ret < 0) { + PSU_ERR("set psu%u temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return -EIO; + } + PSU_DBG("set psu%u temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + psu_index, temp_index, buf, count, ret); + return count; +} + +/************************************psu dir and attrs*******************************************/ +static struct switch_attribute psu_number_att = __ATTR(number, S_IRUGO, psu_number_show, NULL); + +static struct attribute *psu_dir_attrs[] = { + &psu_number_att.attr, + NULL, +}; + +static struct attribute_group psu_root_attr_group = { + .attrs = psu_dir_attrs, +}; + +/*******************************psu[1-n] dir and attrs*******************************************/ +static struct switch_attribute psu_model_name_attr = __ATTR(model_name, S_IRUGO, psu_model_name_show, NULL); +static struct switch_attribute psu_hw_attr = __ATTR(hardware_version, S_IRUGO, psu_hw_show, NULL); +static struct switch_attribute psu_sn_attr = __ATTR(serial_number, S_IRUGO, psu_sn_show, NULL); +static struct switch_attribute psu_pn_attr = __ATTR(part_number, S_IRUGO, psu_pn_show, NULL); +static struct switch_attribute psu_type_attr = __ATTR(type, S_IRUGO, psu_type_show, NULL); +static struct switch_attribute psu_in_curr_attr = __ATTR(in_curr, S_IRUGO, psu_in_curr_show, NULL); +static struct switch_attribute psu_in_vol_attr = __ATTR(in_vol, S_IRUGO, psu_in_vol_show, NULL); +static struct switch_attribute psu_in_power_attr = __ATTR(in_power, S_IRUGO, psu_in_power_show, NULL); +static struct switch_attribute psu_out_curr_attr = __ATTR(out_curr, S_IRUGO, psu_out_curr_show, NULL); +static struct switch_attribute psu_out_vol_attr = __ATTR(out_vol, S_IRUGO, psu_out_vol_show, NULL); +static struct switch_attribute psu_out_power_attr = __ATTR(out_power, S_IRUGO, psu_out_power_show, NULL); +static struct switch_attribute psu_out_max_power_attr = __ATTR(out_max_power, S_IRUGO, psu_out_max_power_show, NULL); +static struct switch_attribute psu_num_temps_attr = __ATTR(num_temp_sensors, S_IRUGO, psu_temp_number_show, NULL); +static struct switch_attribute psu_present_attr = __ATTR(present, S_IRUGO, psu_present_status_show, NULL); +static struct switch_attribute psu_out_status_attr = __ATTR(out_status, S_IRUGO, psu_out_status_show, NULL); +static struct switch_attribute psu_in_status_attr = __ATTR(in_status, S_IRUGO, psu_in_status_show, NULL); +static struct switch_attribute psu_fan_speed_attr = __ATTR(fan_speed, S_IRUGO, psu_fan_speed_show, NULL); +static struct switch_attribute psu_fan_ratio_attr = __ATTR(fan_ratio, S_IRUGO | S_IWUSR, psu_fan_ratio_show, psu_fan_ratio_store); +static struct switch_attribute psu_fan_direction_attr = __ATTR(fan_direction, S_IRUGO, psu_fan_direction_show, NULL); +static struct switch_attribute psu_led_status_attr = __ATTR(led_status, S_IRUGO, psu_led_status_show, NULL); + +static struct attribute *psu_attrs[] = { + &psu_model_name_attr.attr, + &psu_hw_attr.attr, + &psu_sn_attr.attr, + &psu_pn_attr.attr, + &psu_type_attr.attr, + &psu_in_curr_attr.attr, + &psu_in_vol_attr.attr, + &psu_in_power_attr.attr, + &psu_out_curr_attr.attr, + &psu_out_vol_attr.attr, + &psu_out_power_attr.attr, + &psu_out_max_power_attr.attr, + &psu_num_temps_attr.attr, + &psu_present_attr.attr, + &psu_out_status_attr.attr, + &psu_in_status_attr.attr, + &psu_fan_speed_attr.attr, + &psu_fan_ratio_attr.attr, + &psu_fan_direction_attr.attr, + &psu_led_status_attr.attr, + NULL, +}; + +static struct attribute_group psu_attr_group = { + .attrs = psu_attrs, +}; + +/*******************************psu temp[1-n] dir and attrs*******************************************/ +static struct switch_attribute psu_temp_alias_attr = __ATTR(alias, S_IRUGO, psu_temp_alias_show, NULL); +static struct switch_attribute psu_temp_type_attr = __ATTR(type, S_IRUGO, psu_temp_type_show, NULL); +static struct switch_attribute psu_temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, psu_temp_max_show, psu_temp_max_store); +static struct switch_attribute psu_temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, psu_temp_min_show, psu_temp_min_store); +static struct switch_attribute psu_temp_value_attr = __ATTR(value, S_IRUGO, psu_temp_value_show, NULL); + +static struct attribute *psu_temp_attrs[] = { + &psu_temp_alias_attr.attr, + &psu_temp_type_attr.attr, + &psu_temp_max_attr.attr, + &psu_temp_min_attr.attr, + &psu_temp_value_attr.attr, + NULL, +}; + +static struct attribute_group psu_temp_attr_group = { + .attrs = psu_temp_attrs, +}; + +static void psuindex_single_temp_remove_kobj_and_attrs(struct psu_obj_s *curr_psu, unsigned int temp_index) +{ + struct temp_obj_s *curr_temp; /* point to temp1 temp2...*/ + + curr_temp = &curr_psu->temp[temp_index - 1]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &psu_temp_attr_group); + switch_kobject_delete(&curr_temp->obj); + PSU_DBG("delete psu%u temp%u dir and attrs success.\n", curr_psu->obj->index, temp_index); + } + return; +} + +static int psuindex_single_temp_create_kobj_and_attrs(struct psu_obj_s *curr_psu, unsigned int temp_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct temp_obj_s *curr_temp; /* point to temp1 temp2...*/ + + curr_temp = &curr_psu->temp[temp_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%u", temp_index); + curr_temp->obj = switch_kobject_create(name, &curr_psu->obj->kobj); + if (!curr_temp->obj) { + PSU_ERR("create psu%u, %s object error!\n", curr_psu->obj->index, name); + return -ENOMEM; + } + curr_temp->obj->index = temp_index; + if (sysfs_create_group(&curr_temp->obj->kobj, &psu_temp_attr_group) != 0) { + PSU_ERR("create psu%u, %s attrs error.\n", curr_psu->obj->index, name); + switch_kobject_delete(&curr_temp->obj); + return -EBADRQC; + } + PSU_DBG("create psu%u, %s success.\n", curr_psu->obj->index, name); + return 0; +} + +static int psuindex_temp_create_kobj_and_attrs(struct psu_obj_s *curr_psu) +{ + unsigned int temp_index, i, temp_num; + + temp_num = curr_psu->temp_number; + curr_psu->temp = kzalloc(sizeof(struct temp_obj_s) * temp_num, GFP_KERNEL); + if (!curr_psu->temp) { + PSU_ERR("kzalloc temp error, psu index: %u, temp number: %u.\n", + curr_psu->obj->index, temp_num); + return -ENOMEM; + } + for(temp_index = 1; temp_index <= temp_num; temp_index++) { + if(psuindex_single_temp_create_kobj_and_attrs(curr_psu, temp_index) != 0 ) { + goto temp_error; + } + } + return 0; +temp_error: + for(i = temp_index; i > 0; i--) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, i); + } + kfree(curr_psu->temp); + curr_psu->temp = NULL; + return -EBADRQC; +} + +static void psuindex_temp_remove_kobj_and_attrs(struct psu_obj_s *curr_psu) +{ + unsigned int temp_index, temp_num; + + if (curr_psu->temp) { + temp_num = curr_psu->temp_number; + for (temp_index = temp_num; temp_index > 0; temp_index--) { + psuindex_single_temp_remove_kobj_and_attrs(curr_psu, temp_index); + } + kfree(curr_psu->temp); + curr_psu->temp = NULL; + } + return; +} + +/* create psu temp[1-n] directory and attributes*/ +static int psu_temp_create(void) +{ + int psu_num, temp_num; + unsigned int psu_index, i; + struct psu_obj_s *curr_psu; /* point to psu1 psu2...*/ + + psu_num = g_psu.psu_number; + if (psu_num <= 0) { + PSU_DBG("psu number: %d, skip to create temp* dirs and attrs.\n", psu_num); + return 0; + } + + check_p(g_psu_drv->get_psu_temp_number); + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + temp_num = g_psu_drv->get_psu_temp_number(psu_index); + if (temp_num <= 0) { + PSU_DBG("psu%u temp number: %d, don't need to create temp* dirs and attrs.\n", + psu_index, temp_num); + continue; + } + curr_psu = &g_psu.psu[psu_index - 1]; + curr_psu->temp_number = temp_num; + if(psuindex_temp_create_kobj_and_attrs(curr_psu) != 0) { + goto error; + } + } + return 0; +error: + for(i = psu_index; i > 0; i--) { + curr_psu = &g_psu.psu[i - 1]; + psuindex_temp_remove_kobj_and_attrs(curr_psu); + } + return -EBADRQC; +} + +/* delete psu temp[1-n] directory and attributes*/ +static void psu_temp_remove(void) +{ + unsigned int psu_index; + struct psu_obj_s *curr_psu; + + if (g_psu.psu) { + for(psu_index = g_psu.psu_number; psu_index > 0; psu_index--) { + curr_psu = &g_psu.psu[psu_index - 1]; + psuindex_temp_remove_kobj_and_attrs(curr_psu); + curr_psu->temp_number = 0; + } + } + return; +} + +static int psu_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct psu_obj_s *curr_psu; + + curr_psu = &g_psu.psu[index - 1]; + if (curr_psu->obj) { + sysfs_remove_group(&curr_psu->obj->kobj, &psu_attr_group); + switch_kobject_delete(&curr_psu->obj); + PSU_DBG("delete psu%u dir and attrs success.\n", index); + } + return 0; +} + +static int psu_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct psu_obj_s *curr_psu; + + curr_psu = &g_psu.psu[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "psu%u", index); + curr_psu->obj = switch_kobject_create(name, parent); + if (!curr_psu->obj) { + PSU_ERR("create %s object error!\n", name); + return -ENOMEM; + } + curr_psu->obj->index = index; + if (sysfs_create_group(&curr_psu->obj->kobj, &psu_attr_group) != 0) { + PSU_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_psu->obj); + return -EBADRQC; + } + PSU_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int psu_sub_create_kobj_and_attrs(struct kobject *parent, int psu_num) +{ + unsigned int psu_index, i; + + g_psu.psu = kzalloc(sizeof(struct psu_obj_s) * psu_num, GFP_KERNEL); + if (!g_psu.psu) { + PSU_ERR("kzalloc psu.psu error, psu number = %d.\n", psu_num); + return -ENOMEM; + } + + for(psu_index = 1; psu_index <= psu_num; psu_index++) { + if(psu_sub_single_create_kobj_and_attrs(parent, psu_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = psu_index; i > 0; i--) { + psu_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_psu.psu); + g_psu.psu = NULL; + return -EBADRQC; +} + +/* create psu[1-n] directory and attributes*/ +static int psu_sub_create(void) +{ + int ret; + + ret = psu_sub_create_kobj_and_attrs(&g_psu_obj->kobj, g_psu.psu_number); + return ret; +} + +/* delete psu[1-n] directory and attributes*/ +static void psu_sub_remove(void) +{ + unsigned int psu_index; + + if (g_psu.psu) { + for (psu_index = g_psu.psu_number; psu_index > 0; psu_index--) { + psu_sub_single_remove_kobj_and_attrs(psu_index); + } + kfree(g_psu.psu); + g_psu.psu = NULL; + } + g_psu.psu_number = 0; + return; +} + +/* create psu directory and number attributes*/ +static int psu_root_create(void) +{ + g_psu_obj = switch_kobject_create("psu", NULL); + if (!g_psu_obj) { + PSU_ERR("switch_kobject_create psu error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_psu_obj->kobj, &psu_root_attr_group) != 0) { + switch_kobject_delete(&g_psu_obj); + PSU_ERR("create psu dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete psu directory and number attributes*/ +static void psu_root_remove(void) +{ + if (g_psu_obj) { + sysfs_remove_group(&g_psu_obj->kobj, &psu_root_attr_group); + switch_kobject_delete(&g_psu_obj); + PSU_DBG("delete psu dir and attrs success.\n"); + } + return; +} + +int s3ip_sysfs_psu_drivers_register(struct s3ip_sysfs_psu_drivers_s *drv) +{ + int ret, psu_num; + + PSU_INFO("s3ip_sysfs_psu_drivers_register...\n"); + if (g_psu_drv) { + PSU_ERR("g_psu_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_psu_number); + g_psu_drv = drv; + + psu_num = g_psu_drv->get_psu_number(); + if (psu_num <= 0) { + PSU_ERR("psu number: %d, don't need to create psu dirs and attrs.\n", psu_num); + g_psu_drv = NULL; + return -EINVAL; + } + + memset(&g_psu, 0, sizeof(struct psu_s)); + g_psu.psu_number = psu_num; + ret = psu_root_create(); + if (ret < 0) { + PSU_ERR("create psu root dir and attrs failed, ret: %d\n", ret); + g_psu_drv = NULL; + return ret; + } + + ret = psu_sub_create(); + if (ret < 0) { + PSU_ERR("create psu sub dir and attrs failed, ret: %d\n", ret); + psu_root_remove(); + g_psu_drv = NULL; + return ret; + } + + ret = psu_temp_create(); + if (ret < 0) { + PSU_ERR("create psu temp dir and attrs failed, ret: %d\n", ret); + psu_sub_remove(); + psu_root_remove(); + g_psu_drv = NULL; + return ret; + } + PSU_INFO("s3ip_sysfs_psu_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_psu_drivers_unregister(void) +{ + if (g_psu_drv) { + psu_temp_remove(); + psu_sub_remove(); + psu_root_remove(); + g_psu_drv = NULL; + PSU_DBG("s3ip_sysfs_psu_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_psu_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_psu_drivers_unregister); +module_param(g_psu_loglevel, int, 0644); +MODULE_PARM_DESC(g_psu_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/slot_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/slot_sysfs.c new file mode 100644 index 000000000000..b0186ac6ad29 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/slot_sysfs.c @@ -0,0 +1,2099 @@ +/* + * slot_sysfs.c + * + * This module create slot kobjects and attributes in /sys/s3ip/slot + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "slot_sysfs.h" + +static int g_slot_loglevel = 0; + +#define SLOT_INFO(fmt, args...) do { \ + if (g_slot_loglevel & INFO) { \ + printk(KERN_INFO "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SLOT_ERR(fmt, args...) do { \ + if (g_slot_loglevel & ERR) { \ + printk(KERN_ERR "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SLOT_DBG(fmt, args...) do { \ + if (g_slot_loglevel & DBG) { \ + printk(KERN_DEBUG "[SLOT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct slot_temp_obj_s { + struct switch_obj *obj; +}; + +struct slot_vol_obj_s { + struct switch_obj *obj; +}; + +struct slot_curr_obj_s { + struct switch_obj *obj; +}; + +struct slot_fpga_obj_s { + struct switch_obj *obj; +}; + +struct slot_cpld_obj_s { + struct switch_obj *obj; +}; + +struct slot_obj_s { + unsigned int temp_number; + unsigned int vol_number; + unsigned int curr_number; + unsigned int fpga_number; + unsigned int cpld_number; + struct slot_temp_obj_s *temp; + struct slot_vol_obj_s *vol; + struct slot_curr_obj_s *curr; + struct slot_fpga_obj_s *fpga; + struct slot_cpld_obj_s *cpld; + struct switch_obj *obj; +}; + +struct slot_s { + unsigned int slot_number; + struct slot_obj_s *slot; +}; + +static struct slot_s g_slot; +static struct switch_obj *g_slot_obj = NULL; +static struct s3ip_sysfs_slot_drivers_s *g_slot_drv = NULL; + +static ssize_t slot_number_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot_number); +} + +static ssize_t slot_temp_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].temp_number); +} + +static ssize_t slot_vol_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].vol_number); +} + +static ssize_t slot_curr_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].curr_number); +} + +static ssize_t slot_fpga_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].fpga_number); +} + +static ssize_t slot_cpld_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int index; + + index = obj->index; + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_slot.slot[index - 1].cpld_number); +} + +static ssize_t slot_model_name_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_model_name); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_model_name(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u model name failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_sn_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_serial_number); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_serial_number(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u serial number failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_pn_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_part_number); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_part_number(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u part number failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_hw_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_hardware_version); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_hardware_version(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u hardware version failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_status); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_status(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u status failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index; + int ret; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_led_status); + + slot_index = obj->index; + SLOT_DBG("slot index: %u\n", slot_index); + ret = g_slot_drv->get_slot_led_status(slot_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u led status failed, ret: %d\n", slot_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + unsigned int slot_index; + int ret, led_status; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_led_status); + + slot_index = obj->index; + sscanf(buf, "%d", &led_status); + SLOT_DBG("slot index: %u, led_status: %d\n", slot_index, led_status); + ret = g_slot_drv->set_slot_led_status(slot_index, led_status); + if (ret < 0) { + SLOT_ERR("set slot%u led_status: %d failed, ret: %d\n", slot_index, led_status, ret); + return -EIO; + } + SLOT_DBG("set slot%u led_status: %d success\n", slot_index, led_status); + return count; +} + +/*************************************slot temp*************************************************/ +static ssize_t slot_temp_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_value(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u value failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_alias(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u alias failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_type(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u type failed, ret: %d\n", slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_max(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u max threshold failed, ret: %d\n", + slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_temp_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + ret = g_slot_drv->set_slot_temp_max(slot_index, temp_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return count; +} + +static ssize_t slot_temp_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + + SLOT_DBG("slot index: %u, temp index: %u\n", slot_index, temp_index); + ret = g_slot_drv->get_slot_temp_min(slot_index, temp_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u temp%u min threshold failed, ret: %d\n", + slot_index, temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_temp_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, temp_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_temp_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + temp_index = obj->index; + ret = g_slot_drv->set_slot_temp_min(slot_index, temp_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, temp_index, buf, count, ret); + return count; +} +/**********************************end of slot temp**********************************************/ + +/*************************************slot vol*************************************************/ +static ssize_t slot_vol_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_value(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u value failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_alias(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u alias failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_type(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u type failed, ret: %d\n", slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_max(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u max threshold failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_vol_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + ret = g_slot_drv->set_slot_vol_max(slot_index, vol_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u vol%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u vol%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return count; +} + +static ssize_t slot_vol_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_min(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u min threshold failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_vol_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + ret = g_slot_drv->set_slot_vol_min(slot_index, vol_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u vol%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u vol%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, vol_index, buf, count, ret); + return count; +} + +static ssize_t slot_vol_range_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_range); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_range(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u voltage range failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_vol_nominal_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, vol_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_vol_nominal_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + vol_index = obj->index; + + SLOT_DBG("slot index: %u, vol index: %u\n", slot_index, vol_index); + ret = g_slot_drv->get_slot_vol_nominal_value(slot_index, vol_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u vol%u voltage nominal value failed, ret: %d\n", + slot_index, vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} +/**********************************end of slot vol**********************************************/ +/*************************************slot curr*************************************************/ +static ssize_t slot_curr_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_value); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_value(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u value failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_alias(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u alias failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_type(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u type failed, ret: %d\n", slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_max(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u max threshold failed, ret: %d\n", + slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_curr_max); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + ret = g_slot_drv->set_slot_curr_max(slot_index, curr_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u curr%u max threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u curr%u max threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return count; +} + +static ssize_t slot_curr_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_curr_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + + SLOT_DBG("slot index: %u, curr index: %u\n", slot_index, curr_index); + ret = g_slot_drv->get_slot_curr_min(slot_index, curr_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u curr%u min threshold failed, ret: %d\n", + slot_index, curr_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_curr_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, curr_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_curr_min); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + curr_index = obj->index; + ret = g_slot_drv->set_slot_curr_min(slot_index, curr_index, buf, count); + if (ret < 0) { + SLOT_ERR("set slot%u curr%u min threshold failed, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return -EIO; + } + SLOT_DBG("set slot%u curr%u min threshold success, value: %s, count: %lu, ret: %d\n", + slot_index, curr_index, buf, count, ret); + return count; +} +/**********************************end of slot curr**********************************************/ +/*************************************slot fpga*************************************************/ +static ssize_t slot_fpga_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_alias(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u alias failed, ret: %d\n", slot_index, fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_type(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u type failed, ret: %d\n", slot_index, fpga_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_firmware_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_firmware_version(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u firmware version failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_board_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_board_version(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u board version failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, fpga_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_fpga_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + + SLOT_DBG("slot index: %u, fpga index: %u\n", slot_index, fpga_index); + ret = g_slot_drv->get_slot_fpga_test_reg(slot_index, fpga_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u fpga%u test register failed, ret: %d\n", slot_index, fpga_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_fpga_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, fpga_index, value; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_fpga_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + fpga_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_slot_drv->set_slot_fpga_test_reg(slot_index, fpga_index, value); + if (ret < 0) { + SLOT_ERR("set slot%u fpga%u test reg failed, value:0x%x, ret: %d.\n", + slot_index, fpga_index, value, ret); + return -EIO; + } + SLOT_DBG("set slot%u fpga%u test reg success, value: 0x%x.\n", slot_index, fpga_index, value); + return count; +} +/**********************************end of slot fpga**********************************************/ +/*************************************slot cpld*************************************************/ +static ssize_t slot_cpld_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_alias); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_alias(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u alias failed, ret: %d\n", slot_index, cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_type); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_type(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u type failed, ret: %d\n", slot_index, cpld_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_fw_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_firmware_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_firmware_version(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u firmware version failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_board_version_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_board_version); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_board_version(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u board version failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_test_reg_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int slot_index, cpld_index; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->get_slot_cpld_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + + SLOT_DBG("slot index: %u, cpld index: %u\n", slot_index, cpld_index); + ret = g_slot_drv->get_slot_cpld_test_reg(slot_index, cpld_index, buf, PAGE_SIZE); + if (ret < 0) { + SLOT_ERR("get slot%u cpld%u test register failed, ret: %d\n", slot_index, cpld_index, + ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t slot_cpld_test_reg_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int slot_index, cpld_index, value; + int ret; + struct switch_obj *p_obj; + + check_p(g_slot_drv); + check_p(g_slot_drv->set_slot_cpld_test_reg); + + p_obj = to_switch_obj(obj->kobj.parent); + slot_index = p_obj->index; + cpld_index = obj->index; + sscanf(buf, "0x%x", &value); + ret = g_slot_drv->set_slot_cpld_test_reg(slot_index, cpld_index, value); + if (ret < 0) { + SLOT_ERR("set slot%u cpld%u test reg failed, value:0x%x, ret: %d.\n", + slot_index, cpld_index, value, ret); + return -EIO; + } + SLOT_DBG("set slot%u cpld%u test reg success, value: 0x%x.\n", slot_index, cpld_index, value); + return count; +} +/**********************************end of slot cpld**********************************************/ +/**********************************slot dir and attrs********************************************/ +static struct switch_attribute slot_number_attr = __ATTR(number, S_IRUGO, slot_number_show, NULL); + +static struct attribute *slot_dir_attrs[] = { + &slot_number_attr.attr, + NULL, +}; + +static struct attribute_group slot_root_attr_group = { + .attrs = slot_dir_attrs, +}; + +/*******************************slot[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_model_name_attr = __ATTR(model_name, S_IRUGO, slot_model_name_show, NULL); +static struct switch_attribute slot_hw_attr = __ATTR(hardware_version, S_IRUGO, slot_hw_show, NULL); +static struct switch_attribute slot_sn_attr = __ATTR(serial_number, S_IRUGO, slot_sn_show, NULL); +static struct switch_attribute slot_pn_attr = __ATTR(part_number, S_IRUGO, slot_pn_show, NULL); +static struct switch_attribute slot_status_attr = __ATTR(status, S_IRUGO, slot_status_show, NULL); +static struct switch_attribute slot_led_status_attr = __ATTR(led_status, S_IRUGO | S_IWUSR, slot_led_status_show, slot_led_status_store); +static struct switch_attribute num_temp_sensors_attr = __ATTR(num_temp_sensors, S_IRUGO, slot_temp_number_show, NULL); +static struct switch_attribute num_vol_sensors_attr = __ATTR(num_vol_sensors, S_IRUGO, slot_vol_number_show, NULL); +static struct switch_attribute num_curr_sensors_attr = __ATTR(num_curr_sensors, S_IRUGO, slot_curr_number_show, NULL); +static struct switch_attribute num_fpga_attr = __ATTR(num_fpgas, S_IRUGO, slot_fpga_number_show, NULL); +static struct switch_attribute num_cpld_attr = __ATTR(num_cplds, S_IRUGO, slot_cpld_number_show, NULL); + +static struct attribute *slot_attrs[] = { + &slot_model_name_attr.attr, + &slot_hw_attr.attr, + &slot_sn_attr.attr, + &slot_pn_attr.attr, + &slot_status_attr.attr, + &slot_led_status_attr.attr, + &num_temp_sensors_attr.attr, + &num_vol_sensors_attr.attr, + &num_curr_sensors_attr.attr, + &num_fpga_attr.attr, + &num_cpld_attr.attr, + NULL, +}; + +static struct attribute_group slot_attr_group = { + .attrs = slot_attrs, +}; + +/*******************************slot temp[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_temp_alias_attr = __ATTR(alias, S_IRUGO, slot_temp_alias_show, NULL); +static struct switch_attribute slot_temp_type_attr = __ATTR(type, S_IRUGO, slot_temp_type_show, NULL); +static struct switch_attribute slot_temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_temp_max_show, slot_temp_max_store); +static struct switch_attribute slot_temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_temp_min_show, slot_temp_min_store); +static struct switch_attribute slot_temp_value_attr = __ATTR(value, S_IRUGO, slot_temp_value_show, NULL); + +static struct attribute *slot_temp_attrs[] = { + &slot_temp_alias_attr.attr, + &slot_temp_type_attr.attr, + &slot_temp_max_attr.attr, + &slot_temp_min_attr.attr, + &slot_temp_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_temp_attr_group = { + .attrs = slot_temp_attrs, +}; + +/*******************************slot vol[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_vol_alias_attr = __ATTR(alias, S_IRUGO, slot_vol_alias_show, NULL); +static struct switch_attribute slot_vol_type_attr = __ATTR(type, S_IRUGO, slot_vol_type_show, NULL); +static struct switch_attribute slot_vol_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_vol_max_show, slot_vol_max_store); +static struct switch_attribute slot_vol_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_vol_min_show, slot_vol_min_store); +static struct switch_attribute slot_vol_value_attr = __ATTR(value, S_IRUGO, slot_vol_value_show, NULL); +static struct switch_attribute slot_vol_range_attr = __ATTR(range, S_IRUGO, slot_vol_range_show, NULL); +static struct switch_attribute slot_vol_nominal_value_attr = __ATTR(nominal_value, S_IRUGO, slot_vol_nominal_value_show, NULL); + +static struct attribute *slot_vol_attrs[] = { + &slot_vol_alias_attr.attr, + &slot_vol_type_attr.attr, + &slot_vol_max_attr.attr, + &slot_vol_min_attr.attr, + &slot_vol_value_attr.attr, + &slot_vol_range_attr.attr, + &slot_vol_nominal_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_vol_attr_group = { + .attrs = slot_vol_attrs, +}; + +/*******************************slot curr[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_curr_alias_attr = __ATTR(alias, S_IRUGO, slot_curr_alias_show, NULL); +static struct switch_attribute slot_curr_type_attr = __ATTR(type, S_IRUGO, slot_curr_type_show, NULL); +static struct switch_attribute slot_curr_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, slot_curr_max_show, slot_curr_max_store); +static struct switch_attribute slot_curr_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, slot_curr_min_show, slot_curr_min_store); +static struct switch_attribute slot_curr_value_attr = __ATTR(value, S_IRUGO, slot_curr_value_show, NULL); + +static struct attribute *slot_curr_attrs[] = { + &slot_curr_alias_attr.attr, + &slot_curr_type_attr.attr, + &slot_curr_max_attr.attr, + &slot_curr_min_attr.attr, + &slot_curr_value_attr.attr, + NULL, +}; + +static struct attribute_group slot_curr_attr_group = { + .attrs = slot_curr_attrs, +}; + +/*******************************slot fpga[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_fpga_alias_attr = __ATTR(alias, S_IRUGO, slot_fpga_alias_show, NULL); +static struct switch_attribute slot_fpga_type_attr = __ATTR(type, S_IRUGO, slot_fpga_type_show, NULL); +static struct switch_attribute slot_fpga_fw_version_attr = __ATTR(firmware_version, S_IRUGO, slot_fpga_fw_version_show, NULL); +static struct switch_attribute slot_fpga_board_version_attr = __ATTR(board_version, S_IRUGO, slot_fpga_board_version_show, NULL); +static struct switch_attribute slot_fpga_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, slot_fpga_test_reg_show, slot_fpga_test_reg_store); + +static struct attribute *slot_fpga_attrs[] = { + &slot_fpga_alias_attr.attr, + &slot_fpga_type_attr.attr, + &slot_fpga_fw_version_attr.attr, + &slot_fpga_board_version_attr.attr, + &slot_fpga_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group slot_fpga_attr_group = { + .attrs = slot_fpga_attrs, +}; + +/*******************************slot cpld[1-n] dir and attrs*******************************************/ +static struct switch_attribute slot_cpld_alias_attr = __ATTR(alias, S_IRUGO, slot_cpld_alias_show, NULL); +static struct switch_attribute slot_cpld_type_attr = __ATTR(type, S_IRUGO, slot_cpld_type_show, NULL); +static struct switch_attribute slot_cpld_fw_version_attr = __ATTR(firmware_version, S_IRUGO, slot_cpld_fw_version_show, NULL); +static struct switch_attribute slot_cpld_board_version_attr = __ATTR(board_version, S_IRUGO, slot_cpld_board_version_show, NULL); +static struct switch_attribute slot_cpld_test_reg_attr = __ATTR(reg_test, S_IRUGO | S_IWUSR, slot_cpld_test_reg_show, slot_cpld_test_reg_store); + +static struct attribute *slot_cpld_attrs[] = { + &slot_cpld_alias_attr.attr, + &slot_cpld_type_attr.attr, + &slot_cpld_fw_version_attr.attr, + &slot_cpld_board_version_attr.attr, + &slot_cpld_test_reg_attr.attr, + NULL, +}; + +static struct attribute_group slot_cpld_attr_group = { + .attrs = slot_cpld_attrs, +}; + +/***************************************slot cpld*****************************************/ +static void slotindex_single_cpld_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int cpld_index) +{ + struct slot_cpld_obj_s *curr_cpld; + + curr_cpld = &curr_slot->cpld[cpld_index - 1]; + if (curr_cpld->obj) { + sysfs_remove_group(&curr_cpld->obj->kobj, &slot_cpld_attr_group); + switch_kobject_delete(&curr_cpld->obj); + SLOT_DBG("delete slot%u cpld%u dir and attrs success.\n", curr_slot->obj->index, + cpld_index); + } + return; +} + +static int slotindex_single_cpld_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int cpld_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_cpld_obj_s *curr_cpld; + + curr_cpld = &curr_slot->cpld[cpld_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "cpld%u", cpld_index); + curr_cpld->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_cpld->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_cpld->obj->index = cpld_index; + if (sysfs_create_group(&curr_cpld->obj->kobj, &slot_cpld_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_cpld->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_cpld_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int cpld_index, cpld_num; + + if (curr_slot->cpld) { + cpld_num = curr_slot->cpld_number; + for (cpld_index = cpld_num; cpld_index > 0; cpld_index--) { + slotindex_single_cpld_remove_kobj_and_attrs(curr_slot, cpld_index); + } + kfree(curr_slot->cpld); + curr_slot->cpld = NULL; + } + return; +} + +static int slotindex_cpld_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int cpld_index, i, cpld_num; + + cpld_num = curr_slot->cpld_number; + curr_slot->cpld = kzalloc(sizeof(struct slot_cpld_obj_s) * cpld_num, GFP_KERNEL); + if (!curr_slot->cpld) { + SLOT_ERR("kzalloc slot cpld error, slot index: %u, cpld number: %u.\n", + curr_slot->obj->index, cpld_num); + return -ENOMEM; + } + + for (cpld_index = 1; cpld_index <= cpld_num; cpld_index++) { + if (slotindex_single_cpld_create_kobj_and_attrs(curr_slot, cpld_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = cpld_index; i > 0; i--) { + slotindex_single_cpld_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->cpld); + curr_slot->cpld = NULL; + return -EBADRQC; +} + +/* create slot cpld[1-n] directory and attributes*/ +static int slot_cpld_create(void) +{ + int cpld_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_cpld_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + cpld_num = g_slot_drv->get_slot_cpld_number(slot_index); + if (cpld_num <= 0) { + SLOT_DBG("slot%u cpld number: %d, don't need to create cpld* dirs and attrs.\n", + slot_index, cpld_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->cpld_number = cpld_num; + if (slotindex_cpld_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_cpld_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot cpld[1-n] directory and attributes*/ +static void slot_cpld_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_cpld_remove_kobj_and_attrs(curr_slot); + curr_slot->cpld_number = 0; + } + } + return; +} +/************************************end of slot cpld**************************************/ +/***************************************slot fpga*****************************************/ +static void slotindex_single_fpga_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int fpga_index) +{ + struct slot_fpga_obj_s *curr_fpga; + + curr_fpga = &curr_slot->fpga[fpga_index - 1]; + if (curr_fpga->obj) { + sysfs_remove_group(&curr_fpga->obj->kobj, &slot_fpga_attr_group); + switch_kobject_delete(&curr_fpga->obj); + SLOT_DBG("delete slot%u fpga%u dir and attrs success.\n", curr_slot->obj->index, + fpga_index); + } + return; +} + +static int slotindex_single_fpga_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int fpga_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_fpga_obj_s *curr_fpga; + + curr_fpga = &curr_slot->fpga[fpga_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "fpga%u", fpga_index); + curr_fpga->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_fpga->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_fpga->obj->index = fpga_index; + if (sysfs_create_group(&curr_fpga->obj->kobj, &slot_fpga_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_fpga->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_fpga_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int fpga_index, fpga_num; + + if (curr_slot->fpga) { + fpga_num = curr_slot->fpga_number; + for (fpga_index = fpga_num; fpga_index > 0; fpga_index--) { + slotindex_single_fpga_remove_kobj_and_attrs(curr_slot, fpga_index); + } + kfree(curr_slot->fpga); + curr_slot->fpga = NULL; + } + return; +} + +static int slotindex_fpga_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int fpga_index, i, fpga_num; + + fpga_num = curr_slot->fpga_number; + curr_slot->fpga = kzalloc(sizeof(struct slot_fpga_obj_s) * fpga_num, GFP_KERNEL); + if (!curr_slot->fpga) { + SLOT_ERR("kzalloc slot fpga error, slot index: %u, fpga number: %u.\n", + curr_slot->obj->index, fpga_num); + return -ENOMEM; + } + + for (fpga_index = 1; fpga_index <= fpga_num; fpga_index++) { + if (slotindex_single_fpga_create_kobj_and_attrs(curr_slot, fpga_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = fpga_index; i > 0; i--) { + slotindex_single_fpga_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->fpga); + curr_slot->fpga = NULL; + return -EBADRQC; +} + +/* create slot fpga[1-n] directory and attributes*/ +static int slot_fpga_create(void) +{ + int fpga_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_fpga_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + fpga_num = g_slot_drv->get_slot_fpga_number(slot_index); + if (fpga_num <= 0) { + SLOT_DBG("slot%u fpga number: %d, don't need to create fpga* dirs and attrs.\n", + slot_index, fpga_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->fpga_number = fpga_num; + if (slotindex_fpga_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_fpga_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot fpga[1-n] directory and attributes*/ +static void slot_fpga_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_fpga_remove_kobj_and_attrs(curr_slot); + curr_slot->fpga_number = 0; + } + } + return; +} +/************************************end of slot fpga**************************************/ +/*************************************slot current*****************************************/ +static void slotindex_single_curr_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int curr_index) +{ + struct slot_curr_obj_s *curr; + + curr = &curr_slot->curr[curr_index - 1]; + if (curr->obj) { + sysfs_remove_group(&curr->obj->kobj, &slot_curr_attr_group); + switch_kobject_delete(&curr->obj); + SLOT_DBG("delete slot%u curr_sensor%u dir and attrs success.\n", curr_slot->obj->index, + curr_index); + } + return; +} + +static int slotindex_single_curr_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int curr_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_curr_obj_s *curr; + + curr = &curr_slot->curr[curr_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "curr_sensor%u", curr_index); + curr->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr->obj->index = curr_index; + if (sysfs_create_group(&curr->obj->kobj, &slot_curr_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_curr_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int curr_index, curr_num; + + if (curr_slot->curr) { + curr_num = curr_slot->curr_number; + for (curr_index = curr_num; curr_index > 0; curr_index--) { + slotindex_single_curr_remove_kobj_and_attrs(curr_slot, curr_index); + } + kfree(curr_slot->curr); + curr_slot->curr = NULL; + } + return; +} + +static int slotindex_curr_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int curr_index, i, curr_num; + + curr_num = curr_slot->curr_number; + curr_slot->curr = kzalloc(sizeof(struct slot_curr_obj_s) * curr_num, GFP_KERNEL); + if (!curr_slot->curr) { + SLOT_ERR("kzalloc slot curr error, slot index: %u, curr number: %u.\n", + curr_slot->obj->index, curr_num); + return -ENOMEM; + } + + for (curr_index = 1; curr_index <= curr_num; curr_index++) { + if (slotindex_single_curr_create_kobj_and_attrs(curr_slot, curr_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = curr_index; i > 0; i--) { + slotindex_single_curr_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->curr); + curr_slot->curr = NULL; + return -EBADRQC; +} + +/* create slot curr_snesor[1-n] directory and attributes*/ +static int slot_curr_create(void) +{ + int curr_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_curr_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + curr_num = g_slot_drv->get_slot_curr_number(slot_index); + if (curr_num <= 0) { + SLOT_DBG("slot%u curr number: %d, don't need to create curr_sensor* dirs and attrs.\n", + slot_index, curr_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->curr_number = curr_num; + if (slotindex_curr_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_curr_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot curr_sensor[1-n] directory and attributes*/ +static void slot_curr_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_curr_remove_kobj_and_attrs(curr_slot); + curr_slot->curr_number = 0; + } + } + return; +} +/**********************************end of slot current************************************/ +/*************************************slot voltage****************************************/ +static void slotindex_single_vol_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int vol_index) +{ + struct slot_vol_obj_s *curr_vol; + + curr_vol = &curr_slot->vol[vol_index - 1]; + if (curr_vol->obj) { + sysfs_remove_group(&curr_vol->obj->kobj, &slot_vol_attr_group); + switch_kobject_delete(&curr_vol->obj); + SLOT_DBG("delete slot%u vol_sensor%u dir and attrs success.\n", curr_slot->obj->index, + vol_index); + } + return; +} + +static int slotindex_single_vol_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int vol_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_vol_obj_s *curr_vol; + + curr_vol = &curr_slot->vol[vol_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "vol_sensor%u", vol_index); + curr_vol->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_vol->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_vol->obj->index = vol_index; + if (sysfs_create_group(&curr_vol->obj->kobj, &slot_vol_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_vol->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_vol_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int vol_index, vol_num; + + if (curr_slot->vol) { + vol_num = curr_slot->vol_number; + for (vol_index = vol_num; vol_index > 0; vol_index--) { + slotindex_single_vol_remove_kobj_and_attrs(curr_slot, vol_index); + } + kfree(curr_slot->vol); + curr_slot->vol = NULL; + } + return; +} + +static int slotindex_vol_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int vol_index, i, vol_num; + + vol_num = curr_slot->vol_number; + curr_slot->vol = kzalloc(sizeof(struct slot_vol_obj_s) * vol_num, GFP_KERNEL); + if (!curr_slot->vol) { + SLOT_ERR("kzalloc slot vol error, slot index: %u, vol number: %u.\n", + curr_slot->obj->index, vol_num); + return -ENOMEM; + } + + for (vol_index = 1; vol_index <= vol_num; vol_index++) { + if (slotindex_single_vol_create_kobj_and_attrs(curr_slot, vol_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = vol_index; i > 0; i--) { + slotindex_single_vol_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->vol); + curr_slot->vol = NULL; + return -EBADRQC; +} + +/* create slot vol_snesor[1-n] directory and attributes*/ +static int slot_vol_create(void) +{ + int vol_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_vol_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + vol_num = g_slot_drv->get_slot_vol_number(slot_index); + if (vol_num <= 0) { + SLOT_DBG("slot%u vol number: %d, don't need to create vol_sensor* dirs and attrs.\n", + slot_index, vol_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->vol_number = vol_num; + if (slotindex_vol_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_vol_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot vol_sensor[1-n] directory and attributes*/ +static void slot_vol_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_vol_remove_kobj_and_attrs(curr_slot); + curr_slot->vol_number = 0; + } + } + return; +} +/**********************************end of slot voltage************************************/ +/***************************************slot temp*****************************************/ +static void slotindex_single_temp_remove_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int temp_index) +{ + struct slot_temp_obj_s *curr_temp; + + curr_temp = &curr_slot->temp[temp_index - 1]; + if (curr_temp->obj) { + sysfs_remove_group(&curr_temp->obj->kobj, &slot_temp_attr_group); + switch_kobject_delete(&curr_temp->obj); + SLOT_DBG("delete slot%u temp_sensor%u dir and attrs success.\n", curr_slot->obj->index, + temp_index); + } + return; +} + +static int slotindex_single_temp_create_kobj_and_attrs(struct slot_obj_s *curr_slot, + unsigned int temp_index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_temp_obj_s *curr_temp; + + curr_temp = &curr_slot->temp[temp_index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp_sensor%u", temp_index); + curr_temp->obj = switch_kobject_create(name, &curr_slot->obj->kobj); + if (!curr_temp->obj) { + SLOT_ERR("create slot%u %s object error!\n", curr_slot->obj->index, name); + return -ENOMEM; + } + curr_temp->obj->index = temp_index; + if (sysfs_create_group(&curr_temp->obj->kobj, &slot_temp_attr_group) != 0) { + SLOT_ERR("create slot%u %s attrs error.\n", curr_slot->obj->index, name); + switch_kobject_delete(&curr_temp->obj); + return -EBADRQC; + } + SLOT_DBG("create slot%u %s success.\n", curr_slot->obj->index, name); + return 0; +} + +static void slotindex_temp_remove_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int temp_index, temp_num; + + if (curr_slot->temp) { + temp_num = curr_slot->temp_number; + for (temp_index = temp_num; temp_index > 0; temp_index--) { + slotindex_single_temp_remove_kobj_and_attrs(curr_slot, temp_index); + } + kfree(curr_slot->temp); + curr_slot->temp = NULL; + } + return; +} + +static int slotindex_temp_create_kobj_and_attrs(struct slot_obj_s *curr_slot) +{ + unsigned int temp_index, i, temp_num; + + temp_num = curr_slot->temp_number; + curr_slot->temp = kzalloc(sizeof(struct slot_temp_obj_s) * temp_num, GFP_KERNEL); + if (!curr_slot->temp) { + SLOT_ERR("kzalloc slot temp error, slot index: %u, temp number: %u.\n", + curr_slot->obj->index, temp_num); + return -ENOMEM; + } + + for (temp_index = 1; temp_index <= temp_num; temp_index++) { + if (slotindex_single_temp_create_kobj_and_attrs(curr_slot, temp_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = temp_index; i > 0; i--) { + slotindex_single_temp_remove_kobj_and_attrs(curr_slot, i); + } + kfree(curr_slot->temp); + curr_slot->temp = NULL; + return -EBADRQC; +} + +/* create slot temp_sensor[1-n] directory and attributes*/ +static int slot_temp_create(void) +{ + int temp_num; + unsigned int slot_index, i; + struct slot_obj_s *curr_slot; + + check_p(g_slot_drv->get_slot_temp_number); + for (slot_index = 1; slot_index <= g_slot.slot_number; slot_index++) { + temp_num = g_slot_drv->get_slot_temp_number(slot_index); + if (temp_num <= 0) { + SLOT_DBG("slot%u temp number: %d, don't need to create temp_sensor* dirs and attrs.\n", + slot_index, temp_num); + continue; + } + curr_slot = &g_slot.slot[slot_index - 1]; + curr_slot->temp_number = temp_num; + if (slotindex_temp_create_kobj_and_attrs(curr_slot) != 0) { + goto error; + } + } + return 0; +error: + for (i = slot_index; i > 0; i--) { + curr_slot = &g_slot.slot[i - 1]; + slotindex_temp_remove_kobj_and_attrs(curr_slot); + } + return -EBADRQC; +} + +/* delete slot temp_sensor[1-n] directory and attributes*/ +static void slot_temp_remove(void) +{ + unsigned int slot_index; + struct slot_obj_s *curr_slot; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + curr_slot = &g_slot.slot[slot_index - 1]; + slotindex_temp_remove_kobj_and_attrs(curr_slot); + curr_slot->temp_number = 0; + } + } + return; +} +/************************************end of slot temp**************************************/ + +static int slot_child_obj_create(void) +{ + int ret; + + if (g_slot.slot_number <= 0) { + SLOT_DBG("slot number: %u, skip to create slot child dirs and attrs.\n", + g_slot.slot_number); + return 0; + } + /* temp create */ + ret = slot_temp_create(); + if (ret < 0) { + goto temp_err; + } + /* Voltage create */ + ret = slot_vol_create(); + if(ret < 0) { + goto vol_err; + } + /* current create */ + ret = slot_curr_create(); + if(ret < 0) { + goto curr_err; + } + /* fpga create */ + ret = slot_fpga_create(); + if(ret < 0) { + goto fpga_err; + } + /* cplf create */ + ret = slot_cpld_create(); + if(ret < 0) { + goto cpld_err; + } + return 0; +cpld_err: + slot_fpga_remove(); +fpga_err: + slot_curr_remove(); +curr_err: + slot_vol_remove(); +vol_err: + slot_temp_remove(); +temp_err: + return ret; +} + +static void slot_child_obj_remove(void) +{ + slot_cpld_remove(); + slot_fpga_remove(); + slot_curr_remove(); + slot_vol_remove(); + slot_temp_remove(); + return; +} + +static void slot_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct slot_obj_s *curr_slot; + + curr_slot = &g_slot.slot[index - 1]; + if (curr_slot->obj) { + sysfs_remove_group(&curr_slot->obj->kobj, &slot_attr_group); + switch_kobject_delete(&curr_slot->obj); + SLOT_DBG("delete slot%u dir and attrs success.\n", index); + } + + return; +} + +static int slot_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct slot_obj_s * curr_slot; + + curr_slot = &g_slot.slot[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "slot%u", index); + curr_slot->obj = switch_kobject_create(name, parent); + if (!curr_slot->obj) { + SLOT_ERR("create %s object error!\n", name); + return -EBADRQC; + } + curr_slot->obj->index = index; + if (sysfs_create_group(&curr_slot->obj->kobj, &slot_attr_group) != 0) { + SLOT_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&curr_slot->obj); + return -EBADRQC; + } + SLOT_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static int slot_sub_create_kobj_and_attrs(struct kobject *parent, int slot_num) +{ + unsigned int slot_index, i; + + g_slot.slot = kzalloc(sizeof(struct slot_obj_s) * slot_num, GFP_KERNEL); + if (!g_slot.slot) { + SLOT_ERR("kzalloc slot.slot error, slot number = %d.\n", slot_num); + return -ENOMEM; + } + + for(slot_index = 1; slot_index <= slot_num; slot_index++) { + if(slot_sub_single_create_kobj_and_attrs(parent, slot_index) != 0 ) { + goto error; + } + } + return 0; +error: + for(i = slot_index; i > 0; i--) { + slot_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_slot.slot); + g_slot.slot = NULL; + return -EBADRQC; +} + +/* create slot[1-n] directory and attributes*/ +static int slot_sub_create(void) +{ + int ret; + + ret = slot_sub_create_kobj_and_attrs(&g_slot_obj->kobj, g_slot.slot_number); + return ret; +} + +/* delete slot[1-n] directory and attributes*/ +static void slot_sub_remove(void) +{ + unsigned int slot_index; + + if (g_slot.slot) { + for (slot_index = g_slot.slot_number; slot_index > 0; slot_index--) { + slot_sub_single_remove_kobj_and_attrs(slot_index); + } + kfree(g_slot.slot); + g_slot.slot = NULL; + } + g_slot.slot_number = 0; + return; +} + +/* create slot directory and number attributes*/ +static int slot_root_create(void) +{ + g_slot_obj = switch_kobject_create("slot", NULL); + if (!g_slot_obj) { + SLOT_ERR("switch_kobject_create slot error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_slot_obj->kobj, &slot_root_attr_group) != 0) { + switch_kobject_delete(&g_slot_obj); + SLOT_ERR("create slot dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete slot directory and number attributes*/ +static void slot_root_remove(void) +{ + if (g_slot_obj) { + sysfs_remove_group(&g_slot_obj->kobj, &slot_root_attr_group); + switch_kobject_delete(&g_slot_obj); + } + + return; +} + +int s3ip_sysfs_slot_drivers_register(struct s3ip_sysfs_slot_drivers_s *drv) +{ + int ret, slot_num; + + SLOT_INFO("s3ip_sysfs_slot_drivers_register...\n"); + if (g_slot_drv) { + SLOT_ERR("g_slot_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_slot_number); + g_slot_drv = drv; + + slot_num = g_slot_drv->get_slot_number(); + if (slot_num <= 0) { + SLOT_ERR("slot number: %d, don't need to create slot dirs and attrs.\n", slot_num); + g_slot_drv = NULL; + return -EINVAL; + } + + memset(&g_slot, 0, sizeof(struct slot_s)); + g_slot.slot_number = slot_num; + ret = slot_root_create(); + if (ret < 0) { + SLOT_ERR("create slot root dir and attrs failed, ret: %d\n", ret); + g_slot_drv = NULL; + return ret; + } + + ret = slot_sub_create(); + if (ret < 0) { + SLOT_ERR("create slot sub dir and attrs failed, ret: %d\n", ret); + slot_root_remove(); + g_slot_drv = NULL; + return ret; + } + + ret = slot_child_obj_create(); + if (ret < 0) { + SLOT_ERR("create slot child dir and attrs failed, ret: %d\n", ret); + slot_sub_remove(); + slot_root_remove(); + g_slot_drv = NULL; + return ret; + } + SLOT_INFO("s3ip_sysfs_slot_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_slot_drivers_unregister(void) +{ + if (g_slot_drv) { + slot_child_obj_remove(); + slot_sub_remove(); + slot_root_remove(); + g_slot_drv = NULL; + SLOT_DBG("s3ip_sysfs_slot_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_slot_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_slot_drivers_unregister); +module_param(g_slot_loglevel, int, 0644); +MODULE_PARM_DESC(g_slot_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/switch.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/switch.c new file mode 100644 index 000000000000..6bd07cfa0c65 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/switch.c @@ -0,0 +1,270 @@ +/* + * switch.c + * + * This module create a kset in sysfs called /sys/s3ip + * Then other switch kobjects are created and assigned to this kset, + * such as "cpld", "fan", "psu", ... + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include "switch.h" +#include "syseeprom_sysfs.h" + +int g_switch_loglevel = 0; + +#define SWITCH_INFO(fmt, args...) do { \ + if (g_switch_loglevel & INFO) { \ + printk(KERN_INFO "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SWITCH_ERR(fmt, args...) do { \ + if (g_switch_loglevel & ERR) { \ + printk(KERN_ERR "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SWITCH_DBG(fmt, args...) do { \ + if (g_switch_loglevel & DBG) { \ + printk(KERN_DEBUG "[SWITCH][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct syseeprom_s { + struct bin_attribute bin; + int creat_eeprom_bin_flag; +}; + +static struct s3ip_sysfs_syseeprom_drivers_s *g_syseeprom_drv = NULL; +static struct kset *switch_kset; +static struct syseeprom_s g_syseeprom; + +static ssize_t switch_attr_show(struct kobject *kobj, struct attribute *attr, char *buf) +{ + struct switch_attribute *attribute; + struct switch_obj *device; + + attribute = to_switch_attr(attr); + device = to_switch_obj(kobj); + + if (!attribute->show) { + return -ENOSYS; + } + + return attribute->show(device, attribute, buf); +} + +static ssize_t switch_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, + size_t len) +{ + struct switch_attribute *attribute; + struct switch_obj *obj; + + attribute = to_switch_attr(attr); + obj = to_switch_obj(kobj); + + if (!attribute->store) { + return -ENOSYS; + } + + return attribute->store(obj, attribute, buf, len); +} + +static const struct sysfs_ops switch_sysfs_ops = { + .show = switch_attr_show, + .store = switch_attr_store, +}; + +static void switch_obj_release(struct kobject *kobj) +{ + struct switch_obj *obj; + + obj = to_switch_obj(kobj); + kfree(obj); + return; +} + +static struct kobj_type switch_ktype = { + .sysfs_ops = &switch_sysfs_ops, + .release = switch_obj_release, + .default_attrs = NULL, +}; + +static ssize_t syseeprom_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + ssize_t rd_len; + + check_p(g_syseeprom_drv); + check_p(g_syseeprom_drv->read_syseeprom_data); + + memset(buf, 0, count); + rd_len = g_syseeprom_drv->read_syseeprom_data(buf, offset, count); + if (rd_len < 0) { + SWITCH_ERR("read syseeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + offset, count, rd_len); + return -EIO; + } + SWITCH_DBG("read syseeprom data success, offset:0x%llx, read len:%lu, really read len:%ld.\n", + offset, count, rd_len); + return rd_len; +} + +static ssize_t syseeprom_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + ssize_t wr_len; + + check_p(g_syseeprom_drv); + check_p(g_syseeprom_drv->write_syseeprom_data); + + wr_len = g_syseeprom_drv->write_syseeprom_data(buf, offset, count); + if (wr_len < 0) { + SWITCH_ERR("write syseeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + offset, count, wr_len); + return -EIO; + } + SWITCH_DBG("write syseeprom data success, offset:0x%llx, write len:%lu, really write len:%ld.\n", + offset, count, wr_len); + return wr_len; +} + +static int syseeprom_create_eeprom_attrs(void) +{ + int ret, eeprom_size; + + eeprom_size = g_syseeprom_drv->get_syseeprom_size(); + if (eeprom_size <= 0) { + SWITCH_ERR("syseeprom size: %d, invalid.\n", eeprom_size); + return -EINVAL; + } + + sysfs_bin_attr_init(&g_syseeprom.bin); + g_syseeprom.bin.attr.name = "syseeprom"; + g_syseeprom.bin.attr.mode = 0644; + g_syseeprom.bin.read = syseeprom_read; + g_syseeprom.bin.write = syseeprom_write; + g_syseeprom.bin.size = eeprom_size; + + ret = sysfs_create_bin_file(&switch_kset->kobj, &g_syseeprom.bin); + if (ret) { + SWITCH_ERR("create syseeprom bin error, ret: %d. \n", ret); + return -EBADRQC; + } + SWITCH_DBG("create syseeprom bin file success, eeprom size:%d.\n", eeprom_size); + g_syseeprom.creat_eeprom_bin_flag = 1; + return 0; +} + +static void syseeprom_remove_eeprom_attrs(void) +{ + if (g_syseeprom.creat_eeprom_bin_flag) { + sysfs_remove_bin_file(&switch_kset->kobj, &g_syseeprom.bin); + g_syseeprom.creat_eeprom_bin_flag = 0; + } + + return; +} + +int s3ip_sysfs_syseeprom_drivers_register(struct s3ip_sysfs_syseeprom_drivers_s *drv) +{ + int ret; + + SWITCH_INFO("s3ip_sysfs_syseeprom_drivers_register...\n"); + if (g_syseeprom_drv) { + SWITCH_ERR("g_syseeprom_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_syseeprom_size); + g_syseeprom_drv = drv; + + ret = syseeprom_create_eeprom_attrs(); + if (ret < 0) { + SWITCH_ERR("create syseeprom attributes failed, ret: %d\n", ret); + g_syseeprom_drv = NULL; + return ret; + } + SWITCH_INFO("s3ip_sysfs_syseeprom_drivers_register success.\n"); + return 0; +} + +void s3ip_sysfs_syseeprom_drivers_unregister(void) +{ + if (g_syseeprom_drv) { + syseeprom_remove_eeprom_attrs(); + g_syseeprom_drv = NULL; + SWITCH_DBG("s3ip_sysfs_syseeprom_drivers_unregister success.\n"); + } + + return; +} + +struct switch_obj *switch_kobject_create(const char *name, struct kobject *parent) +{ + struct switch_obj *obj; + int ret; + + obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) { + SWITCH_DBG("switch_kobject_create %s kzalloc error", name); + return NULL; + } + + obj->kobj.kset = switch_kset; + + ret = kobject_init_and_add(&obj->kobj, &switch_ktype, parent, "%s", name); + if (ret) { + kobject_put(&obj->kobj); + SWITCH_DBG("kobject_init_and_add %s error", name); + return NULL; + } + + return obj; +} + +void switch_kobject_delete(struct switch_obj **obj) +{ + if (*obj) { + SWITCH_DBG("%s delete %s.\n", (*obj)->kobj.parent->name, (*obj)->kobj.name); + kobject_put(&((*obj)->kobj)); + *obj = NULL; + } +} + +static int __init switch_init(void) +{ + SWITCH_INFO("switch_init...\n"); + + switch_kset = kset_create_and_add("s3ip", NULL, NULL); + if (!switch_kset) { + SWITCH_ERR("create switch_kset error.\n"); + return -ENOMEM; + } + + SWITCH_INFO("switch_init success.\n"); + return 0; +} + +static void __exit switch_exit(void) +{ + if (switch_kset) { + kset_unregister(switch_kset); + } + + SWITCH_INFO("switch_exit success.\n"); +} + +module_init(switch_init); +module_exit(switch_exit); +EXPORT_SYMBOL(s3ip_sysfs_syseeprom_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_syseeprom_drivers_unregister); +module_param(g_switch_loglevel, int, 0644); +MODULE_PARM_DESC(g_switch_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic S3IP sysfs"); +MODULE_DESCRIPTION("switch driver"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/sysled_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/sysled_sysfs.c new file mode 100644 index 000000000000..e42d40a755a2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/sysled_sysfs.c @@ -0,0 +1,314 @@ +/* + * sysled_sysfs.c + * + * This module create sysled kobjects and attributes in /sys/s3ip/sysled + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "sysled_sysfs.h" + +static int g_sysled_loglevel = 0; + +#define SYSLED_INFO(fmt, args...) do { \ + if (g_sysled_loglevel & INFO) { \ + printk(KERN_INFO "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SYSLED_ERR(fmt, args...) do { \ + if (g_sysled_loglevel & ERR) { \ + printk(KERN_ERR "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SYSLED_DBG(fmt, args...) do { \ + if (g_sysled_loglevel & DBG) { \ + printk(KERN_DEBUG "[SYSLED_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static struct switch_obj *g_sysled_obj = NULL; +static struct s3ip_sysfs_sysled_drivers_s *g_sysled_drv = NULL; + +static ssize_t sys_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_led_status); + + ret = g_sysled_drv->get_sys_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys led status success:\n"); + return ret; +} + +static ssize_t sys_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys led status %d success\n", value); + return count; +} + +static ssize_t bmc_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_bmc_led_status); + + ret = g_sysled_drv->get_bmc_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get bmc led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get bmc led status success:\n"); + return ret; +} + +static ssize_t bmc_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_bmc_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set bmc led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_bmc_led_status(value); + if (ret < 0) { + SYSLED_ERR("set bmc led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set bmc led status %d success\n", value); + return count; +} + +static ssize_t sys_fan_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_fan_led_status); + + ret = g_sysled_drv->get_sys_fan_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys fan led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys fan led status success:\n"); + return ret; +} + +static ssize_t sys_fan_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_fan_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys fan led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_fan_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys fan led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys fan led status %d success\n", value); + return count; +} + +static ssize_t sys_psu_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_sys_psu_led_status); + + ret = g_sysled_drv->get_sys_psu_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get sys psu led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get sys psu led status success:\n"); + return ret; +} + +static ssize_t sys_psu_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_sys_psu_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set sys psu led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_sys_psu_led_status(value); + if (ret < 0) { + SYSLED_ERR("set sys psu led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set sys psu led status %d success\n", value); + return count; +} + +static ssize_t id_led_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->get_id_led_status); + + ret = g_sysled_drv->get_id_led_status(buf, PAGE_SIZE); + if (ret < 0) { + SYSLED_ERR("get id led status failed, ret: %d:\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + SYSLED_DBG("get id led status success:\n"); + return ret; +} + +static ssize_t id_led_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_sysled_drv); + check_p(g_sysled_drv->set_id_led_status); + + sscanf(buf, "%d", &value); + if (value < 0) { + SYSLED_ERR("invaild led status value: %d, can't set id led status\n", value); + return -EINVAL; + } + ret = g_sysled_drv->set_id_led_status(value); + if (ret < 0) { + SYSLED_ERR("set id led status %d faield, ret: %d\n", value, ret); + return -EIO; + } + SYSLED_DBG("set id led status %d success\n", value); + return count; +} + +/************************************syseeprom dir and attrs*******************************************/ +static struct switch_attribute sys_led_attr = __ATTR(sys_led_status, S_IRUGO | S_IWUSR, sys_led_status_show, sys_led_status_store); +static struct switch_attribute bmc_led_attr = __ATTR(bmc_led_status, S_IRUGO | S_IWUSR, bmc_led_status_show, bmc_led_status_store); +static struct switch_attribute fan_led_attr = __ATTR(fan_led_status, S_IRUGO | S_IWUSR, sys_fan_led_status_show, sys_fan_led_status_store); +static struct switch_attribute psu_led_attr = __ATTR(psu_led_status, S_IRUGO | S_IWUSR, sys_psu_led_status_show, sys_psu_led_status_store); +static struct switch_attribute id_led_attr = __ATTR(id_led_status, S_IRUGO | S_IWUSR, id_led_status_show, id_led_status_store); + +static struct attribute *sysled_dir_attrs[] = { + &sys_led_attr.attr, + &bmc_led_attr.attr, + &fan_led_attr.attr, + &psu_led_attr.attr, + &id_led_attr.attr, + NULL, +}; + +static struct attribute_group sysled_attr_group = { + .attrs = sysled_dir_attrs, +}; + +/* create syseled directory and attributes*/ +static int sysled_root_create(void) +{ + g_sysled_obj = switch_kobject_create("sysled", NULL); + if (!g_sysled_obj) { + SYSLED_ERR("switch_kobject_create sysled error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_sysled_obj->kobj, &sysled_attr_group) != 0) { + switch_kobject_delete(&g_sysled_obj); + SYSLED_ERR("create sysled dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete syseled directory and attributes*/ +static void sysled_root_remove(void) +{ + if (g_sysled_obj) { + sysfs_remove_group(&g_sysled_obj->kobj, &sysled_attr_group); + switch_kobject_delete(&g_sysled_obj); + } + + return; +} + +int s3ip_sysfs_sysled_drivers_register(struct s3ip_sysfs_sysled_drivers_s *drv) +{ + int ret; + + SYSLED_INFO("s3ip_sysfs_sysled_drivers_register...\n"); + if (g_sysled_drv) { + SYSLED_ERR("g_sysled_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + g_sysled_drv = drv; + + ret = sysled_root_create(); + if (ret < 0) { + SYSLED_ERR("sysled create error.\n"); + g_sysled_drv = NULL; + return ret; + } + SYSLED_INFO("s3ip_sysfs_sysled_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_sysled_drivers_unregister(void) +{ + if (g_sysled_drv) { + sysled_root_remove(); + g_sysled_drv = NULL; + SYSLED_DBG("s3ip_sysfs_sysled_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_sysled_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_sysled_drivers_unregister); +module_param(g_sysled_loglevel, int, 0644); +MODULE_PARM_DESC(g_sysled_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/temp_sensor_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/temp_sensor_sysfs.c new file mode 100644 index 000000000000..3bb229a5bf04 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/temp_sensor_sysfs.c @@ -0,0 +1,391 @@ +/* + * temp_sensor_sysfs.c + * + * This module create temp sensor kobjects and attributes in /sys/s3ip/temp_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "temp_sensor_sysfs.h" + +static int g_temp_sensor_loglevel = 0; + +#define TEMP_SENSOR_INFO(fmt, args...) do { \ + if (g_temp_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define TEMP_SENSOR_ERR(fmt, args...) do { \ + if (g_temp_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define TEMP_SENSOR_DBG(fmt, args...) do { \ + if (g_temp_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[TEMP_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct temp_sensor_obj_s { + struct switch_obj *obj; +}; + +struct temp_sensor_s { + unsigned int temp_number; + struct temp_sensor_obj_s *temp; +}; + +static struct s3ip_sysfs_temp_sensor_drivers_s *g_temp_sensor_drv = NULL; +static struct temp_sensor_s g_temp_sensor; +static struct switch_obj *g_temp_sensor_obj = NULL; + +static ssize_t temp_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_temp_sensor.temp_number); +} + +static ssize_t temp_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_value); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_value(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u value failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_alias); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_alias(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u alias failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_type); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_type(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u type failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_max); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_max(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u max threshold failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->set_main_board_temp_max); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->set_main_board_temp_max(temp_index, buf, count); + if (ret < 0) { + TEMP_SENSOR_ERR("set temp%u max threshold failed, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return -EIO; + } + TEMP_SENSOR_DBG("set temp%u max threshold success, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return count; +} + +static ssize_t temp_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->get_main_board_temp_min); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->get_main_board_temp_min(temp_index, buf, PAGE_SIZE); + if (ret < 0) { + TEMP_SENSOR_ERR("get temp%u min threshold failed, ret: %d\n", temp_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t temp_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int temp_index; + int ret; + + check_p(g_temp_sensor_drv); + check_p(g_temp_sensor_drv->set_main_board_temp_min); + + temp_index = obj->index; + TEMP_SENSOR_DBG("temp index: %u\n", temp_index); + ret = g_temp_sensor_drv->set_main_board_temp_min(temp_index, buf, count); + if (ret < 0) { + TEMP_SENSOR_ERR("set temp%u min threshold failed, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return -EIO; + } + TEMP_SENSOR_DBG("set temp%u min threshold success, value: %s, count: %lu, ret: %d\n", + temp_index, buf, count, ret); + return count; +} + +/************************************temp_sensor dir and attrs*******************************************/ +static struct switch_attribute num_temp_att = __ATTR(number, S_IRUGO, temp_sensor_number_show, NULL); + +static struct attribute *temp_sensor_dir_attrs[] = { + &num_temp_att.attr, + NULL, +}; + +static struct attribute_group temp_sensor_root_attr_group = { + .attrs = temp_sensor_dir_attrs, +}; + +/*******************************temp1 temp2 dir and attrs*******************************************/ +static struct switch_attribute temp_value_attr = __ATTR(value, S_IRUGO, temp_sensor_value_show, NULL); +static struct switch_attribute temp_alias_attr = __ATTR(alias, S_IRUGO, temp_sensor_alias_show, NULL); +static struct switch_attribute temp_type_attr = __ATTR(type, S_IRUGO, temp_sensor_type_show, NULL); +static struct switch_attribute temp_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, temp_sensor_max_show, temp_sensor_max_store); +static struct switch_attribute temp_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, temp_sensor_min_show, temp_sensor_min_store); + +static struct attribute *temp_sensor_attrs[] = { + &temp_value_attr.attr, + &temp_alias_attr.attr, + &temp_type_attr.attr, + &temp_max_attr.attr, + &temp_min_attr.attr, + NULL, +}; + +static struct attribute_group temp_sensor_attr_group = { + .attrs = temp_sensor_attrs, +}; + +static int temp_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct temp_sensor_obj_s *temp_sensor; + + temp_sensor = &g_temp_sensor.temp[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "temp%u", index); + temp_sensor->obj = switch_kobject_create(name, parent); + if (!temp_sensor->obj) { + TEMP_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + temp_sensor->obj->index = index; + if (sysfs_create_group(&temp_sensor->obj->kobj, &temp_sensor_attr_group) != 0) { + TEMP_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&temp_sensor->obj); + return -EBADRQC; + } + TEMP_SENSOR_DBG("create %s dir and attrs success.\n", name); + return 0; +} + +static void temp_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct temp_sensor_obj_s *temp_sensor; + + temp_sensor = &g_temp_sensor.temp[index - 1]; + if (temp_sensor->obj) { + sysfs_remove_group(&temp_sensor->obj->kobj, &temp_sensor_attr_group); + switch_kobject_delete(&temp_sensor->obj); + TEMP_SENSOR_DBG("delete temp%u dir and attrs success.\n", index); + } + + return; +} + +static int temp_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int temp_num) +{ + unsigned int temp_index, i; + + g_temp_sensor.temp = kzalloc(sizeof(struct temp_sensor_obj_s) * temp_num, GFP_KERNEL); + if (!g_temp_sensor.temp) { + TEMP_SENSOR_ERR("kzalloc g_temp_sensor.temp error, temp number: %d.\n", temp_num); + return -ENOMEM; + } + + for (temp_index = 1; temp_index <= temp_num; temp_index++) { + if (temp_sensor_sub_single_create_kobj_and_attrs(parent, temp_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = temp_index; i > 0; i--) { + temp_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_temp_sensor.temp); + g_temp_sensor.temp = NULL; + return -EBADRQC; +} + +/* create temp[1-n] directory and attributes*/ +static int temp_sensor_sub_create(void) +{ + int ret; + + ret = temp_sensor_sub_create_kobj_and_attrs(&g_temp_sensor_obj->kobj, + g_temp_sensor.temp_number); + return ret; +} + +/* delete temp[1-n] directory and attributes*/ +static void temp_sensor_sub_remove(void) +{ + unsigned int temp_index; + + if (g_temp_sensor.temp) { + for (temp_index = g_temp_sensor.temp_number; temp_index > 0; temp_index--) { + temp_sensor_sub_single_remove_kobj_and_attrs(temp_index); + } + kfree(g_temp_sensor.temp); + g_temp_sensor.temp = NULL; + } + + return; +} + +/* create temp_sensor directory and number attributes */ +static int temp_sensor_root_create(void) +{ + g_temp_sensor_obj = switch_kobject_create("temp_sensor", NULL); + if (!g_temp_sensor_obj) { + TEMP_SENSOR_ERR("switch_kobject_create temp_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_temp_sensor_obj->kobj, &temp_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_temp_sensor_obj); + TEMP_SENSOR_ERR("create temp_sensor dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete temp_sensor directory and number attributes */ +static void temp_sensor_root_remove(void) +{ + if (g_temp_sensor_obj) { + sysfs_remove_group(&g_temp_sensor_obj->kobj, &temp_sensor_root_attr_group); + switch_kobject_delete(&g_temp_sensor_obj); + } + + return; +} + +int s3ip_sysfs_temp_sensor_drivers_register(struct s3ip_sysfs_temp_sensor_drivers_s *drv) +{ + int ret, temp_num; + + TEMP_SENSOR_INFO("s3ip_sysfs_temp_sensor_drivers_register...\n"); + if (g_temp_sensor_drv) { + TEMP_SENSOR_ERR("g_temp_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_temp_number); + g_temp_sensor_drv = drv; + + temp_num = g_temp_sensor_drv->get_main_board_temp_number(); + if (temp_num <= 0) { + TEMP_SENSOR_ERR("temp sensor number: %d, don't need to create temp_sensor dirs and attrs.\n", + temp_num); + return -EINVAL; + } + memset(&g_temp_sensor, 0, sizeof(struct temp_sensor_s)); + g_temp_sensor.temp_number = temp_num; + ret = temp_sensor_root_create(); + if (ret < 0) { + TEMP_SENSOR_ERR("create temp_sensor root dir and attrs failed, ret: %d\n", ret); + g_temp_sensor_drv = NULL; + return ret; + } + + ret = temp_sensor_sub_create(); + if (ret < 0) { + TEMP_SENSOR_ERR("create temp_sensor sub dir and attrs failed, ret: %d\n", ret); + temp_sensor_root_remove(); + g_temp_sensor_drv = NULL; + return ret; + } + TEMP_SENSOR_INFO("s3ip_sysfs_temp_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_temp_sensor_drivers_unregister(void) +{ + if (g_temp_sensor_drv) { + temp_sensor_sub_remove(); + temp_sensor_root_remove(); + g_temp_sensor_drv = NULL; + TEMP_SENSOR_DBG("s3ip_sysfs_temp_sensor_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_temp_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_temp_sensor_drivers_unregister); +module_param(g_temp_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_temp_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/transceiver_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/transceiver_sysfs.c new file mode 100644 index 000000000000..02ad4d7a8688 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/transceiver_sysfs.c @@ -0,0 +1,618 @@ +/* + * transceiver_sysfs.c + * + * This module create eth kobjects and attributes in /sys/s3ip/transceiver + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "transceiver_sysfs.h" + +static int g_sff_loglevel = 0; + +#define SFF_INFO(fmt, args...) do { \ + if (g_sff_loglevel & INFO) { \ + printk(KERN_INFO "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SFF_ERR(fmt, args...) do { \ + if (g_sff_loglevel & ERR) { \ + printk(KERN_ERR "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define SFF_DBG(fmt, args...) do { \ + if (g_sff_loglevel & DBG) { \ + printk(KERN_DEBUG "[SFF_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct sff_obj_s { + struct switch_obj *sff_obj; + struct bin_attribute bin; + int sff_creat_bin_flag; +}; + +struct sff_s { + unsigned int sff_number; + struct sff_obj_s *sff; +}; + +static struct sff_s g_sff; +static struct switch_obj *g_sff_obj = NULL; +static struct s3ip_sysfs_transceiver_drivers_s *g_sff_drv = NULL; + +static ssize_t transceiver_power_on_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_transceiver_power_on_status); + + ret = g_sff_drv->get_transceiver_power_on_status(buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get transceiver power on status failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t transceiver_power_on_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_transceiver_power_on_status); + + sscanf(buf, "%d", &value); + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set transceiver power on status.\n", value); + return -EINVAL; + } + + ret = g_sff_drv->set_transceiver_power_on_status(value); + if (ret < 0) { + SFF_ERR("set transceiver power on status %d failed, ret: %d\n", value, ret); + return -EIO; + } + return count; +} + +static ssize_t eth_power_on_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_power_on_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_power_on_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u power on status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_power_on_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_power_on_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u power on status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_power_on_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u power on status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u power on status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_tx_fault_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_tx_fault_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_tx_fault_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u tx fault status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_tx_disable_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_tx_disable_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_tx_disable_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u tx disable status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_tx_disable_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_tx_disable_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u tx disable status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_tx_disable_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u tx disable status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u tx disable status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_present_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_present_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_present_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u present status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_rx_los_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_rx_los_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_rx_los_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u rx los status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_reset_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_reset_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_reset_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u reset status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_reset_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int eth_index; + int ret, value; + + check_p(g_sff_drv); + check_p(g_sff_drv->set_eth_reset_status); + + sscanf(buf, "%d", &value); + eth_index = obj->index; + if (value < 0 || value > 1) { + SFF_ERR("invalid value: %d, can't set eth%u reset status.\n", value, eth_index); + return -EINVAL; + } + + ret = g_sff_drv->set_eth_reset_status(eth_index, value); + if (ret < 0) { + SFF_ERR("set eth%u reset status %d failed, ret: %d\n", eth_index, value, ret); + return -EIO; + } + SFF_DBG("set eth%u reset status %d success\n", eth_index, value); + return count; +} + +static ssize_t eth_low_power_mode_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_low_power_mode_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_low_power_mode_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u low power mode status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_interrupt_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int eth_index; + int ret; + + check_p(g_sff_drv); + check_p(g_sff_drv->get_eth_interrupt_status); + + eth_index = obj->index; + SFF_DBG("eth index: %u\n", eth_index); + ret = g_sff_drv->get_eth_interrupt_status(eth_index, buf, PAGE_SIZE); + if (ret < 0) { + SFF_ERR("get eth%u interrupt status failed, ret: %d\n", eth_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t eth_eeprom_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + struct switch_obj *eth_obj; + ssize_t rd_len; + unsigned int eth_index; + + check_p(g_sff_drv); + check_p(g_sff_drv->read_eth_eeprom_data); + + eth_obj = to_switch_obj(kobj); + eth_index = eth_obj->index; + memset(buf, 0, count); + rd_len = g_sff_drv->read_eth_eeprom_data(eth_index, buf, offset, count); + if (rd_len < 0) { + SFF_ERR("read eth%u eeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + eth_index, offset, count, rd_len); + return -EIO; + } + + SFF_DBG("read eth%u eeprom data success, offset:0x%llx, read len:%lu, really read len:%ld.\n", + eth_index, offset, count, rd_len); + + return rd_len; +} + +static ssize_t eth_eeprom_write(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, + char *buf, loff_t offset, size_t count) +{ + struct switch_obj *eth_obj; + ssize_t wr_len; + unsigned int eth_index; + + check_p(g_sff_drv); + check_p(g_sff_drv->write_eth_eeprom_data); + + eth_obj = to_switch_obj(kobj); + eth_index = eth_obj->index; + wr_len = g_sff_drv->write_eth_eeprom_data(eth_index, buf, offset, count); + if (wr_len < 0) { + SFF_ERR("write eth%u eeprom data error, offset: 0x%llx, read len: %lu, ret: %ld.\n", + eth_index, offset, count, wr_len); + return -EIO; + } + + SFF_DBG("write eth%u eeprom data success, offset:0x%llx, write len:%lu, really write len:%ld.\n", + eth_index, offset, count, wr_len); + + return wr_len; +} + +/************************************eth* signal attrs*******************************************/ +static struct switch_attribute eth_power_on_attr = __ATTR(power_on, S_IRUGO | S_IWUSR, eth_power_on_show, eth_power_on_store); +static struct switch_attribute eth_tx_fault_attr = __ATTR(tx_fault, S_IRUGO, eth_tx_fault_show, NULL); +static struct switch_attribute eth_tx_disable_attr = __ATTR(tx_disable, S_IRUGO | S_IWUSR, eth_tx_disable_show, eth_tx_disable_store); +static struct switch_attribute eth_present_attr = __ATTR(present, S_IRUGO, eth_present_show, NULL); +static struct switch_attribute eth_rx_los_attr = __ATTR(rx_los, S_IRUGO, eth_rx_los_show, NULL); +static struct switch_attribute eth_reset_attr = __ATTR(reset, S_IRUGO | S_IWUSR, eth_reset_show, eth_reset_store); +static struct switch_attribute eth_low_power_mode_attr = __ATTR(low_power_mode, S_IRUGO, eth_low_power_mode_show, NULL); +static struct switch_attribute eth_interrupt_attr = __ATTR(interrupt, S_IRUGO, eth_interrupt_show, NULL); + +static struct attribute *sff_signal_attrs[] = { + ð_power_on_attr.attr, + ð_tx_fault_attr.attr, + ð_tx_disable_attr.attr, + ð_present_attr.attr, + ð_rx_los_attr.attr, + ð_reset_attr.attr, + ð_low_power_mode_attr.attr, + ð_interrupt_attr.attr, + NULL, +}; + +static struct attribute_group sff_signal_attr_group = { + .attrs = sff_signal_attrs, +}; + +/*******************************transceiver dir and attrs*******************************************/ +static struct switch_attribute transceiver_power_on_attr = __ATTR(power_on, S_IRUGO | S_IWUSR, transceiver_power_on_show, transceiver_power_on_store); + +static struct attribute *transceiver_dir_attrs[] = { + &transceiver_power_on_attr.attr, + NULL, +}; + +static struct attribute_group sff_transceiver_attr_group = { + .attrs = transceiver_dir_attrs, +}; + +/* create eth* eeprom attributes */ +static int sff_sub_single_create_eeprom_attrs(unsigned int index) +{ + int ret, eeprom_size; + struct sff_obj_s *curr_sff; + + check_p(g_sff_drv->get_eth_eeprom_size); + eeprom_size = g_sff_drv->get_eth_eeprom_size(index); + if (eeprom_size <= 0) { + SFF_INFO("eth%u, eeprom_size: %d, don't need to creat eeprom attr.\n", + index, eeprom_size); + return 0; + } + + curr_sff = &g_sff.sff[index - 1]; + sysfs_bin_attr_init(&curr_sff->bin); + curr_sff->bin.attr.name = "eeprom"; + curr_sff->bin.attr.mode = 0644; + curr_sff->bin.read = eth_eeprom_read; + curr_sff->bin.write = eth_eeprom_write; + curr_sff->bin.size = eeprom_size; + + ret = sysfs_create_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + if (ret) { + SFF_ERR("eth%u, create eeprom bin error, ret: %d. \n", index, ret); + return -EBADRQC; + } + + SFF_DBG("eth%u, create bin file success, eeprom size:%d.\n", index, eeprom_size); + curr_sff->sff_creat_bin_flag = 1; + return 0; +} + +static int sff_sub_single_create_kobj(struct kobject *parent, unsigned int index) +{ + struct sff_obj_s *curr_sff; + char sff_dir_name[DIR_NAME_MAX_LEN]; + + curr_sff = &g_sff.sff[index - 1]; + memset(sff_dir_name, 0, sizeof(sff_dir_name)); + snprintf(sff_dir_name, sizeof(sff_dir_name), "eth%d", index); + curr_sff->sff_obj = switch_kobject_create(sff_dir_name, parent); + if (!curr_sff->sff_obj) { + SFF_ERR("create eth%d object error! \n", index); + return -EBADRQC; + } + curr_sff->sff_obj->index = index; + if (sysfs_create_group(&curr_sff->sff_obj->kobj, &sff_signal_attr_group) != 0) { + switch_kobject_delete(&curr_sff->sff_obj); + return -EBADRQC; + } + + SFF_DBG("create eth%d dir and attrs success\n", index); + return 0; +} + +/* remove eth directory and attributes */ +static void sff_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct sff_obj_s *curr_sff; + + curr_sff = &g_sff.sff[index - 1]; + if (curr_sff->sff_obj) { + if (curr_sff->sff_creat_bin_flag) { + sysfs_remove_bin_file(&curr_sff->sff_obj->kobj, &curr_sff->bin); + curr_sff->sff_creat_bin_flag = 0; + } + sysfs_remove_group(&curr_sff->sff_obj->kobj, &sff_signal_attr_group); + switch_kobject_delete(&curr_sff->sff_obj); + } + + return; +} + +static int sff_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + int ret; + + ret = sff_sub_single_create_kobj(parent, index); + if (ret < 0) { + SFF_ERR("create eth%d dir error.\n", index); + return ret; + } + + sff_sub_single_create_eeprom_attrs(index); + return 0; +} + +static int sff_sub_create_kobj_and_attrs(struct kobject *parent, int sff_num) +{ + unsigned int sff_index, i; + + g_sff.sff = kzalloc(sizeof(struct sff_obj_s) * sff_num, GFP_KERNEL); + if (!g_sff.sff) { + SFF_ERR("kzalloc g_sff.sff error, sff number = %d.\n", sff_num); + return -ENOMEM; + } + + for (sff_index = 1; sff_index <= sff_num; sff_index++) { + if (sff_sub_single_create_kobj_and_attrs(parent, sff_index) != 0 ) { + goto error; + } + } + return 0; +error: + for (i = sff_index; i > 0; i--) { + sff_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_sff.sff); + g_sff.sff = NULL; + return -EBADRQC; +} + +/* create eth directory and attributes */ +static int sff_sub_create(void) +{ + int ret; + + ret = sff_sub_create_kobj_and_attrs(&g_sff_obj->kobj, g_sff.sff_number); + return ret; +} + +/* delete eth directory and attributes */ +static void sff_sub_remove(void) +{ + unsigned int sff_index; + + if (g_sff.sff) { + for (sff_index = g_sff.sff_number; sff_index > 0; sff_index--) { + sff_sub_single_remove_kobj_and_attrs(sff_index); + } + kfree(g_sff.sff); + g_sff.sff = NULL; + } + g_sff.sff_number = 0; + return; +} + +/* create transceiver directory and attributes */ +static int sff_transceiver_create(void) +{ + g_sff_obj = switch_kobject_create("transceiver", NULL); + if (!g_sff_obj) { + SFF_ERR("switch_kobject_create transceiver error!\n"); + return -ENOMEM; + } + g_sff_obj->index = 0; + if (sysfs_create_group(&g_sff_obj->kobj, &sff_transceiver_attr_group) != 0) { + switch_kobject_delete(&g_sff_obj); + SFF_ERR("create transceiver dir attrs error!\n"); + return -EBADRQC; + } + return 0; +} + +/* delete transceiver directory and attributes */ +static void sff_transceiver_remove(void) +{ + if (g_sff_obj) { + sysfs_remove_group(&g_sff_obj->kobj, &sff_transceiver_attr_group); + switch_kobject_delete(&g_sff_obj); + } + + return; +} + +int s3ip_sysfs_sff_drivers_register(struct s3ip_sysfs_transceiver_drivers_s *drv) +{ + int ret, sff_num; + + SFF_INFO("s3ip_sysfs_sff_drivers_register...\n"); + if (g_sff_drv) { + SFF_ERR("g_sff_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_eth_number); + g_sff_drv = drv; + + sff_num = g_sff_drv->get_eth_number(); + if (sff_num <= 0) { + SFF_ERR("eth number: %d, don't need to create transceiver dirs and attrs.\n", sff_num); + g_sff_drv = NULL; + return -EINVAL; + } + + memset(&g_sff, 0, sizeof(struct sff_s)); + g_sff.sff_number = sff_num; + ret = sff_transceiver_create(); + if (ret < 0) { + SFF_ERR("create transceiver root dir and attrs failed, ret: %d\n", ret); + g_sff_drv = NULL; + return ret; + } + ret = sff_sub_create(); + if (ret < 0) { + SFF_ERR("create transceiver sub dir and attrs failed, ret: %d\n", ret); + sff_transceiver_remove(); + g_sff_drv = NULL; + return ret; + } + SFF_INFO("s3ip_sysfs_sff_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_sff_drivers_unregister(void) +{ + if (g_sff_drv) { + sff_sub_remove(); + sff_transceiver_remove(); + g_sff_drv = NULL; + SFF_DBG("s3ip_sysfs_sff_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_sff_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_sff_drivers_unregister); +module_param(g_sff_loglevel, int, 0644); +MODULE_PARM_DESC(g_sff_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/vol_sensor_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/vol_sensor_sysfs.c new file mode 100644 index 000000000000..ac1b115061cc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/vol_sensor_sysfs.c @@ -0,0 +1,433 @@ +/* + * vol_sensor_sysfs.c + * + * This module create vol sensor kobjects and attributes in /sys/s3ip/vol_sensor + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "vol_sensor_sysfs.h" + +static int g_vol_sensor_loglevel = 0; + +#define VOL_SENSOR_INFO(fmt, args...) do { \ + if (g_vol_sensor_loglevel & INFO) { \ + printk(KERN_INFO "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define VOL_SENSOR_ERR(fmt, args...) do { \ + if (g_vol_sensor_loglevel & ERR) { \ + printk(KERN_ERR "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define VOL_SENSOR_DBG(fmt, args...) do { \ + if (g_vol_sensor_loglevel & DBG) { \ + printk(KERN_DEBUG "[VOL_SENSOR][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +struct vol_sensor_obj_s { + struct switch_obj *obj; +}; + +struct vol_sensor_s { + unsigned int vol_number; + struct vol_sensor_obj_s *vol; +}; + +static struct s3ip_sysfs_vol_sensor_drivers_s *g_vol_sensor_drv = NULL; +static struct vol_sensor_s g_vol_sensor; +static struct switch_obj *g_vol_sensor_obj = NULL; + +static ssize_t vol_sensor_number_show(struct switch_obj *obj, struct switch_attribute *attr, + char *buf) +{ + return (ssize_t)snprintf(buf, PAGE_SIZE, "%u\n", g_vol_sensor.vol_number); +} + +static ssize_t vol_sensor_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_value); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_value(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u value failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_alias_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_alias); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_alias(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u alias failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_type_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_type); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_type(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u type failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_max_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_max); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_max(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u max threshold failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_max_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->set_main_board_vol_max); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->set_main_board_vol_max(vol_index, buf, count); + if (ret < 0) { + VOL_SENSOR_ERR("set vol%u max threshold failed, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return -EIO; + } + VOL_SENSOR_DBG("set vol%u max threshold success, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return count; +} + +static ssize_t vol_sensor_min_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_min); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_min(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u min threshold failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_min_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->set_main_board_vol_min); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->set_main_board_vol_min(vol_index, buf, count); + if (ret < 0) { + VOL_SENSOR_ERR("set vol%u min threshold failed, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return -EIO; + } + VOL_SENSOR_DBG("set vol%u min threshold success, value: %s, count: %lu, ret: %d\n", + vol_index, buf, count, ret); + return count; +} + +static ssize_t vol_sensor_range_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_range); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_range(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u range failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +static ssize_t vol_sensor_nominal_value_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + unsigned int vol_index; + int ret; + + check_p(g_vol_sensor_drv); + check_p(g_vol_sensor_drv->get_main_board_vol_nominal_value); + + vol_index = obj->index; + VOL_SENSOR_DBG("vol index: %u\n", vol_index); + ret = g_vol_sensor_drv->get_main_board_vol_nominal_value(vol_index, buf, PAGE_SIZE); + if (ret < 0) { + VOL_SENSOR_ERR("get vol%u nominal value failed, ret: %d\n", vol_index, ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + return ret; +} + +/************************************vol_sensor dir and attrs*******************************************/ +static struct switch_attribute num_vol_att = __ATTR(number, S_IRUGO, vol_sensor_number_show, NULL); + +static struct attribute *vol_sensor_dir_attrs[] = { + &num_vol_att.attr, + NULL, +}; + +static struct attribute_group vol_sensor_root_attr_group = { + .attrs = vol_sensor_dir_attrs, +}; + +/*******************************vol1 vol2 dir and attrs*******************************************/ +static struct switch_attribute vol_value_attr = __ATTR(value, S_IRUGO, vol_sensor_value_show, NULL); +static struct switch_attribute vol_alias_attr = __ATTR(alias, S_IRUGO, vol_sensor_alias_show, NULL); +static struct switch_attribute vol_type_attr = __ATTR(type, S_IRUGO, vol_sensor_type_show, NULL); +static struct switch_attribute vol_max_attr = __ATTR(max, S_IRUGO | S_IWUSR, vol_sensor_max_show, vol_sensor_max_store); +static struct switch_attribute vol_min_attr = __ATTR(min, S_IRUGO | S_IWUSR, vol_sensor_min_show, vol_sensor_min_store); +static struct switch_attribute vol_range_attr = __ATTR(range, S_IRUGO, vol_sensor_range_show, NULL); +static struct switch_attribute vol_nominal_value_attr = __ATTR(nominal_value, S_IRUGO, vol_sensor_nominal_value_show, NULL); + +static struct attribute *vol_sensor_attrs[] = { + &vol_value_attr.attr, + &vol_alias_attr.attr, + &vol_type_attr.attr, + &vol_max_attr.attr, + &vol_min_attr.attr, + &vol_range_attr.attr, + &vol_nominal_value_attr.attr, + NULL, +}; + +static struct attribute_group vol_sensor_attr_group = { + .attrs = vol_sensor_attrs, +}; + +static int vol_sensor_sub_single_create_kobj_and_attrs(struct kobject *parent, unsigned int index) +{ + char name[DIR_NAME_MAX_LEN]; + struct vol_sensor_obj_s *vol_sensor; + + vol_sensor = &g_vol_sensor.vol[index - 1]; + memset(name, 0, sizeof(name)); + snprintf(name, sizeof(name), "vol%u", index); + vol_sensor->obj = switch_kobject_create(name, parent); + if (!vol_sensor->obj) { + VOL_SENSOR_ERR("create %s object error.\n", name); + return -ENOMEM; + } + + vol_sensor->obj->index = index; + if (sysfs_create_group(&vol_sensor->obj->kobj, &vol_sensor_attr_group) != 0) { + VOL_SENSOR_ERR("create %s attrs error.\n", name); + switch_kobject_delete(&vol_sensor->obj); + return -EBADRQC; + } + VOL_SENSOR_DBG("create %s dir and attrs success.\n", name); + + return 0; +} + +static void vol_sensor_sub_single_remove_kobj_and_attrs(unsigned int index) +{ + struct vol_sensor_obj_s *vol_sensor; + + vol_sensor = &g_vol_sensor.vol[index - 1]; + if (vol_sensor->obj) { + sysfs_remove_group(&vol_sensor->obj->kobj, &vol_sensor_attr_group); + switch_kobject_delete(&vol_sensor->obj); + VOL_SENSOR_DBG("delete vol%u dir and attrs success.\n", index); + } + + return; +} + +static int vol_sensor_sub_create_kobj_and_attrs(struct kobject *parent, int vol_num) +{ + unsigned int vol_index, i; + + g_vol_sensor.vol = kzalloc(sizeof(struct vol_sensor_obj_s) * vol_num, GFP_KERNEL); + if (!g_vol_sensor.vol) { + VOL_SENSOR_ERR("kzalloc g_vol_sensor.vol error, vol number: %d.\n", vol_num); + return -ENOMEM; + } + + for (vol_index = 1; vol_index <= vol_num; vol_index++) { + if (vol_sensor_sub_single_create_kobj_and_attrs(parent, vol_index) != 0) { + goto error; + } + } + return 0; +error: + for (i = vol_index; i > 0; i--) { + vol_sensor_sub_single_remove_kobj_and_attrs(i); + } + kfree(g_vol_sensor.vol); + g_vol_sensor.vol = NULL; + return -EBADRQC; +} + +/* create vol[1-n] directory and attributes*/ +static int vol_sensor_sub_create(void) +{ + int ret; + + ret = vol_sensor_sub_create_kobj_and_attrs(&g_vol_sensor_obj->kobj, g_vol_sensor.vol_number); + return ret; +} + +/* delete vol[1-n] directory and attributes*/ +static void vol_sensor_sub_remove(void) +{ + unsigned int vol_index; + + if (g_vol_sensor.vol) { + for (vol_index = g_vol_sensor.vol_number; vol_index > 0; vol_index--) { + vol_sensor_sub_single_remove_kobj_and_attrs(vol_index); + } + kfree(g_vol_sensor.vol); + g_vol_sensor.vol = NULL; + } + + return; +} + +/* create vol_sensor directory and number attributes */ +static int vol_sensor_root_create(void) +{ + g_vol_sensor_obj = switch_kobject_create("vol_sensor", NULL); + if (!g_vol_sensor_obj) { + VOL_SENSOR_ERR("switch_kobject_create vol_sensor error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_vol_sensor_obj->kobj, &vol_sensor_root_attr_group) != 0) { + switch_kobject_delete(&g_vol_sensor_obj); + VOL_SENSOR_ERR("create vol_sensor dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete vol_sensor directory and number attributes */ +static void vol_sensor_root_remove(void) +{ + if (g_vol_sensor_obj) { + sysfs_remove_group(&g_vol_sensor_obj->kobj, &vol_sensor_root_attr_group); + switch_kobject_delete(&g_vol_sensor_obj); + } + + return; +} + +int s3ip_sysfs_vol_sensor_drivers_register(struct s3ip_sysfs_vol_sensor_drivers_s *drv) +{ + int ret, vol_num; + + VOL_SENSOR_INFO("s3ip_sysfs_vol_sensor_drivers_register...\n"); + if (g_vol_sensor_drv) { + VOL_SENSOR_ERR("g_vol_sensor_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + check_p(drv->get_main_board_vol_number); + g_vol_sensor_drv = drv; + + vol_num = g_vol_sensor_drv->get_main_board_vol_number(); + if (vol_num <= 0) { + VOL_SENSOR_ERR("vol sensor number: %d, don't need to create vol_sensor dirs and attrs.\n", + vol_num); + return -EINVAL; + } + memset(&g_vol_sensor, 0, sizeof(struct vol_sensor_s)); + g_vol_sensor.vol_number = vol_num; + ret = vol_sensor_root_create(); + if (ret < 0) { + VOL_SENSOR_ERR("create vol_sensor root dir and attrs failed, ret: %d\n", ret); + g_vol_sensor_drv = NULL; + return ret; + } + + ret = vol_sensor_sub_create(); + if (ret < 0) { + VOL_SENSOR_ERR("create vol_sensor sub dir and attrs failed, ret: %d\n", ret); + vol_sensor_root_remove(); + g_vol_sensor_drv = NULL; + return ret; + } + VOL_SENSOR_INFO("s3ip_sysfs_vol_sensor_drivers_register success\n"); + return ret; +} + +void s3ip_sysfs_vol_sensor_drivers_unregister(void) +{ + if (g_vol_sensor_drv) { + vol_sensor_sub_remove(); + vol_sensor_root_remove(); + g_vol_sensor_drv = NULL; + VOL_SENSOR_DBG("s3ip_sysfs_vol_sensor_drivers_unregister success.\n"); + } + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_vol_sensor_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_vol_sensor_drivers_unregister); +module_param(g_vol_sensor_loglevel, int, 0644); +MODULE_PARM_DESC(g_vol_sensor_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/watchdog_sysfs.c b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/watchdog_sysfs.c new file mode 100644 index 000000000000..4487d5d19ac7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/S3IP_sysfs/sysfs_driver/watchdog_sysfs.c @@ -0,0 +1,263 @@ +/* + * watchdog_sysfs.c + * + * This module create watchdog kobjects and attributes in /sys/s3ip/watchdog + * + * History + * [Version] [Date] [Description] + * * v1.0 2021-08-31 S3IP sysfs + */ + +#include + +#include "switch.h" +#include "watchdog_sysfs.h" + +static int g_wdt_loglevel = 0; + +#define WDT_INFO(fmt, args...) do { \ + if (g_wdt_loglevel & INFO) { \ + printk(KERN_INFO "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define WDT_ERR(fmt, args...) do { \ + if (g_wdt_loglevel & ERR) { \ + printk(KERN_ERR "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define WDT_DBG(fmt, args...) do { \ + if (g_wdt_loglevel & DBG) { \ + printk(KERN_DEBUG "[WDT_SYSFS][func:%s line:%d]\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +typedef enum wdt_enable_status_e { + WDT_DISENABLE = 0, /* close watchdog */ + WDT_ENABLE = 1, /* open watchdog */ +} wdt_enable_status_t; + +static struct switch_obj *g_watchdog_obj = NULL; +static struct s3ip_sysfs_watchdog_drivers_s *g_wdt_drv = NULL; + +static ssize_t watchdog_identify_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_identify); + + ret = g_wdt_drv->get_watchdog_identify(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog identify failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog identify success\n"); + return ret; +} + +static ssize_t watchdog_timeleft_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_timeleft); + + ret = g_wdt_drv->get_watchdog_timeleft(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog timeleft failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog timeleft success\n"); + return ret; +} + +static ssize_t watchdog_timeout_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_timeout); + + ret = g_wdt_drv->get_watchdog_timeout(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog timeout failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog timeout success\n"); + return ret; +} + +static ssize_t watchdog_timeout_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_timeout); + + sscanf(buf, "%d", &value); + if (value < 0) { + WDT_ERR("invaild timeout value: %d, can't set watchdog timeout\n", value); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_timeout(value); + if (ret < 0) { + WDT_ERR("set watchdog timeout value: %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog timeout value: %d success\n", ret); + return count; +} + +static ssize_t watchdog_enable_status_show(struct switch_obj *obj, struct switch_attribute *attr, char *buf) +{ + int ret; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->get_watchdog_enable_status); + + ret = g_wdt_drv->get_watchdog_enable_status(buf, PAGE_SIZE); + if (ret < 0) { + WDT_ERR("get watchdog enable status failed, ret: %d\n", ret); + return (ssize_t)snprintf(buf, PAGE_SIZE, "%s\n", SYSFS_DEV_ERROR); + } + WDT_DBG("get watchdog enable status success\n"); + return ret; +} + +static ssize_t watchdog_enable_status_store(struct switch_obj *obj, struct switch_attribute *attr, + const char *buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_enable_status); + + sscanf(buf, "%d", &value); + if ((value != WDT_DISENABLE) && (value != WDT_ENABLE)) { + WDT_ERR("invaild enable value: %d, can't set watchdog enable status\n", value); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_enable_status(value); + if (ret < 0) { + WDT_ERR("set watchdog enable status %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog enable status %d success\n", ret); + return count; +} + +static ssize_t watchdog_reset_store(struct switch_obj *obj, struct switch_attribute *attr, + const char* buf, size_t count) +{ + int ret, value; + + check_p(g_wdt_drv); + check_p(g_wdt_drv->set_watchdog_reset); + + ret = kstrtoint(buf, 0, &value); + if (ret) { + WDT_ERR("invalid value: %s \n", buf); + return -EINVAL; + } + + ret = g_wdt_drv->set_watchdog_reset(value); + if (ret < 0) { + WDT_ERR("set watchdog reset %d failed, ret: %d\n", value, ret); + return -EIO; + } + WDT_DBG("set watchdog reset %d success\n", ret); + return count; +} + +/************************************watchdog*******************************************/ +static struct switch_attribute watchdog_identify_attr = __ATTR(identify, S_IRUGO, watchdog_identify_show, NULL); +static struct switch_attribute watchdog_timeleft_attr = __ATTR(timeleft, S_IRUGO, watchdog_timeleft_show, NULL); +static struct switch_attribute watchdog_timeout_attr = __ATTR(timeout, S_IRUGO | S_IWUSR, watchdog_timeout_show, watchdog_timeout_store); +static struct switch_attribute watchdog_enable_attr = __ATTR(enable, S_IRUGO | S_IWUSR, watchdog_enable_status_show, watchdog_enable_status_store); +static struct switch_attribute watchdog_reset_attr = __ATTR(reset, S_IWUSR, NULL, watchdog_reset_store); + +static struct attribute *watchdog_dir_attrs[] = { + &watchdog_identify_attr.attr, + &watchdog_timeleft_attr.attr, + &watchdog_timeout_attr.attr, + &watchdog_enable_attr.attr, + &watchdog_reset_attr.attr, + NULL, +}; + +static struct attribute_group watchdog_attr_group = { + .attrs = watchdog_dir_attrs, +}; + +/* create watchdog directory and attributes */ +static int watchdog_root_create(void) +{ + g_watchdog_obj = switch_kobject_create("watchdog", NULL); + if (!g_watchdog_obj) { + WDT_ERR("switch_kobject_create watchdog error!\n"); + return -ENOMEM; + } + + if (sysfs_create_group(&g_watchdog_obj->kobj, &watchdog_attr_group) != 0) { + switch_kobject_delete(&g_watchdog_obj); + WDT_ERR("create fan dir attrs error!\n"); + return -EBADRQC; + } + + return 0; +} + +/* delete watchdog directory and attributes */ +static void watchdog_root_remove(void) +{ + if (g_watchdog_obj) { + sysfs_remove_group(&g_watchdog_obj->kobj, &watchdog_attr_group); + switch_kobject_delete(&g_watchdog_obj); + } + + return; +} + +int s3ip_sysfs_watchdog_drivers_register(struct s3ip_sysfs_watchdog_drivers_s *drv) +{ + int ret; + + WDT_INFO("s3ip_sysfs_watchdog_drivers_register...\n"); + if (g_wdt_drv) { + WDT_ERR("g_wdt_drv is not NULL, can't register\n"); + return -EPERM; + } + + check_p(drv); + g_wdt_drv = drv; + + ret = watchdog_root_create(); + if (ret < 0) { + WDT_ERR("watchdog create error.\n"); + g_wdt_drv = NULL; + return ret; + } + WDT_INFO("s3ip_sysfs_watchdog_drivers_register success\n"); + return 0; +} + +void s3ip_sysfs_watchdog_drivers_unregister(void) +{ + if (g_wdt_drv) { + watchdog_root_remove(); + g_wdt_drv = NULL; + WDT_DBG("s3ip_sysfs_watchdog_drivers_unregister success.\n"); + } + + return; +} + +EXPORT_SYMBOL(s3ip_sysfs_watchdog_drivers_register); +EXPORT_SYMBOL(s3ip_sysfs_watchdog_drivers_unregister); +module_param(g_wdt_loglevel, int, 0644); +MODULE_PARM_DESC(g_wdt_loglevel, "the log level(info=0x1, err=0x2, dbg=0x4).\n"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_load.py b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_load.py new file mode 100755 index 000000000000..3f359289f64a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_load.py @@ -0,0 +1,30 @@ +#!/usr/bin/python3 +import json +import os + +if __name__ == '__main__': + os.system("sudo rm -rf /sys_switch/*;sudo mkdir -p -m 777 /sys_switch") + + with open('/etc/s3ip/customer_sysfs.json', 'r') as jsonfile: + json_string = json.load(jsonfile) + for s3ip_sysfs_path in json_string['s3ip_syfs_paths']: + #print('path:' + s3ip_sysfs_path['path']) + #print('type:' + s3ip_sysfs_path['type']) + #print('value:' + s3ip_sysfs_path['value']) + + if s3ip_sysfs_path['type'] == "string" : + (path, file) = os.path.split(s3ip_sysfs_path['path']) + command = "sudo mkdir -p -m 777 " + path + #print(command) + os.system(command) + command = "sudo echo " + "\"" + s3ip_sysfs_path['value'] + "\"" + " > " + s3ip_sysfs_path['path'] + #print(command) + os.system(command) + elif s3ip_sysfs_path['type'] == "path" : + command = "sudo ln -s " + s3ip_sysfs_path['value'] + " " + s3ip_sysfs_path['path'] + #print(command) + os.system(command) + else: + print('error type:' + s3ip_sysfs_path['type']) + #os.system("tree -l /sys_switch") + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_sysfs_tool.sh b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_sysfs_tool.sh new file mode 100755 index 000000000000..ca42b4586daf --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/script/s3ip_sysfs_tool.sh @@ -0,0 +1,33 @@ +#! /bin/bash + +s3ip_start(){ + sudo rm -rf /sys_switch/* + sudo /usr/local/bin/s3ip_load.py + echo "s3ip service start" +} +s3ip_stop(){ + sudo rm -rf /sys_switch/* + echo "s3ip service stop" + +} + +case "$1" in + start) + s3ip_start + ;; + stop) + s3ip_stop + ;; + status) + sudo tree -l /sys_switch + ;; + restart) + s3ip_stop + s3ip_start + ;; + *) + echo "Usage: $0 {start|stop|status|restart}" + exit 1 +esac +exit + diff --git a/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/service/s3ip_sysfs.service b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/service/s3ip_sysfs.service new file mode 100755 index 000000000000..db557fefd149 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/common_custom/common_tx/service/s3ip_sysfs.service @@ -0,0 +1,17 @@ +[Unit] +Description=s3ip sysfs service +Wants=network-online.target +After=network-online.target rg_platform_driver.service +Before=pmon.service rg_platform_process.service +Requires=rg_platform_driver.service + +[Service] +Type=oneshot +User=root +ExecStart=/usr/local/bin/s3ip_sysfs_tool.sh start +ExecStop=/usr/local/bin/s3ip_sysfs_tool.sh stop +RemainAfterExit=yes + +[Install] +WantedBy=default.target + diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/changelog b/platform/broadcom/sonic-platform-modules-tencent/debian/changelog new file mode 100644 index 000000000000..c987c3560017 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/changelog @@ -0,0 +1,5 @@ +sonic-ruijie-platform-modules (1.0) unstable; urgency=low + + * Initial release + + -- sonic_rd Fri, 21 APR 2017 11:11:11 -0800 diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/compat b/platform/broadcom/sonic-platform-modules-tencent/debian/compat new file mode 100644 index 000000000000..f599e28b8ab0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/compat @@ -0,0 +1 @@ +10 diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/control b/platform/broadcom/sonic-platform-modules-tencent/debian/control new file mode 100755 index 000000000000..8815bfb5512d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/control @@ -0,0 +1,13 @@ +Source: sonic-ruijie-platform-modules +Section: main +Priority: extra +Maintainer: Ruijie Network +Standards-Version: 3.9.3 + +Package: platform-modules-ruijie-tcs8400 +Architecture: amd64 +Description: kernel modules for platform devices such as fan, led, sfp + +Package: platform-modules-ruijie-tcs9400 +Architecture: amd64 +Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/copyright b/platform/broadcom/sonic-platform-modules-tencent/debian/copyright new file mode 100755 index 000000000000..675157697ad9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/copyright @@ -0,0 +1,16 @@ +Copyright (C) 2016 Microsoft, Inc +Copyright (C) 2022 Ruijie Network Corporation + +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.install b/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.install new file mode 100644 index 000000000000..5fbd8e13c6b7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.install @@ -0,0 +1 @@ +tcs8400/modules/sonic_platform-1.0-py3-none-any.whl /usr/share/sonic/device/x86_64-tencent_tcs8400-r0 diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.postinst b/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.postinst new file mode 100755 index 000000000000..a8132f4f65a9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/platform-modules-ruijie-tcs8400.postinst @@ -0,0 +1,10 @@ +#!/bin/sh +# postinst + +kernel_version=$(uname -r) + +if [ -e /boot/System.map-${kernel_version} ]; then + depmod -a -F /boot/System.map-${kernel_version} ${kernel_version} || true +fi + +#DEBHELPER# diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/rule-tx.mk b/platform/broadcom/sonic-platform-modules-tencent/debian/rule-tx.mk new file mode 100755 index 000000000000..06596c412270 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/rule-tx.mk @@ -0,0 +1,6 @@ +currentdir = $(shell pwd) +CUSTOMS_DIRS = $(currentdir)/common_custom/common_tx +MODULE_DIRS := tcs8400 tcs9400 +export CUSTOMS_DIRS MODULE_DIRS + + diff --git a/platform/broadcom/sonic-platform-modules-tencent/debian/rules b/platform/broadcom/sonic-platform-modules-tencent/debian/rules new file mode 100755 index 000000000000..251b1bed958f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/debian/rules @@ -0,0 +1,100 @@ +#!/usr/bin/make -f +CC=gcc +INSTALL_MOD_DIR:=extra +KVERSION ?= $(shell uname -r) +KERNEL_SRC := /lib/modules/$(KVERSION) +MOD_SRC_DIR:= $(shell pwd) +KBUILD_OUTPUT=$(KERNEL_SRC)/build + +LIB_DIR = usr/lib/python3/dist-packages +CUSTOM_RULES_DIR := $(shell pwd)/debian + +export INSTALL_MOD_DIR top_srcdir KVERSION KERNEL_SRC CC KBUILD_OUTPUT CUSTOM_RULES_DIR + +include $(CUSTOM_RULES_DIR)/rule-tx.mk + +#all product need common +COMPILE_DIRS = $(MODULE_DIRS) + +clean_dirs = $(MODULE_DIRS) +clean_dirs += common + +custom_clean_dirs := $(addprefix _clean_,$(clean_dirs) ) +complie_clean_dirs := $(addprefix _clean_,$(CUSTOMS_DIRS) ) + + +%: + dh $@ +build: $(CUSTOMS_DIRS) + @echo "build success" + +$(custom_clean_dirs): + $(MAKE) -C $(patsubst _clean_%,%,$@) clean + +$(complie_clean_dirs): + $(MAKE) -C $(patsubst _clean_%,%,$@) clean + +common_build : + $(MAKE) -C $(MOD_SRC_DIR)/common + +$(COMPILE_DIRS): common_build + $(MAKE) -C $(MOD_SRC_DIR)/$@ + dh_testdir + dh_installdirs + #dh_installdirs -pplatform-modules-ruijie-$@ usr/local/bin + cp -r $(MOD_SRC_DIR)/common/build/* debian/platform-modules-ruijie-$@/ + cp -r $(MOD_SRC_DIR)/$@/build/* debian/platform-modules-ruijie-$@/ + +$(CUSTOMS_DIRS): $(COMPILE_DIRS) + $(MAKE) -C $@ + @(for mod in $(MODULE_DIRS); do \ + cp -r $@/build/* $(MOD_SRC_DIR)/debian/platform-modules-ruijie-$${mod}/; \ + cd $(MOD_SRC_DIR)/$${mod}; \ + cp -r $(MOD_SRC_DIR)/common/lib/plat_hal $(MOD_SRC_DIR)/$${mod}/; \ + cp -r $(MOD_SRC_DIR)/common/lib/rjutil $(MOD_SRC_DIR)/$${mod}/; \ + cp -r $(MOD_SRC_DIR)/common/lib/eepromutil $(MOD_SRC_DIR)/$${mod}/; \ + cp -r $(MOD_SRC_DIR)/common/sonic_platform $(MOD_SRC_DIR)/$${mod}/; \ + cp $(MOD_SRC_DIR)/common/script/hal_pltfm.py $(MOD_SRC_DIR)/$${mod}/hal_pltfm.py; \ + cp $(MOD_SRC_DIR)/common/script/platform_util.py $(MOD_SRC_DIR)/$${mod}/platform_util.py; \ + cp $(MOD_SRC_DIR)/common/script/platform_intf.py $(MOD_SRC_DIR)/$${mod}/platform_intf.py; \ + python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/plat_hal; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/rjutil; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/eepromutil; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/sonic_platform; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/hal_pltfm.py; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/platform_intf.py; \ + rm -rf $(MOD_SRC_DIR)/$${mod}/platform_util.py; \ + cd $(MOD_SRC_DIR); \ + done) + +binary: binary-indep + @echo "=======================================================" + +binary-indep: + # Resuming debhelper scripts + dh_testroot + dh_install + dh_installchangelogs + dh_installdocs + dh_systemd_enable + dh_installinit + dh_systemd_start + dh_link + dh_fixperms + dh_compress + dh_strip + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb +override_dh_usrlocal: + +override_dh_pysupport: + +clean: $(custom_clean_dirs) $(complie_clean_dirs) + dh_testdir + dh_testroot + dh_clean + +.PHONY: build $(COMPILE_DIRS) $(CUSTOMS_DIRS) binary binary-arch binary-indep clean \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/Makefile b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/Makefile new file mode 100755 index 000000000000..d4e576cf6a3f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/Makefile @@ -0,0 +1,28 @@ +PWD = $(shell pwd) +DIR_KERNEL_SRC = $(PWD)/modules/driver +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUB_BUILD_DIR = $(PWD)/build +INSTALL_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3/dist-packages +INSTALL_SYSFS_CFG_DIR = $(SUB_BUILD_DIR)/etc/plat_sysfs_cfg +INSTALL_S3IP_CONFIG_DIR = $(SUB_BUILD_DIR)/etc/s3ip + +all: + $(MAKE) -C $(KBUILD_OUTPUT) M=$(DIR_KERNEL_SRC) modules + @if [ ! -d ${INSTALL_DIR} ]; then mkdir -p ${INSTALL_DIR} ;fi + cp -r $(DIR_KERNEL_SRC)/*.ko $(INSTALL_DIR) + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + cp -r $(PWD)/config/* $(INSTALL_SCRIPT_DIR) + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/hal-config/ ]; then cp -r $(PWD)/hal-config/* ${INSTALL_LIB_DIR} ;fi + @if [ ! -d ${INSTALL_SYSFS_CFG_DIR} ]; then mkdir -p ${INSTALL_SYSFS_CFG_DIR} ;fi + @if [ -d $(PWD)/plat_sysfs_cfg/ ]; then cp -r $(PWD)/plat_sysfs_cfg/* ${INSTALL_SYSFS_CFG_DIR} ;fi + @if [ ! -d ${INSTALL_S3IP_CONFIG_DIR} ]; then mkdir -p ${INSTALL_S3IP_CONFIG_DIR} ;fi + @if [ -d $(PWD)/s3ip_config/ ]; then cp -r $(PWD)/s3ip_config/* ${INSTALL_S3IP_CONFIG_DIR} ;fi +clean: + rm -f ${DIR_KERNEL_SRC}/*.o ${DIR_KERNEL_SRC}/*.ko ${DIR_KERNEL_SRC}/*.mod.c ${DIR_KERNEL_SRC}/.*.cmd ${DIR_KERNEL_SRC}/.*.mod + rm -f ${DIR_KERNEL_SRC}/Module.markers ${DIR_KERNEL_SRC}/Module.symvers ${DIR_KERNEL_SRC}/modules.order + rm -rf ${DIR_KERNEL_SRC}/.tmp_versions + rm -rf $(SUB_BUILD_DIR) diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_0x407b_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_0x407b_config.py new file mode 100755 index 000000000000..f221dd6d6a67 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_0x407b_config.py @@ -0,0 +1,975 @@ +#!/usr/bin/python3 +from ruijiecommon import * + + +STARTMODULE = { + "xdpe_avscontrol":1, + "dev_monitor": 1, + "hal_fanctrl":1, + "hal_ledctrl":1, + "sff_temp_polling":1, + "rg_pmon_syslog":1, +} + +DEV_MONITOR_PARAM = { + "polling_time" : 10, + "psus": [ + {"name": "psu1", + "present": {"gettype": "i2c", "bus": 2, "loc": 0x1d, "offset": 0x34, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu1pmbus", "name": "rg_fsp1200", "bus": 41, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu1frue2", "name": "24c02", "bus": 41, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu2", + "present": {"gettype": "i2c", "bus": 2, "loc": 0x1d, "offset": 0x34, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu2pmbus", "name": "rg_fsp1200", "bus": 42, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu2frue2", "name": "24c02", "bus": 42, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "fans": [ + {"name": "fan1", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 5, "okval": 0}, + "device": [ + {"id": "fan1frue2", "name": "24c64", "bus": 35, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan2", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "fan2frue2", "name": "24c64", "bus": 34, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan3", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan3frue2", "name": "24c64", "bus": 33, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan4", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan4frue2", "name": "24c64", "bus": 32, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan5", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan5frue2", "name": "24c64", "bus": 31, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan6", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan6frue2", "name": "24c64", "bus": 30, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "others": [ + {"name":"eeprom", + "device":[ + {"id":"eeprom_1", "name":"24c02","bus":1, "loc":0x56, "attr":"eeprom"}, + ], + }, + {"name":"lm75", + "device":[ + {"id":"lm75_1", "name":"lm75","bus":36, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_2", "name":"lm75","bus":36, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_3", "name":"lm75","bus":39, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_4", "name":"lm75","bus":40, "loc":0x4e, "attr":"hwmon"}, + {"id":"lm75_5", "name":"lm75","bus":40, "loc":0x4f, "attr":"hwmon"}, + ], + }, + {"name":"mac_bsc", + "device":[ + {"id":"mac_bsc_1", "name":"rg_mac_bsc_td4","bus":44, "loc":0x44, "attr":"hwmon"}, + ], + }, + {"name":"ina3221", + "device":[ + {"id":"ina3221_1", "name":"rg_ina3221","bus":25, "loc":0x43, "attr":"hwmon"}, + ], + }, + {"name":"tps53622", + "device":[ + {"id":"tps53622_1", "name":"rg_tps53622","bus":25, "loc":0x60, "attr":"hwmon"}, + {"id":"tps53622_2", "name":"rg_tps53622","bus":25, "loc":0x6c, "attr":"hwmon"}, + ], + }, + {"name":"ucd90160", + "device":[ + {"id":"ucd90160_1", "name":"rg_ucd90160","bus":24, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_2", "name":"rg_ucd90160","bus":45, "loc":0x5b, "attr":"hwmon"}, + ], + }, + {"name":"tmp411", + "device":[ + {"id":"tmp411_1", "name":"tmp411","bus":39, "loc":0x4c, "attr":"hwmon"}, + {"id":"tmp411_2", "name":"tmp411","bus":40, "loc":0x4c, "attr":"hwmon"}, + ], + }, + ], +} + +CPLDVERSIONS = [ ] +MANUINFO_CONF = { + "bios": { + "key": "BIOS", + "head": True, + "next": "bmc" + }, + "bios_vendor": { + "parent": "bios", + "key": "Vendor", + "cmd": "dmidecode -t 0 |grep Vendor", + "pattern": r".*Vendor", + "separator": ":", + "arrt_index" : 1, + }, + "bios_version": { + "parent": "bios", + "key": "Version", + "cmd": "dmidecode -t 0 |grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "bios_date": { + "parent": "bios", + "key": "Release Date", + "cmd": "dmidecode -t 0 |grep Release", + "pattern": r".*Release Date", + "separator": ":", + "arrt_index" : 3, + }, + + "bmc": { + "key": "BMC", + "next": "onie" + }, + "bmc_version": { + "parent": "bmc", + "key": "Version", + "cmd": "ipmitool mc info |grep \"Firmware Revision\"", + "pattern": r".*Firmware Revision", + "separator": ":", + "arrt_index" : 1, + }, + + "onie": { + "key": "ONIE", + "next": "cpu" + }, + "onie_date": { + "parent": "onie", + "key": "Build Date", + "file": "/host/machine.conf", + "pattern": r"^onie_build_date", + "separator": "=", + "arrt_index" : 1, + }, + "onie_version": { + "parent": "onie", + "key": "Version", + "file": "/host/machine.conf", + "pattern": r"^onie_version", + "separator": "=", + "arrt_index" : 2, + }, + "onie_sub_version": { + "parent": "onie", + "key": "Sub Version", + "file": "/host/machine.conf", + "pattern": r"^onie_sub_version", + "separator": "=", + "arrt_index" : 3, + }, + + "cpu": { + "key": "CPU", + "next": "ssd" + }, + "cpu_vendor": { + "parent": "cpu", + "key": "Vendor", + "cmd": "dmidecode --type processor |grep Manufacturer", + "pattern": r".*Manufacturer", + "separator": ":", + "arrt_index" : 1, + }, + "cpu_model": { + "parent": "cpu", + "key": "Device Model", + "cmd": "dmidecode --type processor | grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "cpu_core": { + "parent": "cpu", + "key": "Core Count", + "cmd": "dmidecode --type processor | grep \"Core Count\"", + "pattern": r".*Core Count", + "separator": ":", + "arrt_index" : 3, + }, + "cpu_thread": { + "parent": "cpu", + "key": "Thread Count", + "cmd": "dmidecode --type processor | grep \"Thread Count\"", + "pattern": r".*Thread Count", + "separator": ":", + "arrt_index" : 4, + }, + + "ssd": { + "key": "SSD", + "next": "cpld" + }, + "ssd_model": { + "parent": "ssd", + "key": "Device Model", + "cmd": "smartctl -i /dev/sda |grep \"Device Model\"", + "pattern": r".*Device Model", + "separator": ":", + "arrt_index" : 1, + }, + "ssd_fw": { + "parent": "ssd", + "key": "Firmware Version", + "cmd": "smartctl -i /dev/sda |grep \"Firmware Version\"", + "pattern": r".*Firmware Version", + "separator": ":", + "arrt_index" : 2, + }, + "ssd_user_cap": { + "parent": "ssd", + "key": "User Capacity", + "cmd": "smartctl -i /dev/sda |grep \"User Capacity\"", + "pattern": r".*User Capacity", + "separator": ":", + "arrt_index" : 3, + }, + + "cpld": { + "key": "CPLD", + "next": "psu" + }, + + "cpld1": { + "key": "CPLD1", + "parent": "cpld", + "arrt_index" : 1, + }, + "cpld1_model": { + "key": "Device Model", + "parent": "cpld1", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld1_vender": { + "key": "Vendor", + "parent": "cpld1", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld1_desc": { + "key": "Description", + "parent": "cpld1", + "config" : "CPU_CPLD", + "arrt_index" : 3, + }, + "cpld1_version": { + "key": "Firmware Version", + "parent": "cpld1", + "reg": { + "loc": "/dev/port", + "offset": 0x700, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld2": { + "key": "CPLD2", + "parent": "cpld", + "arrt_index" : 2, + }, + "cpld2_model": { + "key": "Device Model", + "parent": "cpld2", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld2_vender": { + "key": "Vendor", + "parent": "cpld2", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld2_desc": { + "key": "Description", + "parent": "cpld2", + "config" : "BASE_CPLD", + "arrt_index" : 3, + }, + "cpld2_version": { + "key": "Firmware Version", + "parent": "cpld2", + "reg": { + "loc": "/dev/port", + "offset": 0x900, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld3": { + "key": "CPLD3", + "parent": "cpld", + "arrt_index" : 3, + }, + "cpld3_model": { + "key": "Device Model", + "parent": "cpld3", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld3_vender": { + "key": "Vendor", + "parent": "cpld3", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld3_desc": { + "key": "Description", + "parent": "cpld3", + "config" : "MAC_CPLDA", + "arrt_index" : 3, + }, + "cpld3_version": { + "key": "Firmware Version", + "parent": "cpld3", + "i2c": { + "bus": "2", + "loc": "0x1d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld4": { + "key": "CPLD4", + "parent": "cpld", + "arrt_index" : 4, + }, + "cpld4_model": { + "key": "Device Model", + "parent": "cpld4", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld4_vender": { + "key": "Vendor", + "parent": "cpld4", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld4_desc": { + "key": "Description", + "parent": "cpld4", + "config" : "MAC_CPLDB", + "arrt_index" : 3, + }, + "cpld4_version": { + "key": "Firmware Version", + "parent": "cpld4", + "i2c": { + "bus": "2", + "loc": "0x2d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld5": { + "key": "CPLD5", + "parent": "cpld", + "arrt_index" : 5, + }, + "cpld5_model": { + "key": "Device Model", + "parent": "cpld5", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld5_vender": { + "key": "Vendor", + "parent": "cpld5", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld5_desc": { + "key": "Description", + "parent": "cpld5", + "config" : "FAN_CPLD", + "arrt_index" : 3, + }, + "cpld5_version": { + "key": "Firmware Version", + "parent": "cpld5", + "i2c": { + "bus": "4", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "psu": { + "key": "PSU", + "next": "fan" + }, + + "psu1": { + "parent": "psu", + "key": "PSU1", + "arrt_index" : 1, + }, + "psu1_hw_version": { + "key": "Hardware Version", + "parent": "psu1", + "extra": { + "funcname": "getPsu", + "id": "psu1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu1_fw_version": { + "key": "Firmware Version", + "parent": "psu1", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu2": { + "parent": "psu", + "key": "PSU2", + "arrt_index" : 2, + }, + "psu2_hw_version": { + "key": "Hardware Version", + "parent": "psu2", + "extra": { + "funcname": "getPsu", + "id": "psu2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu2_fw_version": { + "key": "Firmware Version", + "parent": "psu2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan": { + "key": "FAN", + "next": "i210" + }, + + "fan1": { + "key": "FAN1", + "parent": "fan", + "arrt_index" : 1, + }, + "fan1_hw_version": { + "key": "Hardware Version", + "parent": "fan1", + "extra": { + "funcname": "checkFan", + "id": "fan1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan1_fw_version": { + "key": "Firmware Version", + "parent": "fan1", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan2": { + "key": "FAN2", + "parent": "fan", + "arrt_index" : 2, + }, + "fan2_hw_version": { + "key": "Hardware Version", + "parent": "fan2", + "extra": { + "funcname": "checkFan", + "id": "fan2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan2_fw_version": { + "key": "Firmware Version", + "parent": "fan2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan3": { + "key": "FAN3", + "parent": "fan", + "arrt_index" : 3, + }, + "fan3_hw_version": { + "key": "Hardware Version", + "parent": "fan3", + "extra": { + "funcname": "checkFan", + "id": "fan3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan3_fw_version": { + "key": "Firmware Version", + "parent": "fan3", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan4": { + "key": "FAN4", + "parent": "fan", + "arrt_index" : 4, + }, + "fan4_hw_version": { + "key": "Hardware Version", + "parent": "fan4", + "extra": { + "funcname": "checkFan", + "id": "fan4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan4_fw_version": { + "key": "Firmware Version", + "parent": "fan4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan5": { + "key": "FAN5", + "parent": "fan", + "arrt_index" : 5, + }, + "fan5_hw_version": { + "key": "Hardware Version", + "parent": "fan5", + "extra": { + "funcname": "checkFan", + "id": "fan5", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan5_fw_version": { + "key": "Firmware Version", + "parent": "fan5", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan6": { + "key": "FAN6", + "parent": "fan", + "arrt_index" : 6, + }, + "fan6_hw_version": { + "key": "Hardware Version", + "parent": "fan6", + "extra": { + "funcname": "checkFan", + "id": "fan6", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan6_fw_version": { + "key": "Firmware Version", + "parent": "fan6", + "config" : "NA", + "arrt_index" : 2, + }, + + "i210": { + "key": "NIC", + "next": "fpga" + }, + "i210_model": { + "parent": "i210", + "config": "NA", + "key": "Device Model", + "arrt_index" : 1, + }, + "i210_vendor": { + "parent": "i210", + "config": "INTEL", + "key": "Vendor", + "arrt_index" : 2, + }, + "i210_version": { + "parent": "i210", + "cmd": "ethtool -i eth0", + "pattern": r"firmware-version", + "separator": ":", + "key": "Firmware Version", + "arrt_index" : 3, + }, + + "fpga": { + "key": "FPGA", + "next": "others" + }, + "fpga_model": { + "parent": "fpga", + "devfile": { + "loc": "/dev/fpga0", + "offset":0xd8, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga_vendor": { + "parent": "fpga", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga_desc": { + "parent": "fpga", + "config" : "NA", + "key": "Description", + "arrt_index" : 3, + }, + "fpga_hw_version": { + "parent": "fpga", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga_fw_version": { + "parent": "fpga", + "pci": { + "bus" : 8, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "others": { + "key": "OTHERS", + }, + "5387": { + "parent": "others", + "key": "CPU-BMC-SWITCH", + "arrt_index" : 1, + }, + "5387_model": { + "parent": "5387", + "config": "BCM53134O", + "key": "Device Model", + "arrt_index" : 1, + }, + "5387_vendor": { + "parent": "5387", + "config": "Broadcom", + "key": "Vendor", + "arrt_index" : 2, + }, + "5387_hw_version": { + "parent": "5387", + "key": "Hardware Version", + "func": { + "funcname": "get_bcm5387_version", + "params" : { + "before": [ + {"dealtype": "io_wr", "io_addr": 0x94d, "value":0xfe}, + ], + "get_version" : "md5sum /sys/bus/spi/devices/spi0.0/eeprom | awk '{print $1}'", + "finally": [ + {"dealtype": "io_wr", "io_addr": 0x94d, "value":0xff}, + ], + }, + }, + "arrt_index" : 3, + }, +} + +MAC_AVS_PARAM ={ + 0x72:0.90000, + 0x73:0.89375, + 0x74:0.88750, + 0x75:0.88125, + 0x76:0.87500, + 0x77:0.86875, + 0x78:0.86250, + 0x79:0.85625, + 0x7a:0.85000, + 0x7b:0.84375, + 0x7c:0.83750, + 0x7d:0.83125, + 0x7e:0.82500, + 0x7f:0.81875, + 0x80:0.81250, + 0x81:0.80625, + 0x82:0.80000, + 0x83:0.79375, + 0x84:0.78750, + 0x85:0.78125, + 0x86:0.77500, + 0x87:0.76875, + 0x88:0.76250, + 0x89:0.75625, + 0x8A:0.75000, + 0x8B:0.74375, + 0x8C:0.73750, + 0x8D:0.73125, + 0x8E:0.72500, +} + +AVS_VOUT_MODE_PARAM ={ + 0x18:256, # 2^8 + 0x17:512, # 2^9 + 0x16:1024, # 2^10 + 0x15:2048, # 2^11 + 0x14:4096, # 2^12 +} + +MAC_DEFAULT_PARAM = { + "type": 1, + "default":0x82, + "bus":43, + "devno":0x5b, + "loopaddr":0xff, + "loop":0x06, + "vout_cmd_addr":0x42, + "vout_mode_addr":0x40, + "sdktype": 0, + "macregloc":24 , + "mask": 0xff, + "rov_source":0, + "cpld_avs":{"bus":2, "loc":0x2d, "offset":0x3f, "gettype":"i2c"}, + "set_avs": {"loc": "/sys/bus/i2c/devices/43-005b/avs_vout", "gettype": "sysfs", "formula": "int((%f)*1000000)"}, +} + +## +DRIVERLISTS = [ + {"name": "rg_gpio_d1500", "delay": 0}, + {"name": "i2c_dev", "delay": 0}, + {"name": "i2c_gpio", "delay":0}, + {"name": "i2c_mux", "delay":0}, + {"name": "rg_fpga_pcie", "delay": 0}, + {"name": "rg_pcie_dev", "delay": 0}, + {"name": "rg_lpc_drv", "delay": 0}, + {"name": "rg_io_dev", "delay": 0}, + {"name": "rg_i2c_dev", "delay": 0}, + {"name": "rg_fpga_i2c_bus_drv", "delay": 0}, + {"name": "rg_fpga_pca954x_drv", "delay": 0}, + {"name": "rg_wdt", "delay": 0}, + {"name": "rg_gpio_device", "delay": 0}, + {"name": "rg_i2c_gpio_device", "delay":0}, + {"name": "rg_pcie_dev_device", "delay": 0}, + {"name": "rg_lpc_drv_device", "delay": 0}, + {"name": "rg_io_dev_device", "delay": 0}, + {"name": "rg_fpga_i2c_bus_device", "delay": 0}, + {"name": "rg_fpga_pca954x_device", "delay": 0}, + {"name": "rg_i2c_dev_device", "delay": 0}, + {"name": "rg_wdt_device", "delay": 0}, + {"name": "ruijie_common dfd_my_type_i2c_bus=1 dfd_my_type_i2c_addr=0x56", "delay": 1}, + {"name": "rg_spi_gpio_device", "delay": 0}, + {"name": "rg_eeprom_93xx46", "delay": 0}, + {"name": "lm75", "delay":0}, + {"name": "tmp401", "delay":0}, + {"name": "rg_optoe", "delay": 0}, + {"name": "at24", "delay": 0}, + {"name": "rg_mac_bsc", "delay": 0}, + {"name": "rg_pmbus_core", "delay":0}, + {"name": "rg_csu550", "delay": 0}, + {"name": "rg_ina3221", "delay": 0}, + {"name": "rg_tps53622", "delay": 0}, + {"name": "rg_ucd9000", "delay": 0}, + {"name": "rg_xdpe132g5c", "delay": 0}, + {"name": "s3ip_sysfs", "delay": 0}, + {"name": "rg_switch_driver", "delay": 0}, + {"name": "syseeprom_device_driver", "delay": 0}, + {"name": "fan_device_driver", "delay": 0}, + {"name": "cpld_device_driver", "delay": 0}, + {"name": "sysled_device_driver", "delay": 0}, + {"name": "psu_device_driver", "delay": 0}, + {"name": "transceiver_device_driver", "delay": 0}, + {"name": "temp_sensor_device_driver", "delay": 0}, + {"name": "vol_sensor_device_driver", "delay": 0}, + {"name": "curr_sensor_device_driver", "delay": 0}, + {"name": "fpga_device_driver", "delay": 0}, + {"name": "watchdog_device_driver", "delay": 0}, + {"name": "rg_plat_dfd", "delay":0}, + {"name": "rg_plat_switch", "delay":0}, + {"name": "rg_plat_fan", "delay":0}, + {"name": "rg_plat_psu", "delay":0}, + {"name": "rg_plat_sff", "delay":0}, +] + +DEVICE = [ + {"name": "24c02","bus":1,"loc":0x56 }, + {"name": "rg_mac_bsc_td4","bus":44,"loc":0x44 }, + {"name": "24c64","bus":30,"loc":0x50 }, + {"name": "24c64","bus":31,"loc":0x50 }, + {"name": "24c64","bus":32,"loc":0x50 }, + {"name": "24c64","bus":33,"loc":0x50 }, + {"name": "24c64","bus":34,"loc":0x50 }, + {"name": "24c64","bus":35,"loc":0x50 }, + {"name": "24c02", "bus":41, "loc":0x50}, + {"name":"rg_fsp1200","bus":41, "loc":0x58 }, + {"name": "24c02", "bus":42, "loc": 0x50}, + {"name":"rg_fsp1200","bus":42, "loc":0x58 }, + {"name": "lm75", "bus": 36, "loc": 0x48}, + {"name": "lm75", "bus": 36, "loc": 0x49}, + {"name": "lm75", "bus": 39, "loc": 0x4b}, + {"name": "tmp411", "bus": 39, "loc": 0x4c}, + {"name": "tmp411", "bus": 40, "loc": 0x4c}, + {"name": "lm75", "bus": 40, "loc": 0x4e}, + {"name": "lm75", "bus": 40, "loc": 0x4f}, + # dcdc + {"name": "rg_ucd90160", "bus": 24, "loc": 0x5b}, + {"name": "rg_ucd90160", "bus": 45, "loc": 0x5b}, + {"name": "rg_ina3221", "bus": 25, "loc": 0x43}, + {"name": "rg_tps53622", "bus": 25, "loc": 0x60}, + {"name": "rg_tps53622", "bus": 25, "loc": 0x6c}, + # xdpe avs + {"name": "rg_xdpe132g5c", "bus": 43, "loc": 0x5b}, +] + +OPTOE = [ + {"name": "rg_optoe1", "startbus": 46, "endbus": 69}, + {"name": "rg_optoe3", "startbus": 70, "endbus": 77}, +] + +PMON_SYSLOG_STATUS = { + "polling_time": 3, + "sffs": { + "present": {"path": ["/sys/s3ip/transceiver/*/present"], "ABSENT":0}, + "nochangedmsgflag": 0, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 1, + "alias": { + "eth1": "Eth200GE1", + "eth2": "Eth200GE2", + "eth3": "Eth200GE3", + "eth4": "Eth200GE4", + "eth5": "Eth200GE5", + "eth6": "Eth200GE6", + "eth7": "Eth200GE7", + "eth8": "Eth200GE8", + "eth9": "Eth200GE9", + "eth10": "Eth200GE10", + "eth11": "Eth200GE11", + "eth12": "Eth200GE12", + "eth13": "Eth200GE13", + "eth14": "Eth200GE14", + "eth15": "Eth200GE15", + "eth16": "Eth200GE16", + "eth17": "Eth200GE17", + "eth18": "Eth200GE18", + "eth19": "Eth200GE19", + "eth20": "Eth200GE20", + "eth21": "Eth200GE21", + "eth22": "Eth200GE22", + "eth23": "Eth200GE23", + "eth24": "Eth200GE24", + "eth25": "Eth400GE25", + "eth26": "Eth400GE26", + "eth27": "Eth400GE27", + "eth28": "Eth400GE28", + "eth29": "Eth400GE29", + "eth30": "Eth400GE30", + "eth31": "Eth400GE31", + "eth32": "Eth400GE32", + } + }, + "fans": { + "present": {"path": ["/sys/s3ip/fan/*/status"], "ABSENT":0}, + "status": [ + {"path": "/sys/s3ip/fan/%s/status", 'okval': 1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "psus": { + "present" : {"path": ["/sys/s3ip/psu/*/present"], "ABSENT":0}, + "status" : [ + {"path": "/sys/s3ip/psu/%s/out_status", "okval":1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "temps": { + "temps_list":[ + {"name":"air_inlet_TL", "input_path":"/sys/bus/i2c/devices/40-004f/hwmon/*/temp1_input", "input_accuracy":1000, "warning":43, "critical":53}, + {"name":"air_outlet_L", "input_path":"/sys/bus/i2c/devices/36-0048/hwmon/*/temp1_input", "input_accuracy":1000, "warning":70, "critical":75}, + {"name":"CPU_TEMP", "input_path":"/sys/devices/platform/coretemp.0/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":102}, + {"name":"SWITCH_TEMP", "input_path":"/sys/bus/i2c/devices/44-0044/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":105}, + ], + "over_temps_polling_seconds": 60, + }, +} + +INIT_PARAM = [ ] +INIT_COMMAND = [ + "i2cset -f -y 2 0x2d 0x45 0xff", + "i2cset -f -y 2 0x2d 0x46 0xff", + "i2cset -f -y 2 0x2d 0x34 0xff", + "i2cset -f -y 2 0x2d 0x35 0xff", + "i2cset -f -y 2 0x1d 0x39 0xff", + "i2cset -f -y 2 0x1d 0x3a 0xff", + "i2cset -f -y 2 0x2d 0x3a 0xff", + "i2cset -f -y 2 0x1d 0x3b 0xff", +] + +INIT_PARAM_PRE = [ + {"loc":"43-005b/avs_vout_max","value": "900000"}, + {"loc":"43-005b/avs_vout_min","value": "725000"}, +] +INIT_COMMAND_PRE = [ ] diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_config.py new file mode 100755 index 000000000000..a1a0b17752d6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_config.py @@ -0,0 +1,975 @@ +#!/usr/bin/python3 +from ruijiecommon import * + + +STARTMODULE = { + "xdpe_avscontrol":1, + "dev_monitor": 1, + "hal_fanctrl":1, + "hal_ledctrl":1, + "sff_temp_polling":1, + "rg_pmon_syslog":1, +} + +DEV_MONITOR_PARAM = { + "polling_time" : 10, + "psus": [ + {"name": "psu1", + "present": {"gettype": "i2c", "bus": 2, "loc": 0x1d, "offset": 0x34, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu1pmbus", "name": "rg_fsp1200", "bus": 41, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu1frue2", "name": "24c02", "bus": 41, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu2", + "present": {"gettype": "i2c", "bus": 2, "loc": 0x1d, "offset": 0x34, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu2pmbus", "name": "rg_fsp1200", "bus": 42, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu2frue2", "name": "24c02", "bus": 42, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "fans": [ + {"name": "fan1", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 5, "okval": 0}, + "device": [ + {"id": "fan1frue2", "name": "24c64", "bus": 35, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan2", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "fan2frue2", "name": "24c64", "bus": 34, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan3", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan3frue2", "name": "24c64", "bus": 33, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan4", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan4frue2", "name": "24c64", "bus": 32, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan5", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan5frue2", "name": "24c64", "bus": 31, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan6", + "present": {"gettype": "i2c", "bus": 4, "loc": 0x3d, "offset": 0x37, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan6frue2", "name": "24c64", "bus": 30, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "others": [ + {"name":"eeprom", + "device":[ + {"id":"eeprom_1", "name":"24c02","bus":1, "loc":0x56, "attr":"eeprom"}, + ], + }, + {"name":"lm75", + "device":[ + {"id":"lm75_1", "name":"lm75","bus":36, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_2", "name":"lm75","bus":36, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_3", "name":"lm75","bus":39, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_4", "name":"lm75","bus":40, "loc":0x4e, "attr":"hwmon"}, + {"id":"lm75_5", "name":"lm75","bus":40, "loc":0x4f, "attr":"hwmon"}, + ], + }, + {"name":"mac_bsc", + "device":[ + {"id":"mac_bsc_1", "name":"rg_mac_bsc_td4","bus":44, "loc":0x44, "attr":"hwmon"}, + ], + }, + {"name":"ina3221", + "device":[ + {"id":"ina3221_1", "name":"rg_ina3221","bus":25, "loc":0x43, "attr":"hwmon"}, + ], + }, + {"name":"tps53622", + "device":[ + {"id":"tps53622_1", "name":"rg_tps53622","bus":25, "loc":0x60, "attr":"hwmon"}, + {"id":"tps53622_2", "name":"rg_tps53622","bus":25, "loc":0x6c, "attr":"hwmon"}, + ], + }, + {"name":"ucd90160", + "device":[ + {"id":"ucd90160_1", "name":"rg_ucd90160","bus":24, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_2", "name":"rg_ucd90160","bus":45, "loc":0x5b, "attr":"hwmon"}, + ], + }, + {"name":"tmp411", + "device":[ + {"id":"tmp411_1", "name":"tmp411","bus":39, "loc":0x4c, "attr":"hwmon"}, + {"id":"tmp411_2", "name":"tmp411","bus":40, "loc":0x4c, "attr":"hwmon"}, + ], + }, + ], +} + +CPLDVERSIONS = [ ] +MANUINFO_CONF = { + "bios": { + "key": "BIOS", + "head": True, + "next": "bmc" + }, + "bios_vendor": { + "parent": "bios", + "key": "Vendor", + "cmd": "dmidecode -t 0 |grep Vendor", + "pattern": r".*Vendor", + "separator": ":", + "arrt_index" : 1, + }, + "bios_version": { + "parent": "bios", + "key": "Version", + "cmd": "dmidecode -t 0 |grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "bios_date": { + "parent": "bios", + "key": "Release Date", + "cmd": "dmidecode -t 0 |grep Release", + "pattern": r".*Release Date", + "separator": ":", + "arrt_index" : 3, + }, + + "bmc": { + "key": "BMC", + "next": "onie" + }, + "bmc_version": { + "parent": "bmc", + "key": "Version", + "cmd": "ipmitool mc info |grep \"Firmware Revision\"", + "pattern": r".*Firmware Revision", + "separator": ":", + "arrt_index" : 1, + }, + + "onie": { + "key": "ONIE", + "next": "cpu" + }, + "onie_date": { + "parent": "onie", + "key": "Build Date", + "file": "/host/machine.conf", + "pattern": r"^onie_build_date", + "separator": "=", + "arrt_index" : 1, + }, + "onie_version": { + "parent": "onie", + "key": "Version", + "file": "/host/machine.conf", + "pattern": r"^onie_version", + "separator": "=", + "arrt_index" : 2, + }, + "onie_sub_version": { + "parent": "onie", + "key": "Sub Version", + "file": "/host/machine.conf", + "pattern": r"^onie_sub_version", + "separator": "=", + "arrt_index" : 3, + }, + + "cpu": { + "key": "CPU", + "next": "ssd" + }, + "cpu_vendor": { + "parent": "cpu", + "key": "Vendor", + "cmd": "dmidecode --type processor |grep Manufacturer", + "pattern": r".*Manufacturer", + "separator": ":", + "arrt_index" : 1, + }, + "cpu_model": { + "parent": "cpu", + "key": "Device Model", + "cmd": "dmidecode --type processor | grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "cpu_core": { + "parent": "cpu", + "key": "Core Count", + "cmd": "dmidecode --type processor | grep \"Core Count\"", + "pattern": r".*Core Count", + "separator": ":", + "arrt_index" : 3, + }, + "cpu_thread": { + "parent": "cpu", + "key": "Thread Count", + "cmd": "dmidecode --type processor | grep \"Thread Count\"", + "pattern": r".*Thread Count", + "separator": ":", + "arrt_index" : 4, + }, + + "ssd": { + "key": "SSD", + "next": "cpld" + }, + "ssd_model": { + "parent": "ssd", + "key": "Device Model", + "cmd": "smartctl -i /dev/sda |grep \"Device Model\"", + "pattern": r".*Device Model", + "separator": ":", + "arrt_index" : 1, + }, + "ssd_fw": { + "parent": "ssd", + "key": "Firmware Version", + "cmd": "smartctl -i /dev/sda |grep \"Firmware Version\"", + "pattern": r".*Firmware Version", + "separator": ":", + "arrt_index" : 2, + }, + "ssd_user_cap": { + "parent": "ssd", + "key": "User Capacity", + "cmd": "smartctl -i /dev/sda |grep \"User Capacity\"", + "pattern": r".*User Capacity", + "separator": ":", + "arrt_index" : 3, + }, + + "cpld": { + "key": "CPLD", + "next": "psu" + }, + + "cpld1": { + "key": "CPLD1", + "parent": "cpld", + "arrt_index" : 1, + }, + "cpld1_model": { + "key": "Device Model", + "parent": "cpld1", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld1_vender": { + "key": "Vendor", + "parent": "cpld1", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld1_desc": { + "key": "Description", + "parent": "cpld1", + "config" : "CPU_CPLD", + "arrt_index" : 3, + }, + "cpld1_version": { + "key": "Firmware Version", + "parent": "cpld1", + "reg": { + "loc": "/dev/port", + "offset": 0x700, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld2": { + "key": "CPLD2", + "parent": "cpld", + "arrt_index" : 2, + }, + "cpld2_model": { + "key": "Device Model", + "parent": "cpld2", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld2_vender": { + "key": "Vendor", + "parent": "cpld2", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld2_desc": { + "key": "Description", + "parent": "cpld2", + "config" : "BASE_CPLD", + "arrt_index" : 3, + }, + "cpld2_version": { + "key": "Firmware Version", + "parent": "cpld2", + "reg": { + "loc": "/dev/port", + "offset": 0x900, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld3": { + "key": "CPLD3", + "parent": "cpld", + "arrt_index" : 3, + }, + "cpld3_model": { + "key": "Device Model", + "parent": "cpld3", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld3_vender": { + "key": "Vendor", + "parent": "cpld3", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld3_desc": { + "key": "Description", + "parent": "cpld3", + "config" : "MAC_CPLDA", + "arrt_index" : 3, + }, + "cpld3_version": { + "key": "Firmware Version", + "parent": "cpld3", + "i2c": { + "bus": "2", + "loc": "0x1d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld4": { + "key": "CPLD4", + "parent": "cpld", + "arrt_index" : 4, + }, + "cpld4_model": { + "key": "Device Model", + "parent": "cpld4", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld4_vender": { + "key": "Vendor", + "parent": "cpld4", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld4_desc": { + "key": "Description", + "parent": "cpld4", + "config" : "MAC_CPLDB", + "arrt_index" : 3, + }, + "cpld4_version": { + "key": "Firmware Version", + "parent": "cpld4", + "i2c": { + "bus": "2", + "loc": "0x2d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld5": { + "key": "CPLD5", + "parent": "cpld", + "arrt_index" : 5, + }, + "cpld5_model": { + "key": "Device Model", + "parent": "cpld5", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld5_vender": { + "key": "Vendor", + "parent": "cpld5", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld5_desc": { + "key": "Description", + "parent": "cpld5", + "config" : "FAN_CPLD", + "arrt_index" : 3, + }, + "cpld5_version": { + "key": "Firmware Version", + "parent": "cpld5", + "i2c": { + "bus": "4", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "psu": { + "key": "PSU", + "next": "fan" + }, + + "psu1": { + "parent": "psu", + "key": "PSU1", + "arrt_index" : 1, + }, + "psu1_hw_version": { + "key": "Hardware Version", + "parent": "psu1", + "extra": { + "funcname": "getPsu", + "id": "psu1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu1_fw_version": { + "key": "Firmware Version", + "parent": "psu1", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu2": { + "parent": "psu", + "key": "PSU2", + "arrt_index" : 2, + }, + "psu2_hw_version": { + "key": "Hardware Version", + "parent": "psu2", + "extra": { + "funcname": "getPsu", + "id": "psu2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu2_fw_version": { + "key": "Firmware Version", + "parent": "psu2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan": { + "key": "FAN", + "next": "i210" + }, + + "fan1": { + "key": "FAN1", + "parent": "fan", + "arrt_index" : 1, + }, + "fan1_hw_version": { + "key": "Hardware Version", + "parent": "fan1", + "extra": { + "funcname": "checkFan", + "id": "fan1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan1_fw_version": { + "key": "Firmware Version", + "parent": "fan1", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan2": { + "key": "FAN2", + "parent": "fan", + "arrt_index" : 2, + }, + "fan2_hw_version": { + "key": "Hardware Version", + "parent": "fan2", + "extra": { + "funcname": "checkFan", + "id": "fan2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan2_fw_version": { + "key": "Firmware Version", + "parent": "fan2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan3": { + "key": "FAN3", + "parent": "fan", + "arrt_index" : 3, + }, + "fan3_hw_version": { + "key": "Hardware Version", + "parent": "fan3", + "extra": { + "funcname": "checkFan", + "id": "fan3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan3_fw_version": { + "key": "Firmware Version", + "parent": "fan3", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan4": { + "key": "FAN4", + "parent": "fan", + "arrt_index" : 4, + }, + "fan4_hw_version": { + "key": "Hardware Version", + "parent": "fan4", + "extra": { + "funcname": "checkFan", + "id": "fan4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan4_fw_version": { + "key": "Firmware Version", + "parent": "fan4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan5": { + "key": "FAN5", + "parent": "fan", + "arrt_index" : 5, + }, + "fan5_hw_version": { + "key": "Hardware Version", + "parent": "fan5", + "extra": { + "funcname": "checkFan", + "id": "fan5", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan5_fw_version": { + "key": "Firmware Version", + "parent": "fan5", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan6": { + "key": "FAN6", + "parent": "fan", + "arrt_index" : 6, + }, + "fan6_hw_version": { + "key": "Hardware Version", + "parent": "fan6", + "extra": { + "funcname": "checkFan", + "id": "fan6", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan6_fw_version": { + "key": "Firmware Version", + "parent": "fan6", + "config" : "NA", + "arrt_index" : 2, + }, + + "i210": { + "key": "NIC", + "next": "fpga" + }, + "i210_model": { + "parent": "i210", + "config": "NA", + "key": "Device Model", + "arrt_index" : 1, + }, + "i210_vendor": { + "parent": "i210", + "config": "INTEL", + "key": "Vendor", + "arrt_index" : 2, + }, + "i210_version": { + "parent": "i210", + "cmd": "ethtool -i eth0", + "pattern": r"firmware-version", + "separator": ":", + "key": "Firmware Version", + "arrt_index" : 3, + }, + + "fpga": { + "key": "FPGA", + "next": "others" + }, + "fpga_model": { + "parent": "fpga", + "devfile": { + "loc": "/dev/fpga0", + "offset":0xd8, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga_vendor": { + "parent": "fpga", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga_desc": { + "parent": "fpga", + "config" : "NA", + "key": "Description", + "arrt_index" : 3, + }, + "fpga_hw_version": { + "parent": "fpga", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga_fw_version": { + "parent": "fpga", + "pci": { + "bus" : 8, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "others": { + "key": "OTHERS", + }, + "5387": { + "parent": "others", + "key": "CPU-BMC-SWITCH", + "arrt_index" : 1, + }, + "5387_model": { + "parent": "5387", + "config": "BCM5387", + "key": "Device Model", + "arrt_index" : 1, + }, + "5387_vendor": { + "parent": "5387", + "config": "Broadcom", + "key": "Vendor", + "arrt_index" : 2, + }, + "5387_hw_version": { + "parent": "5387", + "key": "Hardware Version", + "func": { + "funcname": "get_bcm5387_version", + "params" : { + "before": [ + {"dealtype": "io_wr", "io_addr": 0x94d, "value":0xfe}, + ], + "get_version" : "md5sum /sys/bus/spi/devices/spi0.0/eeprom | awk '{print $1}'", + "finally": [ + {"dealtype": "io_wr", "io_addr": 0x94d, "value":0xff}, + ], + }, + }, + "arrt_index" : 3, + }, +} + +MAC_AVS_PARAM ={ + 0x72:0.90000, + 0x73:0.89375, + 0x74:0.88750, + 0x75:0.88125, + 0x76:0.87500, + 0x77:0.86875, + 0x78:0.86250, + 0x79:0.85625, + 0x7a:0.85000, + 0x7b:0.84375, + 0x7c:0.83750, + 0x7d:0.83125, + 0x7e:0.82500, + 0x7f:0.81875, + 0x80:0.81250, + 0x81:0.80625, + 0x82:0.80000, + 0x83:0.79375, + 0x84:0.78750, + 0x85:0.78125, + 0x86:0.77500, + 0x87:0.76875, + 0x88:0.76250, + 0x89:0.75625, + 0x8A:0.75000, + 0x8B:0.74375, + 0x8C:0.73750, + 0x8D:0.73125, + 0x8E:0.72500, +} + +AVS_VOUT_MODE_PARAM ={ + 0x18:256, # 2^8 + 0x17:512, # 2^9 + 0x16:1024, # 2^10 + 0x15:2048, # 2^11 + 0x14:4096, # 2^12 +} + +MAC_DEFAULT_PARAM = { + "type": 1, + "default":0x82, + "bus":43, + "devno":0x5b, + "loopaddr":0xff, + "loop":0x06, + "vout_cmd_addr":0x42, + "vout_mode_addr":0x40, + "sdktype": 0, + "macregloc":24 , + "mask": 0xff, + "rov_source":0, + "cpld_avs":{"bus":2, "loc":0x2d, "offset":0x3f, "gettype":"i2c"}, + "set_avs": {"loc": "/sys/bus/i2c/devices/43-005b/avs_vout", "gettype": "sysfs", "formula": "int((%f)*1000000)"}, +} + +## +DRIVERLISTS = [ + {"name": "rg_gpio_d1500", "delay": 0}, + {"name": "i2c_dev", "delay": 0}, + {"name": "i2c_gpio", "delay":0}, + {"name": "i2c_mux", "delay":0}, + {"name": "rg_fpga_pcie", "delay": 0}, + {"name": "rg_pcie_dev", "delay": 0}, + {"name": "rg_lpc_drv", "delay": 0}, + {"name": "rg_io_dev", "delay": 0}, + {"name": "rg_i2c_dev", "delay": 0}, + {"name": "rg_fpga_i2c_bus_drv", "delay": 0}, + {"name": "rg_fpga_pca954x_drv", "delay": 0}, + {"name": "rg_wdt", "delay": 0}, + {"name": "rg_gpio_device", "delay": 0}, + {"name": "rg_i2c_gpio_device", "delay":0}, + {"name": "rg_pcie_dev_device", "delay": 0}, + {"name": "rg_lpc_drv_device", "delay": 0}, + {"name": "rg_io_dev_device", "delay": 0}, + {"name": "rg_fpga_i2c_bus_device", "delay": 0}, + {"name": "rg_fpga_pca954x_device", "delay": 0}, + {"name": "rg_i2c_dev_device", "delay": 0}, + {"name": "rg_wdt_device", "delay": 0}, + {"name": "ruijie_common dfd_my_type_i2c_bus=1 dfd_my_type_i2c_addr=0x56", "delay": 1}, + {"name": "rg_spi_gpio_device", "delay": 0}, + {"name": "rg_eeprom_93xx46", "delay": 0}, + {"name": "lm75", "delay":0}, + {"name": "tmp401", "delay":0}, + {"name": "rg_optoe", "delay": 0}, + {"name": "at24", "delay": 0}, + {"name": "rg_mac_bsc", "delay": 0}, + {"name": "rg_pmbus_core", "delay":0}, + {"name": "rg_csu550", "delay": 0}, + {"name": "rg_ina3221", "delay": 0}, + {"name": "rg_tps53622", "delay": 0}, + {"name": "rg_ucd9000", "delay": 0}, + {"name": "rg_xdpe132g5c", "delay": 0}, + {"name": "s3ip_sysfs", "delay": 0}, + {"name": "rg_switch_driver", "delay": 0}, + {"name": "syseeprom_device_driver", "delay": 0}, + {"name": "fan_device_driver", "delay": 0}, + {"name": "cpld_device_driver", "delay": 0}, + {"name": "sysled_device_driver", "delay": 0}, + {"name": "psu_device_driver", "delay": 0}, + {"name": "transceiver_device_driver", "delay": 0}, + {"name": "temp_sensor_device_driver", "delay": 0}, + {"name": "vol_sensor_device_driver", "delay": 0}, + {"name": "curr_sensor_device_driver", "delay": 0}, + {"name": "fpga_device_driver", "delay": 0}, + {"name": "watchdog_device_driver", "delay": 0}, + {"name": "rg_plat_dfd", "delay":0}, + {"name": "rg_plat_switch", "delay":0}, + {"name": "rg_plat_fan", "delay":0}, + {"name": "rg_plat_psu", "delay":0}, + {"name": "rg_plat_sff", "delay":0}, +] + +DEVICE = [ + {"name": "24c02","bus":1,"loc":0x56 }, + {"name": "rg_mac_bsc_td4","bus":44,"loc":0x44 }, + {"name": "24c64","bus":30,"loc":0x50 }, + {"name": "24c64","bus":31,"loc":0x50 }, + {"name": "24c64","bus":32,"loc":0x50 }, + {"name": "24c64","bus":33,"loc":0x50 }, + {"name": "24c64","bus":34,"loc":0x50 }, + {"name": "24c64","bus":35,"loc":0x50 }, + {"name": "24c02", "bus":41, "loc":0x50}, + {"name":"rg_fsp1200","bus":41, "loc":0x58 }, + {"name": "24c02", "bus":42, "loc": 0x50}, + {"name":"rg_fsp1200","bus":42, "loc":0x58 }, + {"name": "lm75", "bus": 36, "loc": 0x48}, + {"name": "lm75", "bus": 36, "loc": 0x49}, + {"name": "lm75", "bus": 39, "loc": 0x4b}, + {"name": "tmp411", "bus": 39, "loc": 0x4c}, + {"name": "tmp411", "bus": 40, "loc": 0x4c}, + {"name": "lm75", "bus": 40, "loc": 0x4e}, + {"name": "lm75", "bus": 40, "loc": 0x4f}, + # dcdc + {"name": "rg_ucd90160", "bus": 24, "loc": 0x5b}, + {"name": "rg_ucd90160", "bus": 45, "loc": 0x5b}, + {"name": "rg_ina3221", "bus": 25, "loc": 0x43}, + {"name": "rg_tps53622", "bus": 25, "loc": 0x60}, + {"name": "rg_tps53622", "bus": 25, "loc": 0x6c}, + # xdpe avs + {"name": "rg_xdpe132g5c", "bus": 43, "loc": 0x5b}, +] + +OPTOE = [ + {"name": "rg_optoe1", "startbus": 46, "endbus": 69}, + {"name": "rg_optoe3", "startbus": 70, "endbus": 77}, +] + +PMON_SYSLOG_STATUS = { + "polling_time": 3, + "sffs": { + "present": {"path": ["/sys/s3ip/transceiver/*/present"], "ABSENT":0}, + "nochangedmsgflag": 0, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 1, + "alias": { + "eth1": "Eth200GE1", + "eth2": "Eth200GE2", + "eth3": "Eth200GE3", + "eth4": "Eth200GE4", + "eth5": "Eth200GE5", + "eth6": "Eth200GE6", + "eth7": "Eth200GE7", + "eth8": "Eth200GE8", + "eth9": "Eth200GE9", + "eth10": "Eth200GE10", + "eth11": "Eth200GE11", + "eth12": "Eth200GE12", + "eth13": "Eth200GE13", + "eth14": "Eth200GE14", + "eth15": "Eth200GE15", + "eth16": "Eth200GE16", + "eth17": "Eth200GE17", + "eth18": "Eth200GE18", + "eth19": "Eth200GE19", + "eth20": "Eth200GE20", + "eth21": "Eth200GE21", + "eth22": "Eth200GE22", + "eth23": "Eth200GE23", + "eth24": "Eth200GE24", + "eth25": "Eth400GE25", + "eth26": "Eth400GE26", + "eth27": "Eth400GE27", + "eth28": "Eth400GE28", + "eth29": "Eth400GE29", + "eth30": "Eth400GE30", + "eth31": "Eth400GE31", + "eth32": "Eth400GE32", + } + }, + "fans": { + "present": {"path": ["/sys/s3ip/fan/*/status"], "ABSENT":0}, + "status": [ + {"path": "/sys/s3ip/fan/%s/status", 'okval': 1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "psus": { + "present" : {"path": ["/sys/s3ip/psu/*/present"], "ABSENT":0}, + "status" : [ + {"path": "/sys/s3ip/psu/%s/out_status", "okval":1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "temps": { + "temps_list":[ + {"name":"air_inlet_TL", "input_path":"/sys/bus/i2c/devices/40-004f/hwmon/*/temp1_input", "input_accuracy":1000, "warning":43, "critical":53}, + {"name":"air_outlet_L", "input_path":"/sys/bus/i2c/devices/36-0048/hwmon/*/temp1_input", "input_accuracy":1000, "warning":70, "critical":75}, + {"name":"CPU_TEMP", "input_path":"/sys/devices/platform/coretemp.0/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":102}, + {"name":"SWITCH_TEMP", "input_path":"/sys/bus/i2c/devices/44-0044/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":105}, + ], + "over_temps_polling_seconds": 60, + }, +} + +INIT_PARAM = [ ] +INIT_COMMAND = [ + "i2cset -f -y 2 0x2d 0x45 0xff", + "i2cset -f -y 2 0x2d 0x46 0xff", + "i2cset -f -y 2 0x2d 0x34 0xff", + "i2cset -f -y 2 0x2d 0x35 0xff", + "i2cset -f -y 2 0x1d 0x39 0xff", + "i2cset -f -y 2 0x1d 0x3a 0xff", + "i2cset -f -y 2 0x2d 0x3a 0xff", + "i2cset -f -y 2 0x1d 0x3b 0xff", +] + +INIT_PARAM_PRE = [ + {"loc":"43-005b/avs_vout_max","value": "900000"}, + {"loc":"43-005b/avs_vout_min","value": "725000"}, +] +INIT_COMMAND_PRE = [ ] diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_port_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_port_config.py new file mode 100755 index 000000000000..e75633f5d701 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/config/x86_64_tencent_tcs8400_r0_port_config.py @@ -0,0 +1,6 @@ +#!/usr/bin/python3 + +PLATFORM_INTF_OPTOE = { + "port_num": 32, + "optoe_start_bus": 46, +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_0x407b_device.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_0x407b_device.py new file mode 100755 index 000000000000..76174fd8a9c7 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_0x407b_device.py @@ -0,0 +1,1108 @@ +#!/usr/bin/python3 + +psu_fan_airflow = { + "F2B": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "B2F": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +psu_display_name = { + "PSA1300CRPS-F": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "PSA1300CRPS-R": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +fanairflow = { + "F2B": ["FAN24K4056-F", "FAN24K4056S-F"], + "B2F": ["FAN24K4056S-R"], +} + +fan_display_name = { + "FAN24K4056-F": ["FAN24K4056-F", "FAN24K4056S-F"], + "FAN24K4056-R": ["FAN24K4056S-R"] +} + +psutypedecode = { + 0x00: 'N/A', + 0x01: 'AC', + 0x02: 'DC', +} + + +class Unit: + Temperature = "C" + Voltage = "V" + Current = "A" + Power = "W" + Speed = "RPM" + + +PSU_NOT_PRESENT_PWM = 100 + + +class threshold: + PSU_TEMP_MIN = -10 * 1000 + PSU_TEMP_MAX = 60 * 1000 + + PSU_FAN_SPEED_MIN = 2000 + PSU_FAN_SPEED_MAX = 28000 + + PSU_OUTPUT_VOLTAGE_MIN = 11 * 1000 + PSU_OUTPUT_VOLTAGE_MAX = 14 * 1000 + + PSU_AC_INPUT_VOLTAGE_MIN = 200 * 1000 + PSU_AC_INPUT_VOLTAGE_MAX = 240 * 1000 + + PSU_DC_INPUT_VOLTAGE_MIN = 190 * 1000 + PSU_DC_INPUT_VOLTAGE_MAX = 290 * 1000 + + ERR_VALUE = -9999999 + + PSU_OUTPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_OUTPUT_POWER_MAX = 1300 * 1000 * 1000 + + PSU_INPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_INPUT_POWER_MAX = 1444 * 1000 * 1000 + + PSU_OUTPUT_CURRENT_MIN = 2 * 1000 + PSU_OUTPUT_CURRENT_MAX = 107 * 1000 + + PSU_INPUT_CURRENT_MIN = 0.2 * 1000 + PSU_INPUT_CURRENT_MAX = 7 * 1000 + + FRONT_FAN_SPEED_MAX = 25000 + REAR_FAN_SPEED_MAX = 22000 + FAN_SPEED_MIN = 2000 + + +class Description: + CPLD = "Used for managing IO modules, SFP+ modules and system LEDs" + BIOS = "Performs initialization of hardware components during booting" + FPGA = "Platform management controller for on-board temperature monitoring, in-chassis power" + + +devices = { + "onie_e2": [ + { + "name": "ONIE_E2", + "e2loc": {"loc": "/sys/bus/i2c/devices/1-0056/eeprom", "way": "sysfs"}, + }, + ], + "psus": [ + { + "e2loc": {"loc": "/sys/bus/i2c/devices/41-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 41, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu1/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU1", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 41, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/42-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 42, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu2/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU2", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 42, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + } + ], + "temps": [ + { + "name": "BOARD_TEMP", + "temp_id": "TEMP1", + "api_name": "Board", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/40-004e/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 80000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "CPU_TEMP", + "temp_id": "TEMP2", + "api_name": "CPU", + "Temperature": { + "value": {"loc": "/sys/bus/platform/devices/coretemp.0/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 104000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "INLET_TEMP", + "temp_id": "TEMP3", + "api_name": "Inlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/40-004f/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 40000, + "Max": 50000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "OUTLET_TEMP", + "temp_id": "TEMP4", + "api_name": "Outlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/36-0048/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 80000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SWITCH_TEMP", + "temp_id": "TEMP5", + "api_name": "Switch ASIC", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/44-0044/hwmon/hwmon*/temp99_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 105000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SFF_TEMP", + "Temperature": { + "value": {"loc": "/tmp/highest_sff_temp", "way": "sysfs", "flock_path": "/tmp/highest_sff_temp"}, + "Min": -15000, + "Low": 0, + "High": 80000, + "Max": 100000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + ], + "leds": [ + { + "name": "FRONT_SYS_LED", + "led_type": "SYS_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x40, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_PSU_LED", + "led_type": "PSU_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x43, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_FAN_LED", + "led_type": "FAN_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x42, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + ], + "fans": [ + { + "name": "FAN1", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-35/35-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x41, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x65, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x20, "is_runing": 0x20}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x20, "no_alarm": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x65, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x20, "is_runing": 0x20}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x20, "no_alarm": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN2", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-34/34-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x40, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x64, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x10, "is_runing": 0x10}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x10, "no_alarm": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x64, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x10, "is_runing": 0x10}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x10, "no_alarm": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN3", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-33/33-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3f, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x63, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x08, "is_runing": 0x08}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x08, "no_alarm": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x63, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x08, "is_runing": 0x08}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x08, "no_alarm": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN4", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-32/32-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x62, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x04, "is_runing": 0x04}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x04, "no_alarm": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x62, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x04, "is_runing": 0x04}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x04, "no_alarm": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN5", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-31/31-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x61, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x02, "is_runing": 0x02}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x02, "no_alarm": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x61, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x02, "is_runing": 0x02}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x02, "no_alarm": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN6", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-30/30-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x60, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x01, "is_runing": 0x01}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x01, "no_alarm": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x60, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x01, "is_runing": 0x01}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x01, "no_alarm": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + ], + "cplds": [ + { + "name": "CPU_CPLD", + "cpld_id": "CPLD1", + "VersionFile": {"loc": "/dev/cpld0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for system power", + "slot": 0, + }, + { + "name": "BASE_CPLD", + "cpld_id": "CPLD2", + "VersionFile": {"loc": "/dev/cpld1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + }, + { + "name": "MAC_CPLDA", + "cpld_id": "CPLD3", + "VersionFile": {"loc": "/dev/cpld4", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "MAC_CPLDB", + "cpld_id": "CPLD4", + "VersionFile": {"loc": "/dev/cpld5", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "FAN_CPLD", + "cpld_id": "CPLD5", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "FPGA", + "cpld_id": "CPLD6", + "VersionFile": {"loc": "/dev/fpga0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + ], + "dcdc": [ + { + "name": "VDD5V_CLK_MCU", + "dcdc_id": "DCDC1", + "Min": 4840, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5345, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD3.3_CLK", + "dcdc_id": "DCDC2", + "Min": 3220, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3560, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.0V", + "dcdc_id": "DCDC3", + "Min": 950, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1049, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.8V", + "dcdc_id": "DCDC4", + "Min": 1720, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1903, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_BOARD_VDD3.3V", + "dcdc_id": "DCDC5", + "Min": 3170, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3499, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.2V", + "dcdc_id": "DCDC6", + "Min": 1150, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1272, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD_CORE", + "dcdc_id": "DCDC7", + "Min": 670, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 950, + "format": "float(float(%s)/1000)", + }, + { + "name": "ANALOG0.75V", + "dcdc_id": "DCDC8", + "Min": 700, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 800, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V", + "dcdc_id": "DCDC9", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1259, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDDO1.8V", + "dcdc_id": "DCDC10", + "Min": 1750, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1937, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_ANA1.2V", + "dcdc_id": "DCDC11", + "Min": 1150, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1276, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_ANA1.8V", + "dcdc_id": "DCDC12", + "Min": 1730, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in12_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1910, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC13", + "Min": 3250, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in13_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3595, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC14", + "Min": 3260, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in14_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3601, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFPDD_VDD3.3V_A", + "dcdc_id": "DCDC15", + "Min": 3230, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in15_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3565, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFPDD_VDD3.3V_B", + "dcdc_id": "DCDC16", + "Min": 3220, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in16_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3564, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD5.0V", + "dcdc_id": "DCDC17", + "Min": 4910, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5429, + "format": "float(float(%s)/1000)", + }, + { + "name": "CONNECT_BOARD_VDD3.3V", + "dcdc_id": "DCDC18", + "Min": 3110, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3437, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD12V", + "dcdc_id": "DCDC19", + "Min": 11300, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12700, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD3.3_STBY", + "dcdc_id": "DCDC20", + "Min": 3160, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3489, + "format": "float(float(%s)/1000)", + }, + { + "name": "SSD_VDD3.3V", + "dcdc_id": "DCDC21", + "Min": 3140, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3475, + "format": "float(float(%s)/1000)", + }, + { + "name": "PHY_VDD1V0", + "dcdc_id": "DCDC22", + "Min": 950, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1050, + "format": "float(float(%s)/1000)", + }, + { + "name": "ODD_PHY_M", + "dcdc_id": "DCDC23", + "Min": 3116, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3444, + "format": "float(float(%s)/1000)", + }, + { + "name": "VCCIN", + "dcdc_id": "DCDC24", + "Min": 1700, + "value": { + "loc": "/sys/bus/i2c/devices/25-0060/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1879, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V05", + "dcdc_id": "DCDC25", + "Min": 1000, + "value": { + "loc": "/sys/bus/i2c/devices/25-0060/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1103, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V2_VDDQ", + "dcdc_id": "DCDC26", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/25-006c/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1258, + "format": "float(float(%s)/1000)", + }, + { + "name": "P2V5_VPP", + "dcdc_id": "DCDC27", + "Min": 2117, + "value": { + "loc": "/sys/bus/i2c/devices/25-006c/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2342, + "format": "float(float(%s)/1000) * 1.124", + }, + { + "name": "P3V3_STBY", + "dcdc_id": "DCDC28", + "Min": 3140, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3476, + "format": "float(float(%s)/1000)", + }, + { + "name": "P5V_AUX_IN", + "dcdc_id": "DCDC29", + "Min": 4730, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5229, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V7_VCCSCFUSESUS_IN", + "dcdc_id": "DCDC30", + "Min": 1620, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1789, + "format": "float(float(%s)/1000)", + }, + ], + "cpu": [ + { + "name": "cpu", + "CpuResetCntReg": {"loc": "/dev/cpld1", "offset": 0x88, "len": 1, "way": "devfile_ascii"}, + } + ], + "sfps": { + "port_start": 1, + "port_end": 32, + } +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_device.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_device.py new file mode 100755 index 000000000000..2a7b99b47fdc --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_device.py @@ -0,0 +1,1108 @@ +#!/usr/bin/python3 + +psu_fan_airflow = { + "F2B": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "B2F": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +psu_display_name = { + "PSA1300CRPS-F": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "PSA1300CRPS-R": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +fanairflow = { + "F2B": ["FAN24K4056-F", "FAN24K4056S-F"], + "B2F": ["FAN24K4056S-R"], +} + +fan_display_name = { + "FAN24K4056-F": ["FAN24K4056-F", "FAN24K4056S-F"], + "FAN24K4056-R": ["FAN24K4056S-R"] +} + +psutypedecode = { + 0x00: 'N/A', + 0x01: 'AC', + 0x02: 'DC', +} + + +class Unit: + Temperature = "C" + Voltage = "V" + Current = "A" + Power = "W" + Speed = "RPM" + + +PSU_NOT_PRESENT_PWM = 100 + + +class threshold: + PSU_TEMP_MIN = -10 * 1000 + PSU_TEMP_MAX = 60 * 1000 + + PSU_FAN_SPEED_MIN = 2000 + PSU_FAN_SPEED_MAX = 28000 + + PSU_OUTPUT_VOLTAGE_MIN = 11 * 1000 + PSU_OUTPUT_VOLTAGE_MAX = 14 * 1000 + + PSU_AC_INPUT_VOLTAGE_MIN = 200 * 1000 + PSU_AC_INPUT_VOLTAGE_MAX = 240 * 1000 + + PSU_DC_INPUT_VOLTAGE_MIN = 190 * 1000 + PSU_DC_INPUT_VOLTAGE_MAX = 290 * 1000 + + ERR_VALUE = -9999999 + + PSU_OUTPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_OUTPUT_POWER_MAX = 1300 * 1000 * 1000 + + PSU_INPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_INPUT_POWER_MAX = 1444 * 1000 * 1000 + + PSU_OUTPUT_CURRENT_MIN = 2 * 1000 + PSU_OUTPUT_CURRENT_MAX = 107 * 1000 + + PSU_INPUT_CURRENT_MIN = 0.2 * 1000 + PSU_INPUT_CURRENT_MAX = 7 * 1000 + + FRONT_FAN_SPEED_MAX = 25000 + REAR_FAN_SPEED_MAX = 22000 + FAN_SPEED_MIN = 2000 + + +class Description: + CPLD = "Used for managing IO modules, SFP+ modules and system LEDs" + BIOS = "Performs initialization of hardware components during booting" + FPGA = "Platform management controller for on-board temperature monitoring, in-chassis power" + + +devices = { + "onie_e2": [ + { + "name": "ONIE_E2", + "e2loc": {"loc": "/sys/bus/i2c/devices/1-0056/eeprom", "way": "sysfs"}, + }, + ], + "psus": [ + { + "e2loc": {"loc": "/sys/bus/i2c/devices/41-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 41, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu1/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU1", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 41, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 41, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-41/41-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/42-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 42, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu2/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU2", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 42, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 42, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-42/42-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + } + ], + "temps": [ + { + "name": "BOARD_TEMP", + "temp_id": "TEMP1", + "api_name": "Board", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/40-004e/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 80000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "CPU_TEMP", + "temp_id": "TEMP2", + "api_name": "CPU", + "Temperature": { + "value": {"loc": "/sys/bus/platform/devices/coretemp.0/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 104000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "INLET_TEMP", + "temp_id": "TEMP3", + "api_name": "Inlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/40-004f/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 40000, + "Max": 50000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "OUTLET_TEMP", + "temp_id": "TEMP4", + "api_name": "Outlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/36-0048/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 80000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SWITCH_TEMP", + "temp_id": "TEMP5", + "api_name": "Switch ASIC", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/44-0044/hwmon/hwmon*/temp99_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 105000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SFF_TEMP", + "Temperature": { + "value": {"loc": "/tmp/highest_sff_temp", "way": "sysfs", "flock_path": "/tmp/highest_sff_temp"}, + "Min": -15000, + "Low": 0, + "High": 80000, + "Max": 100000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + ], + "leds": [ + { + "name": "FRONT_SYS_LED", + "led_type": "SYS_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x40, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_PSU_LED", + "led_type": "PSU_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x43, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_FAN_LED", + "led_type": "FAN_LED", + "led": {"bus": 2, "addr": 0x2d, "offset": 0x42, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + ], + "fans": [ + { + "name": "FAN1", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-35/35-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x41, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x65, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x20, "is_runing": 0x20}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x20, "no_alarm": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x65, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x20, "is_runing": 0x20}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x20, "no_alarm": 0x20}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN2", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-34/34-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x40, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x64, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x10, "is_runing": 0x10}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x10, "no_alarm": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x64, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x10, "is_runing": 0x10}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x10, "no_alarm": 0x10}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN3", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-33/33-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3f, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x63, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x08, "is_runing": 0x08}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x08, "no_alarm": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x63, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x08, "is_runing": 0x08}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x08, "no_alarm": 0x08}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN4", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-32/32-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x62, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x04, "is_runing": 0x04}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x04, "no_alarm": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x62, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x04, "is_runing": 0x04}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x04, "no_alarm": 0x04}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN5", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-31/31-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x61, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x02, "is_runing": 0x02}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x02, "no_alarm": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x61, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x02, "is_runing": 0x02}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x02, "no_alarm": 0x02}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN6", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-30/30-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"bus": 4, "addr": 0x3d, "offset": 0x37, "way": "i2c", "mask": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 4, "addr": 0x3d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x60, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x01, "is_runing": 0x01}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x38, "way": "i2c", "mask": 0x01, "no_alarm": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 4, "addr": 0x3d, "offset": 0x60, "way": "i2c"}, + "Running": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x01, "is_runing": 0x01}, + "HwAlarm": {"bus": 4, "addr": 0x3d, "offset": 0x39, "way": "i2c", "mask": 0x01, "no_alarm": 0x01}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + ], + "cplds": [ + { + "name": "CPU_CPLD", + "cpld_id": "CPLD1", + "VersionFile": {"loc": "/dev/cpld0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for system power", + "slot": 0, + }, + { + "name": "BASE_CPLD", + "cpld_id": "CPLD2", + "VersionFile": {"loc": "/dev/cpld1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + }, + { + "name": "MAC_CPLDA", + "cpld_id": "CPLD3", + "VersionFile": {"loc": "/dev/cpld4", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "MAC_CPLDB", + "cpld_id": "CPLD4", + "VersionFile": {"loc": "/dev/cpld5", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "FAN_CPLD", + "cpld_id": "CPLD5", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "FPGA", + "cpld_id": "CPLD6", + "VersionFile": {"loc": "/dev/fpga0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + ], + "dcdc": [ + { + "name": "VDD5V_CLK_MCU", + "dcdc_id": "DCDC1", + "Min": 4840, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5345, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD3.3_CLK", + "dcdc_id": "DCDC2", + "Min": 3220, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3560, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.0V", + "dcdc_id": "DCDC3", + "Min": 950, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1049, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.8V", + "dcdc_id": "DCDC4", + "Min": 1720, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1903, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_BOARD_VDD3.3V", + "dcdc_id": "DCDC5", + "Min": 3170, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3499, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD1.2V", + "dcdc_id": "DCDC6", + "Min": 1150, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1272, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD_CORE", + "dcdc_id": "DCDC7", + "Min": 670, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 950, + "format": "float(float(%s)/1000)", + }, + { + "name": "ANALOG0.75V", + "dcdc_id": "DCDC8", + "Min": 700, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 800, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V", + "dcdc_id": "DCDC9", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1259, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDDO1.8V", + "dcdc_id": "DCDC10", + "Min": 1750, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1937, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_ANA1.2V", + "dcdc_id": "DCDC11", + "Min": 1150, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1276, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_ANA1.8V", + "dcdc_id": "DCDC12", + "Min": 1730, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in12_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1910, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC13", + "Min": 3250, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in13_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3595, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC14", + "Min": 3260, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in14_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3601, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFPDD_VDD3.3V_A", + "dcdc_id": "DCDC15", + "Min": 3230, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in15_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3565, + "format": "float(float(%s)/1000)", + }, + { + "name": "QSFPDD_VDD3.3V_B", + "dcdc_id": "DCDC16", + "Min": 3220, + "value": { + "loc": "/sys/bus/i2c/devices/45-005b/hwmon/hwmon*/in16_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3564, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD5.0V", + "dcdc_id": "DCDC17", + "Min": 4910, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5429, + "format": "float(float(%s)/1000)", + }, + { + "name": "SW_VDD1.2V", + "dcdc_id": "DCDC18", + "Min": 1160, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1284, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD2.5V", + "dcdc_id": "DCDC19", + "Min": 2370, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2620, + "format": "float(float(%s)/1000)", + }, + { + "name": "CONNECT_BOARD_VDD3.3V", + "dcdc_id": "DCDC20", + "Min": 3110, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3437, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD12V", + "dcdc_id": "DCDC21", + "Min": 11300, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12700, + "format": "float(float(%s)/1000)", + }, + { + "name": "VDD3.3_STBY", + "dcdc_id": "DCDC22", + "Min": 3160, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3489, + "format": "float(float(%s)/1000)", + }, + { + "name": "SSD_VDD3.3V", + "dcdc_id": "DCDC23", + "Min": 3140, + "value": { + "loc": "/sys/bus/i2c/devices/24-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3475, + "format": "float(float(%s)/1000)", + }, + { + "name": "VCCIN", + "dcdc_id": "DCDC24", + "Min": 1700, + "value": { + "loc": "/sys/bus/i2c/devices/25-0060/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1879, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V05", + "dcdc_id": "DCDC25", + "Min": 1000, + "value": { + "loc": "/sys/bus/i2c/devices/25-0060/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1103, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V2_VDDQ", + "dcdc_id": "DCDC26", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/25-006c/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1258, + "format": "float(float(%s)/1000)", + }, + { + "name": "P2V5_VPP", + "dcdc_id": "DCDC27", + "Min": 2117, + "value": { + "loc": "/sys/bus/i2c/devices/25-006c/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2342, + "format": "float(float(%s)/1000) * 1.124", + }, + { + "name": "P3V3_STBY", + "dcdc_id": "DCDC28", + "Min": 3140, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3476, + "format": "float(float(%s)/1000)", + }, + { + "name": "P5V_AUX_IN", + "dcdc_id": "DCDC29", + "Min": 4730, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5229, + "format": "float(float(%s)/1000)", + }, + { + "name": "P1V7_VCCSCFUSESUS_IN", + "dcdc_id": "DCDC30", + "Min": 1620, + "value": { + "loc": "/sys/bus/i2c/devices/25-0043/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1789, + "format": "float(float(%s)/1000)", + }, + ], + "cpu": [ + { + "name": "cpu", + "CpuResetCntReg": {"loc": "/dev/cpld1", "offset": 0x88, "len": 1, "way": "devfile_ascii"}, + } + ], + "sfps": { + "port_start": 1, + "port_end": 32, + } +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_monitor.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_monitor.py new file mode 100755 index 000000000000..4cb28cf8bb66 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/hal-config/x86_64_tencent_tcs8400_r0_monitor.py @@ -0,0 +1,212 @@ +#!/usr/bin/python3 + +monitor = { + "openloop": { + "linear": { + "name": "linear", + "flag": 0, + "pwm_min": 0x80, + "pwm_max": 0xff, + "K": 11, + "tin_min": 38, + }, + "curve": { + "name": "curve", + "flag": 1, + "pwm_min": 0x80, + "pwm_max": 0xff, + "a": 0.369, + "b": -15.657, + "c": 289, + "tin_min": 25, + }, + }, + + "pid": { + "CPU_TEMP": { + "name": "CPU_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 1.5, + "Ki": 1, + "Kd": 0.3, + "target": 80, + "value": [None, None, None], + }, + "SWITCH_TEMP": { + "name": "SWITCH_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 1.5, + "Ki": 1, + "Kd": 0.3, + "target": 90, + "value": [None, None, None], + }, + "OUTLET_TEMP": { + "name": "OUTLET_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 2, + "Ki": 0.4, + "Kd": 0.3, + "target": 65, + "value": [None, None, None], + }, + "BOARD_TEMP": { + "name": "BOARD_TEMP", + "flag": 0, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 2, + "Ki": 0.4, + "Kd": 0.3, + "target": 65, + "value": [None, None, None], + }, + "SFF_TEMP": { + "name": "SFF_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x80, + "pwm_max": 0xff, + "Kp": 0.1, + "Ki": 0.4, + "Kd": 0, + "target": 60, + "value": [None, None, None], + }, + }, + + "temps_threshold": { + "SWITCH_TEMP": {"name": "SWITCH_TEMP", "warning": 100, "critical": 105, "invalid": -100000, "error": -99999}, + "INLET_TEMP": {"name": "INLET_TEMP", "warning": 40, "critical": 50, "fix": -3}, + "BOARD_TEMP": {"name": "BOARD_TEMP", "warning": 70, "critical": 75}, + "OUTLET_TEMP": {"name": "OUTLET_TEMP", "warning": 70, "critical": 75}, + "CPU_TEMP": {"name": "CPU_TEMP", "warning": 100, "critical": 102}, + "SFF_TEMP": {"name": "SFF_TEMP", "warning": 999, "critical": 1000, "ignore_threshold": 1, "invalid": -10000, "error": -9999}, + }, + + "fancontrol_para": { + "interval": 5, + "fan_status_interval": 0.5, + "fan_air_flow_monitor": 1, + "max_pwm": 0xff, + "min_pwm": 0x80, + "abnormal_pwm": 0xff, + "warning_pwm": 0xff, + "temp_invalid_pid_pwm": 0x80, + "temp_error_pid_pwm": 0x80, + "temp_fail_num": 3, + "check_temp_fail": [ + {"temp_name": "INLET_TEMP"}, + {"temp_name": "SWITCH_TEMP"}, + {"temp_name": "CPU_TEMP"}, + ], + "temp_warning_num": 3, # temp over warning 3 times continuously + "temp_critical_num": 3, # temp over critical 3 times continuously + "temp_warning_countdown": 60, # 5 min warning speed after not warning + "temp_critical_countdown": 60, # 5 min full speed after not critical + "rotor_error_count": 2, # fan rotor error 2 times continuously + "inlet_mac_diff": 999, + "check_crit_reboot_flag": 1, + "check_crit_reboot_num": 3, + "check_crit_sleep_time": 20, + "psu_absent_fullspeed_num": 0xFF, + "fan_absent_fullspeed_num": 1, + "rotor_error_fullspeed_num": 1, + "fan_plug_in_default_countdown": 0, # no use + "fan_plug_in_pwm": 0x80, # fan plug in pwd + "deal_fan_error": 1, + "deal_fan_error_conf": { + "countdown": 2, + "FAN1": [ + {"name":"FAN1", "pwm":0xff}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN2": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0xff}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN3": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0xff}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN4": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0xff}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN5": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0xff}, + {"name":"FAN6", "pwm":0x80}, + ], + "FAN6": [ + {"name":"FAN1", "pwm":0x80}, + {"name":"FAN2", "pwm":0x80}, + {"name":"FAN3", "pwm":0x80}, + {"name":"FAN4", "pwm":0x80}, + {"name":"FAN5", "pwm":0x80}, + {"name":"FAN6", "pwm":0xff}, + ], + }, + }, + + "ledcontrol_para": { + "interval": 5, + "checkpsu": 1, + "checkfan": 1, + "psu_yellow_num": 1, + "fan_yellow_num": 1, + "board_sys_led": [ + {"led_name": "FRONT_SYS_LED"}, + ], + "board_psu_led": [ + {"led_name": "FRONT_PSU_LED"}, + ], + "board_fan_led": [ + {"led_name": "FRONT_FAN_LED"}, + ], + "psu_air_flow_monitor": 1, + "fan_air_flow_monitor": 1, + "fan_mix_list": [ + {"FAN24K4056-F", "FAN24K4056S-F"} + ] + }, + "intelligent_monitor_para": { + "interval": 60, + }, + + "dcdc_monitor_whitelist": { #not monitor when checkbit equal okval + "QSFP56_VDD3.3V_A": {"gettype": "i2c", "bus": 2, "addr": 0x2d, "offset": 0x45, "checkbit": 0, "okval": 0}, + "QSFP56_VDD3.3V_B": {"gettype": "i2c", "bus": 2, "addr": 0x2d, "offset": 0x45, "checkbit": 1, "okval": 0}, + "QSFPDD_VDD3.3V_A": {"gettype": "i2c", "bus": 2, "addr": 0x2d, "offset": 0x46, "checkbit": 0, "okval": 0}, + "QSFPDD_VDD3.3V_B": {"gettype": "i2c", "bus": 2, "addr": 0x2d, "offset": 0x46, "checkbit": 1, "okval": 0}, + }, +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/Makefile new file mode 100755 index 000000000000..873cb472f957 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/Makefile @@ -0,0 +1,12 @@ +MAKEFILE_FILE_PATH = $(abspath $(lastword $(MAKEFILE_LIST))) +MODULES_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../../../common/modules) + +EXTRA_CFLAGS+= -I$(MODULES_DIR) + +obj-m += rg_pcie_dev_device.o +obj-m += rg_fpga_i2c_bus_device.o +obj-m += rg_fpga_pca954x_device.o +obj-m += rg_lpc_drv_device.o +obj-m += rg_i2c_dev_device.o +obj-m += rg_io_dev_device.o +obj-m += rg_wdt_device.o \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_i2c_bus_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_i2c_bus_device.c new file mode 100644 index 000000000000..22e8a1ddf19d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_i2c_bus_device.c @@ -0,0 +1,874 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_fpga_i2c_debug = 0; +static int g_rg_fpga_i2c_error = 0; + +module_param(g_rg_fpga_i2c_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_i2c_error, int, S_IRUGO | S_IWUSR); + +#define RG_FPGA_I2C_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_i2c_debug) { \ + printk(KERN_INFO "[RG_FPGA_I2C][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_FPGA_I2C_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_fpga_i2c_error) { \ + printk(KERN_ERR "[RG_FPGA_I2C][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static fpga_i2c_bus_device_t fpga_i2c_bus_device_data0 = { + .adap_nr = 2, + .i2c_timeout = 3000, + .i2c_scale = 0x500, + .i2c_filter = 0x504, + .i2c_stretch = 0x508, + .i2c_ext_9548_exits_flag = 0x50c, + .i2c_ext_9548_addr = 0x510, + .i2c_ext_9548_chan = 0x514, + .i2c_in_9548_chan = 0x518, + .i2c_slave = 0x51c, + .i2c_reg = 0x520, + .i2c_reg_len = 0x530, + .i2c_data_len = 0x534, + .i2c_ctrl = 0x538, + .i2c_status = 0x53c, + .i2c_err_vec = 0x548, + .i2c_data_buf = 0x580, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_i2c_bus_device_data1 = { + .adap_nr = 3, + .i2c_timeout = 3000, + .i2c_scale = 0x600, + .i2c_filter = 0x604, + .i2c_stretch = 0x608, + .i2c_ext_9548_exits_flag = 0x60c, + .i2c_ext_9548_addr = 0x610, + .i2c_ext_9548_chan = 0x614, + .i2c_in_9548_chan = 0x618, + .i2c_slave = 0x61c, + .i2c_reg = 0x620, + .i2c_reg_len = 0x630, + .i2c_data_len = 0x634, + .i2c_ctrl = 0x638, + .i2c_status = 0x63c, + .i2c_err_vec = 0x648, + .i2c_data_buf = 0x680, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x84, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_i2c_bus_device_data2 = { + .adap_nr = 4, + .i2c_timeout = 3000, + .i2c_scale = 0x700, + .i2c_filter = 0x704, + .i2c_stretch = 0x708, + .i2c_ext_9548_exits_flag = 0x70c, + .i2c_ext_9548_addr = 0x710, + .i2c_ext_9548_chan = 0x714, + .i2c_in_9548_chan = 0x718, + .i2c_slave = 0x71c, + .i2c_reg = 0x720, + .i2c_reg_len = 0x730, + .i2c_data_len = 0x734, + .i2c_ctrl = 0x738, + .i2c_status = 0x73c, + .i2c_err_vec = 0x748, + .i2c_data_buf = 0x780, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x88, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; +static fpga_i2c_bus_device_t fpga_i2c_bus_device_data3 = { + .adap_nr = 5, + .i2c_timeout = 3000, + .i2c_scale = 0x800, + .i2c_filter = 0x804, + .i2c_stretch = 0x808, + .i2c_ext_9548_exits_flag = 0x80c, + .i2c_ext_9548_addr = 0x810, + .i2c_ext_9548_chan = 0x814, + .i2c_in_9548_chan = 0x818, + .i2c_slave = 0x81c, + .i2c_reg = 0x820, + .i2c_reg_len = 0x830, + .i2c_data_len = 0x834, + .i2c_ctrl = 0x838, + .i2c_status = 0x83c, + .i2c_err_vec = 0x848, + .i2c_data_buf = 0x880, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x8c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, + .i2c_offset_reg = 0xd4, + .i2c_data_buf_len_reg = 0xac, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data0 = { + .adap_nr = 6, + .i2c_timeout = 3000, + .i2c_scale = 0x2c00, + .i2c_filter = 0x2c04, + .i2c_stretch = 0x2c08, + .i2c_ext_9548_exits_flag = 0x2c0c, + .i2c_ext_9548_addr = 0x2c10, + .i2c_ext_9548_chan = 0x2c14, + .i2c_in_9548_chan = 0x2c18, + .i2c_slave = 0x2c1c, + .i2c_reg = 0x2c20, + .i2c_reg_len = 0x2c30, + .i2c_data_len = 0x2c34, + .i2c_ctrl = 0x2c38, + .i2c_status = 0x2c3c, + .i2c_err_vec = 0x2c48, + .i2c_data_buf = 0x2c80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data1 = { + .adap_nr = 7, + .i2c_timeout = 3000, + .i2c_scale = 0x2d00, + .i2c_filter = 0x2d04, + .i2c_stretch = 0x2d08, + .i2c_ext_9548_exits_flag = 0x2d0c, + .i2c_ext_9548_addr = 0x2d10, + .i2c_ext_9548_chan = 0x2d14, + .i2c_in_9548_chan = 0x2d18, + .i2c_slave = 0x2d1c, + .i2c_reg = 0x2d20, + .i2c_reg_len = 0x2d30, + .i2c_data_len = 0x2d34, + .i2c_ctrl = 0x2d38, + .i2c_status = 0x2d3c, + .i2c_err_vec = 0x2d48, + .i2c_data_buf = 0x2d80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data2 = { + .adap_nr = 8, + .i2c_timeout = 3000, + .i2c_scale = 0x2e00, + .i2c_filter = 0x2e04, + .i2c_stretch = 0x2e08, + .i2c_ext_9548_exits_flag = 0x2e0c, + .i2c_ext_9548_addr = 0x2e10, + .i2c_ext_9548_chan = 0x2e14, + .i2c_in_9548_chan = 0x2e18, + .i2c_slave = 0x2e1c, + .i2c_reg = 0x2e20, + .i2c_reg_len = 0x2e30, + .i2c_data_len = 0x2e34, + .i2c_ctrl = 0x2e38, + .i2c_status = 0x2e3c, + .i2c_err_vec = 0x2e48, + .i2c_data_buf = 0x2e80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000004, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data3 = { + .adap_nr = 9, + .i2c_timeout = 3000, + .i2c_scale = 0x2f00, + .i2c_filter = 0x2f04, + .i2c_stretch = 0x2f08, + .i2c_ext_9548_exits_flag = 0x2f0c, + .i2c_ext_9548_addr = 0x2f10, + .i2c_ext_9548_chan = 0x2f14, + .i2c_in_9548_chan = 0x2f18, + .i2c_slave = 0x2f1c, + .i2c_reg = 0x2f20, + .i2c_reg_len = 0x2f30, + .i2c_data_len = 0x2f34, + .i2c_ctrl = 0x2f38, + .i2c_status = 0x2f3c, + .i2c_err_vec = 0x2f48, + .i2c_data_buf = 0x2f80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000008, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data4 = { + .adap_nr = 10, + .i2c_timeout = 3000, + .i2c_scale = 0x3000, + .i2c_filter = 0x3004, + .i2c_stretch = 0x3008, + .i2c_ext_9548_exits_flag = 0x300c, + .i2c_ext_9548_addr = 0x3010, + .i2c_ext_9548_chan = 0x3014, + .i2c_in_9548_chan = 0x3018, + .i2c_slave = 0x301c, + .i2c_reg = 0x3020, + .i2c_reg_len = 0x3030, + .i2c_data_len = 0x3034, + .i2c_ctrl = 0x3038, + .i2c_status = 0x303c, + .i2c_err_vec = 0x3048, + .i2c_data_buf = 0x3080, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000010, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data5 = { + .adap_nr = 11, + .i2c_timeout = 3000, + .i2c_scale = 0x3100, + .i2c_filter = 0x3104, + .i2c_stretch = 0x3108, + .i2c_ext_9548_exits_flag = 0x310c, + .i2c_ext_9548_addr = 0x3110, + .i2c_ext_9548_chan = 0x3114, + .i2c_in_9548_chan = 0x3118, + .i2c_slave = 0x311c, + .i2c_reg = 0x3120, + .i2c_reg_len = 0x3130, + .i2c_data_len = 0x3134, + .i2c_ctrl = 0x3138, + .i2c_status = 0x313c, + .i2c_data_buf = 0x3180, + .i2c_err_vec = 0x3148, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000020, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data6 = { + .adap_nr = 12, + .i2c_timeout = 3000, + .i2c_scale = 0x3200, + .i2c_filter = 0x3204, + .i2c_stretch = 0x3208, + .i2c_ext_9548_exits_flag = 0x320c, + .i2c_ext_9548_addr = 0x3210, + .i2c_ext_9548_chan = 0x3214, + .i2c_in_9548_chan = 0x3218, + .i2c_slave = 0x321c, + .i2c_reg = 0x3220, + .i2c_reg_len = 0x3230, + .i2c_data_len = 0x3234, + .i2c_ctrl = 0x3238, + .i2c_status = 0x323c, + .i2c_err_vec = 0x3248, + .i2c_data_buf = 0x3280, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000040, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data7 = { + .adap_nr = 13, + .i2c_timeout = 3000, + .i2c_scale = 0x3300, + .i2c_filter = 0x3304, + .i2c_stretch = 0x3308, + .i2c_ext_9548_exits_flag = 0x330c, + .i2c_ext_9548_addr = 0x3310, + .i2c_ext_9548_chan = 0x3314, + .i2c_in_9548_chan = 0x3318, + .i2c_slave = 0x331c, + .i2c_reg = 0x3320, + .i2c_reg_len = 0x3330, + .i2c_data_len = 0x3334, + .i2c_ctrl = 0x3338, + .i2c_status = 0x333c, + .i2c_err_vec = 0x3348, + .i2c_data_buf = 0x3380, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000080, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data8 = { + .adap_nr = 14, + .i2c_timeout = 3000, + .i2c_scale = 0x3400, + .i2c_filter = 0x3404, + .i2c_stretch = 0x3408, + .i2c_ext_9548_exits_flag = 0x340c, + .i2c_ext_9548_addr = 0x3410, + .i2c_ext_9548_chan = 0x3414, + .i2c_in_9548_chan = 0x3418, + .i2c_slave = 0x341c, + .i2c_reg = 0x3420, + .i2c_reg_len = 0x3430, + .i2c_data_len = 0x3434, + .i2c_ctrl = 0x3438, + .i2c_status = 0x343c, + .i2c_err_vec = 0x3448, + .i2c_data_buf = 0x3480, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000100, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data9 = { + .adap_nr = 15, + .i2c_timeout = 3000, + .i2c_scale = 0x3500, + .i2c_filter = 0x3504, + .i2c_stretch = 0x3508, + .i2c_ext_9548_exits_flag = 0x350c, + .i2c_ext_9548_addr = 0x3510, + .i2c_ext_9548_chan = 0x3514, + .i2c_in_9548_chan = 0x3518, + .i2c_slave = 0x351c, + .i2c_reg = 0x3520, + .i2c_reg_len = 0x3530, + .i2c_data_len = 0x3534, + .i2c_ctrl = 0x3538, + .i2c_status = 0x353c, + .i2c_err_vec = 0x3548, + .i2c_data_buf = 0x3580, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000200, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data10 = { + .adap_nr = 16, + .i2c_timeout = 3000, + .i2c_scale = 0x3600, + .i2c_filter = 0x3604, + .i2c_stretch = 0x3608, + .i2c_ext_9548_exits_flag = 0x360c, + .i2c_ext_9548_addr = 0x3610, + .i2c_ext_9548_chan = 0x3614, + .i2c_in_9548_chan = 0x3618, + .i2c_slave = 0x361c, + .i2c_reg = 0x3620, + .i2c_reg_len = 0x3630, + .i2c_data_len = 0x3634, + .i2c_ctrl = 0x3638, + .i2c_status = 0x363c, + .i2c_err_vec = 0x3648, + .i2c_data_buf = 0x3680, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000400, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data11 = { + .adap_nr = 17, + .i2c_timeout = 3000, + .i2c_scale = 0x3700, + .i2c_filter = 0x3704, + .i2c_stretch = 0x3708, + .i2c_ext_9548_exits_flag = 0x370c, + .i2c_ext_9548_addr = 0x3710, + .i2c_ext_9548_chan = 0x3714, + .i2c_in_9548_chan = 0x3718, + .i2c_slave = 0x371c, + .i2c_reg = 0x3720, + .i2c_reg_len = 0x3730, + .i2c_data_len = 0x3734, + .i2c_ctrl = 0x3738, + .i2c_status = 0x373c, + .i2c_err_vec = 0x3748, + .i2c_data_buf = 0x3780, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000800, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data12 = { + .adap_nr = 18, + .i2c_timeout = 3000, + .i2c_scale = 0x3800, + .i2c_filter = 0x3804, + .i2c_stretch = 0x3808, + .i2c_ext_9548_exits_flag = 0x380c, + .i2c_ext_9548_addr = 0x3810, + .i2c_ext_9548_chan = 0x3814, + .i2c_in_9548_chan = 0x3818, + .i2c_slave = 0x381c, + .i2c_reg = 0x3820, + .i2c_reg_len = 0x3830, + .i2c_data_len = 0x3834, + .i2c_ctrl = 0x3838, + .i2c_status = 0x383c, + .i2c_err_vec = 0x3848, + .i2c_data_buf = 0x3880, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00001000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data13 = { + .adap_nr = 19, + .i2c_timeout = 3000, + .i2c_scale = 0x3900, + .i2c_filter = 0x3904, + .i2c_stretch = 0x3908, + .i2c_ext_9548_exits_flag = 0x390c, + .i2c_ext_9548_addr = 0x3910, + .i2c_ext_9548_chan = 0x3914, + .i2c_in_9548_chan = 0x3918, + .i2c_slave = 0x391c, + .i2c_reg = 0x3920, + .i2c_reg_len = 0x3930, + .i2c_data_len = 0x3934, + .i2c_ctrl = 0x3938, + .i2c_status = 0x393c, + .i2c_err_vec = 0x3948, + .i2c_data_buf = 0x3980, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00002000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data14 = { + .adap_nr = 20, + .i2c_timeout = 3000, + .i2c_scale = 0x3a00, + .i2c_filter = 0x3a04, + .i2c_stretch = 0x3a08, + .i2c_ext_9548_exits_flag = 0x3a0c, + .i2c_ext_9548_addr = 0x3a10, + .i2c_ext_9548_chan = 0x3a14, + .i2c_in_9548_chan = 0x3a18, + .i2c_slave = 0x3a1c, + .i2c_reg = 0x3a20, + .i2c_reg_len = 0x3a30, + .i2c_data_len = 0x3a34, + .i2c_ctrl = 0x3a38, + .i2c_status = 0x3a3c, + .i2c_err_vec = 0x3a48, + .i2c_data_buf = 0x3a80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00004000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static fpga_i2c_bus_device_t fpga_dom_i2c_bus_device_data15 = { + .adap_nr = 21, + .i2c_timeout = 3000, + .i2c_scale = 0x3b00, + .i2c_filter = 0x3b04, + .i2c_stretch = 0x3b08, + .i2c_ext_9548_exits_flag = 0x3b0c, + .i2c_ext_9548_addr = 0x3b10, + .i2c_ext_9548_chan = 0x3b14, + .i2c_in_9548_chan = 0x3b18, + .i2c_slave = 0x3b1c, + .i2c_reg = 0x3b20, + .i2c_reg_len = 0x3b30, + .i2c_data_len = 0x3b34, + .i2c_ctrl = 0x3b38, + .i2c_status = 0x3b3c, + .i2c_err_vec = 0x3b48, + .i2c_data_buf = 0x3b80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 3, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00008000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, + .i2c_rst_delay = 1, + .i2c_rst_delay_a = 1, +}; + +static void rg_fpga_i2c_bus_device_release(struct device *dev) +{ + return; +} + +static struct platform_device fpga_i2c_bus_device[] = { + { + .name = "rg-fpga-i2c", + .id = 1, + .dev = { + .platform_data = &fpga_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 2, + .dev = { + .platform_data = &fpga_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 3, + .dev = { + .platform_data = &fpga_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 4, + .dev = { + .platform_data = &fpga_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 5, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 6, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 7, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 8, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 9, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 10, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 11, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data6, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 12, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data7, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 13, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data8, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 14, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data9, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 15, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data10, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 16, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data11, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 17, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data12, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 18, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data13, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 19, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data14, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 20, + .dev = { + .platform_data = &fpga_dom_i2c_bus_device_data15, + .release = rg_fpga_i2c_bus_device_release, + }, + }, +}; + +static int __init rg_fpga_i2c_bus_device_init(void) +{ + int i; + int ret = 0; + fpga_i2c_bus_device_t *fpga_i2c_bus_device_data; + + RG_FPGA_I2C_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(fpga_i2c_bus_device); i++) { + fpga_i2c_bus_device_data = fpga_i2c_bus_device[i].dev.platform_data; + ret = platform_device_register(&fpga_i2c_bus_device[i]); + if (ret < 0) { + fpga_i2c_bus_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-fpga-i2c.%d register failed!\n", i + 1); + } else { + fpga_i2c_bus_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_fpga_i2c_bus_device_exit(void) +{ + int i; + fpga_i2c_bus_device_t *fpga_i2c_bus_device_data; + + RG_FPGA_I2C_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(fpga_i2c_bus_device) - 1; i >= 0; i--) { + fpga_i2c_bus_device_data = fpga_i2c_bus_device[i].dev.platform_data; + if (fpga_i2c_bus_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&fpga_i2c_bus_device[i]); + } + } +} + +module_init(rg_fpga_i2c_bus_device_init); +module_exit(rg_fpga_i2c_bus_device_exit); +MODULE_DESCRIPTION("FPGA I2C Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_pca954x_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_pca954x_device.c new file mode 100644 index 000000000000..c9b4f6a871d2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_fpga_pca954x_device.c @@ -0,0 +1,308 @@ +#include +#include +#include +#include +#include +#include + +#include + +static int g_rg_fpga_pca954x_device_debug = 0; +static int g_rg_fpga_pca954x_device_error = 0; + +module_param(g_rg_fpga_pca954x_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_pca954x_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_pca954x_device_debug) { \ + printk(KERN_INFO "[RG_FPGA_PCA954X_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_FPGA_PCA954X_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_fpga_pca954x_device_error) { \ + printk(KERN_ERR "[RG_FPGA_PCA954X_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static fpga_pca954x_device_t fpga_pca954x_device_data0 = { + .i2c_bus = 3, + .i2c_addr = 0x77, + .pca9548_base_nr = 22, + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data1 = { + .i2c_bus = 4, + .i2c_addr = 0x71, + .pca9548_base_nr = 30, + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data2 = { + .i2c_bus = 5, + .i2c_addr = 0x77, + .pca9548_base_nr = 38, + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data3 = { + .i2c_bus = 6, + .i2c_addr = 0x70, + .pca9548_base_nr = 46, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data4 = { + .i2c_bus = 7, + .i2c_addr = 0x70, + .pca9548_base_nr = 48, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data5 = { + .i2c_bus = 8, + .i2c_addr = 0x70, + .pca9548_base_nr = 50, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data6 = { + .i2c_bus = 9, + .i2c_addr = 0x70, + .pca9548_base_nr = 52, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data7 = { + .i2c_bus = 10, + .i2c_addr = 0x70, + .pca9548_base_nr = 54, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data8 = { + .i2c_bus = 11, + .i2c_addr = 0x70, + .pca9548_base_nr = 56, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data9 = { + .i2c_bus = 12, + .i2c_addr = 0x70, + .pca9548_base_nr = 58, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data10 = { + .i2c_bus = 13, + .i2c_addr = 0x70, + .pca9548_base_nr = 60, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data11 = { + .i2c_bus = 14, + .i2c_addr = 0x70, + .pca9548_base_nr = 62, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data12 = { + .i2c_bus = 15, + .i2c_addr = 0x70, + .pca9548_base_nr = 64, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data13 = { + .i2c_bus = 16, + .i2c_addr = 0x70, + .pca9548_base_nr = 66, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data14 = { + .i2c_bus = 17, + .i2c_addr = 0x70, + .pca9548_base_nr = 68, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data15 = { + .i2c_bus = 18, + .i2c_addr = 0x70, + .pca9548_base_nr = 70, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data16 = { + .i2c_bus = 19, + .i2c_addr = 0x70, + .pca9548_base_nr = 72, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data17 = { + .i2c_bus = 20, + .i2c_addr = 0x70, + .pca9548_base_nr = 74, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga_pca954x_device_data18 = { + .i2c_bus = 21, + .i2c_addr = 0x70, + .pca9548_base_nr = 76, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +struct i2c_board_info fpga_pca954x_device_info[] = { + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga_pca954x_device_data0, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga_pca954x_device_data1, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga_pca954x_device_data2, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data3, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data4, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data5, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data6, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data7, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data8, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data9, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data10, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data11, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data12, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data13, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data14, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data15, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data16, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data17, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga_pca954x_device_data18, + }, +}; + +static int __init rg_fpga_pca954x_device_init(void) +{ + int i; + struct i2c_adapter *adap; + struct i2c_client *client; + fpga_pca954x_device_t *fpga_pca954x_device_data; + + RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(fpga_pca954x_device_info); i++) { + fpga_pca954x_device_data = fpga_pca954x_device_info[i].platform_data; + fpga_pca954x_device_info[i].addr = fpga_pca954x_device_data->i2c_addr; + adap = i2c_get_adapter(fpga_pca954x_device_data->i2c_bus); + if (adap == NULL) { + fpga_pca954x_device_data->client = NULL; + printk(KERN_ERR "get i2c bus %d adapter fail.\n", fpga_pca954x_device_data->i2c_bus); + continue; + } + client = i2c_new_client_device(adap, &fpga_pca954x_device_info[i]); + if (!client) { + fpga_pca954x_device_data->client = NULL; + printk(KERN_ERR "Failed to register fpga pca954x device %d at bus %d!\n", + fpga_pca954x_device_data->i2c_addr, fpga_pca954x_device_data->i2c_bus); + } else { + fpga_pca954x_device_data->client = client; + } + i2c_put_adapter(adap); + } + return 0; +} + +static void __exit rg_fpga_pca954x_device_exit(void) +{ + int i; + fpga_pca954x_device_t *fpga_pca954x_device_data; + + RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(fpga_pca954x_device_info) - 1; i >= 0; i--) { + fpga_pca954x_device_data = fpga_pca954x_device_info[i].platform_data; + if (fpga_pca954x_device_data->client) { + i2c_unregister_device(fpga_pca954x_device_data->client); + fpga_pca954x_device_data->client = NULL; + } + } +} + +module_init(rg_fpga_pca954x_device_init); +module_exit(rg_fpga_pca954x_device_exit); +MODULE_DESCRIPTION("RG FPGA PCA954X Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_i2c_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_i2c_dev_device.c new file mode 100644 index 000000000000..84140e8c6cad --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_i2c_dev_device.c @@ -0,0 +1,155 @@ +#include +#include +#include +#include +#include +#include + +#include + +static int g_rg_i2c_dev_device_debug = 0; +static int g_rg_i2c_dev_device_error = 0; + +module_param(g_rg_i2c_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_i2c_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_I2C_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_i2c_dev_device_debug) { \ + printk(KERN_INFO "[RG_I2C_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_I2C_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_i2c_dev_device_error) { \ + printk(KERN_ERR "[RG_I2C_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static i2c_dev_device_t i2c_dev_device_data0 = { + .i2c_bus = 2, + .i2c_addr = 0x1d, + .i2c_name = "cpld4", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data1 = { + .i2c_bus = 2, + .i2c_addr = 0x2d, + .i2c_name = "cpld5", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data2 = { + .i2c_bus = 4, + .i2c_addr = 0x3d, + .i2c_name = "cpld6", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data3 = { + .i2c_bus = 2, + .i2c_addr = 0x1e, + .i2c_name = "cpld7", + .data_bus_width = 1, + .addr_bus_width = 2, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 0x2000, +}; + +static i2c_dev_device_t i2c_dev_device_data4 = { + .i2c_bus = 4, + .i2c_addr = 0x3e, + .i2c_name = "cpld8", + .data_bus_width = 1, + .addr_bus_width = 2, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 0x2000, +}; + +struct i2c_board_info i2c_dev_device_info[] = { + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data0, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data1, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data2, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data3, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data4, + }, +}; + +static int __init rg_i2c_dev_device_init(void) +{ + int i; + struct i2c_adapter *adap; + struct i2c_client *client; + i2c_dev_device_t *i2c_dev_device_data; + + RG_I2C_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(i2c_dev_device_info); i++) { + i2c_dev_device_data = i2c_dev_device_info[i].platform_data; + i2c_dev_device_info[i].addr = i2c_dev_device_data->i2c_addr; + adap = i2c_get_adapter(i2c_dev_device_data->i2c_bus); + if (adap == NULL) { + i2c_dev_device_data->client = NULL; + printk(KERN_ERR "get i2c bus %d adapter fail.\n", i2c_dev_device_data->i2c_bus); + continue; + } + client = i2c_new_client_device(adap, &i2c_dev_device_info[i]); + if (!client) { + i2c_dev_device_data->client = NULL; + printk(KERN_ERR "Failed to register i2c dev device %d at bus %d!\n", + i2c_dev_device_data->i2c_addr, i2c_dev_device_data->i2c_bus); + } else { + i2c_dev_device_data->client = client; + } + i2c_put_adapter(adap); + } + return 0; +} + +static void __exit rg_i2c_dev_device_exit(void) +{ + int i; + i2c_dev_device_t *i2c_dev_device_data; + + RG_I2C_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(i2c_dev_device_info) - 1; i >= 0; i--) { + i2c_dev_device_data = i2c_dev_device_info[i].platform_data; + if (i2c_dev_device_data->client) { + i2c_unregister_device(i2c_dev_device_data->client); + i2c_dev_device_data->client = NULL; + } + } +} + +module_init(rg_i2c_dev_device_init); +module_exit(rg_i2c_dev_device_exit); +MODULE_DESCRIPTION("RG I2C DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_io_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_io_dev_device.c new file mode 100644 index 000000000000..104fcfb8ad4b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_io_dev_device.c @@ -0,0 +1,138 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_io_dev_device_debug = 0; +static int g_rg_io_dev_device_error = 0; + +module_param(g_rg_io_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_io_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_IO_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_io_dev_device_debug) { \ + printk(KERN_INFO "[RG_IO_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_IO_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_io_dev_device_error) { \ + printk(KERN_ERR "[RG_IO_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static io_dev_device_t io_dev_device_data0 = { + .io_dev_name = "cpld0", + .io_base = 0x700, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static io_dev_device_t io_dev_device_data1 = { + .io_dev_name = "cpld1", + .io_base = 0x900, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static io_dev_device_t io_dev_device_data2 = { + .io_dev_name = "cpld2", + .io_base = 0xb00, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static io_dev_device_t io_dev_device_data3 = { + .io_dev_name = "cpld3", + .io_base = 0x900, + .io_len = 0x2000, + .indirect_addr = 1, + .wr_data = 0xfb, + .addr_low = 0xfc, + .addr_high = 0xfd, + .rd_data = 0xfe, + .opt_ctl = 0xff, +}; + +static void rg_io_dev_device_release(struct device *dev) +{ + return; +} + +static struct platform_device io_dev_device[] = { + { + .name = "rg-io-dev", + .id = 1, + .dev = { + .platform_data = &io_dev_device_data0, + .release = rg_io_dev_device_release, + }, + }, + { + .name = "rg-io-dev", + .id = 2, + .dev = { + .platform_data = &io_dev_device_data1, + .release = rg_io_dev_device_release, + }, + }, + { + .name = "rg-io-dev", + .id = 3, + .dev = { + .platform_data = &io_dev_device_data2, + .release = rg_io_dev_device_release, + }, + }, + { + .name = "rg-io-dev", + .id = 4, + .dev = { + .platform_data = &io_dev_device_data3, + .release = rg_io_dev_device_release, + }, + }, +}; + +static int __init rg_io_dev_device_init(void) +{ + int i; + int ret = 0; + io_dev_device_t *io_dev_device_data; + + RG_IO_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(io_dev_device); i++) { + io_dev_device_data = io_dev_device[i].dev.platform_data; + ret = platform_device_register(&io_dev_device[i]); + if (ret < 0) { + io_dev_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-io-dev.%d register failed!\n", i + 1); + } else { + io_dev_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_io_dev_device_exit(void) +{ + int i; + io_dev_device_t *io_dev_device_data; + + RG_IO_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(io_dev_device) - 1; i >= 0; i--) { + io_dev_device_data = io_dev_device[i].dev.platform_data; + if (io_dev_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&io_dev_device[i]); + } + } +} + +module_init(rg_io_dev_device_init); +module_exit(rg_io_dev_device_exit); +MODULE_DESCRIPTION("RG IO DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_lpc_drv_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_lpc_drv_device.c new file mode 100644 index 000000000000..fb34291555a0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_lpc_drv_device.c @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_lpc_drv_device_debug = 0; +static int g_rg_lpc_drv_device_error = 0; + +module_param(g_rg_lpc_drv_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_lpc_drv_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_LPC_DRV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_lpc_drv_device_debug) { \ + printk(KERN_INFO "[RG_LPC_DRV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_LPC_DRV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_lpc_drv_device_error) { \ + printk(KERN_ERR "[RG_LPC_DRV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static lpc_drv_device_t lpc_drv_device_data_0 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0x700, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x84, +}; + +static lpc_drv_device_t lpc_drv_device_data_1 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0x900, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x88, +}; + +static lpc_drv_device_t lpc_drv_device_data_2 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0xb00, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x90, +}; + +static void rg_lpc_drv_device_release(struct device *dev) +{ + return; +} + +static struct platform_device lpc_drv_device[] = { + { + .name = "rg-lpc", + .id = 1, + .dev = { + .platform_data = &lpc_drv_device_data_0, + .release = rg_lpc_drv_device_release, + }, + }, + { + .name = "rg-lpc", + .id = 2, + .dev = { + .platform_data = &lpc_drv_device_data_1, + .release = rg_lpc_drv_device_release, + }, + }, + { + .name = "rg-lpc", + .id = 3, + .dev = { + .platform_data = &lpc_drv_device_data_2, + .release = rg_lpc_drv_device_release, + }, + }, +}; + +static int __init rg_lpc_drv_device_init(void) +{ + int i; + int ret = 0; + lpc_drv_device_t *lpc_drv_device_data; + + RG_LPC_DRV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(lpc_drv_device); i++) { + lpc_drv_device_data = lpc_drv_device[i].dev.platform_data; + ret = platform_device_register(&lpc_drv_device[i]); + if (ret < 0) { + lpc_drv_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-lpc.%d register failed!\n", i + 1); + } else { + lpc_drv_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_lpc_drv_device_exit(void) +{ + int i; + lpc_drv_device_t *lpc_drv_device_data; + + RG_LPC_DRV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(lpc_drv_device) - 1; i >= 0; i--) { + lpc_drv_device_data = lpc_drv_device[i].dev.platform_data; + if (lpc_drv_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&lpc_drv_device[i]); + } + } +} + +module_init(rg_lpc_drv_device_init); +module_exit(rg_lpc_drv_device_exit); +MODULE_DESCRIPTION("RG LPC DRV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_pcie_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_pcie_dev_device.c new file mode 100644 index 000000000000..ee7992c0e96f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_pcie_dev_device.c @@ -0,0 +1,93 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_pcie_dev_device_debug = 0; +static int g_rg_pcie_dev_device_error = 0; + +module_param(g_rg_pcie_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_pcie_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_pcie_dev_device_debug) { \ + printk(KERN_INFO "[RG_PCIE_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_PCIE_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_pcie_dev_device_error) { \ + printk(KERN_ERR "[RG_PCIE_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static pci_dev_device_t pcie_dev_device_data0 = { + .pci_dev_name = "fpga0", + .pci_domain = 0x0000, + .pci_bus = 0x08, + .pci_slot = 0x00, + .pci_fn = 0, + .pci_bar = 0, + .bus_width = 4, + .upg_ctrl_base = 0xa00, + .upg_flash_base = 0x2f0000, +}; + +static void rg_pcie_dev_device_release(struct device *dev) +{ + return; +} + +static struct platform_device pcie_dev_device[] = { + { + .name = "rg-pci-dev", + .id = 1, + .dev = { + .platform_data = &pcie_dev_device_data0, + .release = rg_pcie_dev_device_release, + }, + }, +}; + +static int __init rg_pcie_dev_device_init(void) +{ + int i; + int ret = 0; + pci_dev_device_t *pcie_dev_device_data; + + RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(pcie_dev_device); i++) { + pcie_dev_device_data = pcie_dev_device[i].dev.platform_data; + ret = platform_device_register(&pcie_dev_device[i]); + if (ret < 0) { + pcie_dev_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-pci-dev.%d register failed!\n", i + 1); + } else { + pcie_dev_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_pcie_dev_device_exit(void) +{ + int i; + pci_dev_device_t *pcie_dev_device_data; + + RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(pcie_dev_device) - 1; i >= 0; i--) { + pcie_dev_device_data = pcie_dev_device[i].dev.platform_data; + if (pcie_dev_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&pcie_dev_device[i]); + } + } +} + +module_init(rg_pcie_dev_device_init); +module_exit(rg_pcie_dev_device_exit); +MODULE_DESCRIPTION("RG PCIE DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_wdt_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_wdt_device.c new file mode 100644 index 000000000000..5296c239fd8e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/modules/driver/rg_wdt_device.c @@ -0,0 +1,104 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_wdt_device_debug = 0; +static int g_rg_wdt_device_error = 0; + +module_param(g_rg_wdt_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_wdt_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_WDT_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_wdt_device_debug) { \ + printk(KERN_INFO "[RG_WDT_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_WDT_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_wdt_device_error) { \ + printk(KERN_ERR "[RG_WDT_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static rg_wdt_device_t rg_wdt_device_data_0 = { + .feed_wdt_type = 2, + .hw_margin = 180000, + .feed_time = 30000, + .config_dev_name = "/dev/cpld5", + .config_mode = 2, + .priv_func_mode = 4, + .enable_reg = 0x4c, + .enable_val = 0x1, + .disable_val = 0x0, + .enable_mask = 0x1, + .timeout_cfg_reg = 0x4d, + .hw_algo = "toggle", + .wdt_config_mode.logic_wdt = { + .feed_dev_name = "/dev/cpld5", + .feed_reg = 0x4c, + .active_val = 0x1, + .logic_func_mode = 0x1, + }, + .timer_accuracy = 6000, /* 6s */ + .sysfs_index = SYSFS_NO_CFG, +}; + +static void rg_wdt_device_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_wdt_device[] = { + { + .name = "rg_wdt", + .id = 0, + .dev = { + .platform_data = &rg_wdt_device_data_0, + .release = rg_wdt_device_release, + }, + }, +}; + +static int __init rg_wdt_device_init(void) +{ + int i; + int ret = 0; + rg_wdt_device_t *rg_wdt_device_data; + + RG_WDT_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(rg_wdt_device); i++) { + rg_wdt_device_data = rg_wdt_device[i].dev.platform_data; + ret = platform_device_register(&rg_wdt_device[i]); + if (ret < 0) { + rg_wdt_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-wdt.%d register failed!\n", i + 1); + } else { + rg_wdt_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_wdt_device_exit(void) +{ + int i; + rg_wdt_device_t *rg_wdt_device_data; + + RG_WDT_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(rg_wdt_device) - 1; i >= 0; i--) { + rg_wdt_device_data = rg_wdt_device[i].dev.platform_data; + if (rg_wdt_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&rg_wdt_device[i]); + } + } +} + +module_init(rg_wdt_device_init); +module_exit(rg_wdt_device_exit); +MODULE_DESCRIPTION("RG WDT Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-CPLD.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-CPLD.cfg new file mode 100755 index 000000000000..a5f56d5cddb2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-CPLD.cfg @@ -0,0 +1,20 @@ +#cpld_id: 0:CPLD_A 1:CPLD_B +cpld_i2c_dev.bus_0_2=2 +cpld_i2c_dev.addr_0_2=0x1d +cpld_i2c_dev.bus_0_3=2 +cpld_i2c_dev.addr_0_3=0x2d +cpld_i2c_dev.bus_0_4=4 +cpld_i2c_dev.addr_0_4=0x3d + +#cpld_id: 0:X86_CPLD, 1:MAC_CPLDA, 2:MAC_CPLDB +cpld_lpc_dev_0_0=0x700 +cpld_lpc_dev_0_1=0x900 + +mode_cpld_0_0=lpc +mode_cpld_0_1=lpc +mode_cpld_0_2=i2c +mode_cpld_0_3=i2c +mode_cpld_0_4=i2c + +# cpld number +dev_num_4_0=5 diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-FAN.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-FAN.cfg new file mode 100755 index 000000000000..9a95a177d00b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-FAN.cfg @@ -0,0 +1,413 @@ +# fan number +dev_num_1_0=6 + +# fan motor number +dev_num_1_5=2 + +dev_present_status.mode_1_1=config +dev_present_status.src_1_1=cpld +dev_present_status.frmt_1_1=bit +dev_present_status.pola_1_1=negative +dev_present_status.addr_1_1=0x00040037 +dev_present_status.len_1_1=1 +dev_present_status.bit_offset_1_1=5 + +dev_present_status.mode_1_2=config +dev_present_status.src_1_2=cpld +dev_present_status.frmt_1_2=bit +dev_present_status.pola_1_2=negative +dev_present_status.addr_1_2=0x00040037 +dev_present_status.len_1_2=1 +dev_present_status.bit_offset_1_2=4 + +dev_present_status.mode_1_3=config +dev_present_status.src_1_3=cpld +dev_present_status.frmt_1_3=bit +dev_present_status.pola_1_3=negative +dev_present_status.addr_1_3=0x00040037 +dev_present_status.len_1_3=1 +dev_present_status.bit_offset_1_3=3 + +dev_present_status.mode_1_4=config +dev_present_status.src_1_4=cpld +dev_present_status.frmt_1_4=bit +dev_present_status.pola_1_4=negative +dev_present_status.addr_1_4=0x00040037 +dev_present_status.len_1_4=1 +dev_present_status.bit_offset_1_4=2 + +dev_present_status.mode_1_5=config +dev_present_status.src_1_5=cpld +dev_present_status.frmt_1_5=bit +dev_present_status.pola_1_5=negative +dev_present_status.addr_1_5=0x00040037 +dev_present_status.len_1_5=1 +dev_present_status.bit_offset_1_5=1 + +dev_present_status.mode_1_6=config +dev_present_status.src_1_6=cpld +dev_present_status.frmt_1_6=bit +dev_present_status.pola_1_6=negative +dev_present_status.addr_1_6=0x00040037 +dev_present_status.len_1_6=1 +dev_present_status.bit_offset_1_6=0 + +fan_roll_status.mode_1_0=config +fan_roll_status.int_cons_1_0= +fan_roll_status.src_1_0=cpld +fan_roll_status.frmt_1_0=bit +fan_roll_status.pola_1_0=positive +fan_roll_status.fpath_1_0= +fan_roll_status.addr_1_0=0x00040038 +fan_roll_status.len_1_0=1 +fan_roll_status.bit_offset_1_0=5 + +fan_roll_status.mode_1_1=config +fan_roll_status.int_cons_1_1= +fan_roll_status.src_1_1=cpld +fan_roll_status.frmt_1_1=bit +fan_roll_status.pola_1_1=positive +fan_roll_status.fpath_1_1= +fan_roll_status.addr_1_1=0x00040039 +fan_roll_status.len_1_1=1 +fan_roll_status.bit_offset_1_1=5 + +fan_roll_status.mode_2_0=config +fan_roll_status.int_cons_2_0= +fan_roll_status.src_2_0=cpld +fan_roll_status.frmt_2_0=bit +fan_roll_status.pola_2_0=positive +fan_roll_status.fpath_2_0= +fan_roll_status.addr_2_0=0x00040038 +fan_roll_status.len_2_0=1 +fan_roll_status.bit_offset_2_0=4 + +fan_roll_status.mode_2_1=config +fan_roll_status.int_cons_2_1= +fan_roll_status.src_2_1=cpld +fan_roll_status.frmt_2_1=bit +fan_roll_status.pola_2_1=positive +fan_roll_status.fpath_2_1= +fan_roll_status.addr_2_1=0x00040039 +fan_roll_status.len_2_1=1 +fan_roll_status.bit_offset_2_1=4 + +fan_roll_status.mode_3_0=config +fan_roll_status.int_cons_3_0= +fan_roll_status.src_3_0=cpld +fan_roll_status.frmt_3_0=bit +fan_roll_status.pola_3_0=positive +fan_roll_status.fpath_3_0= +fan_roll_status.addr_3_0=0x00040038 +fan_roll_status.len_3_0=1 +fan_roll_status.bit_offset_3_0=3 + +fan_roll_status.mode_3_1=config +fan_roll_status.int_cons_3_1= +fan_roll_status.src_3_1=cpld +fan_roll_status.frmt_3_1=bit +fan_roll_status.pola_3_1=positive +fan_roll_status.fpath_3_1= +fan_roll_status.addr_3_1=0x00040039 +fan_roll_status.len_3_1=1 +fan_roll_status.bit_offset_3_1=3 + +fan_roll_status.mode_4_0=config +fan_roll_status.int_cons_4_0= +fan_roll_status.src_4_0=cpld +fan_roll_status.frmt_4_0=bit +fan_roll_status.pola_4_0=positive +fan_roll_status.fpath_4_0= +fan_roll_status.addr_4_0=0x00040038 +fan_roll_status.len_4_0=1 +fan_roll_status.bit_offset_4_0=2 + +fan_roll_status.mode_4_1=config +fan_roll_status.int_cons_4_1= +fan_roll_status.src_4_1=cpld +fan_roll_status.frmt_4_1=bit +fan_roll_status.pola_4_1=positive +fan_roll_status.fpath_4_1= +fan_roll_status.addr_4_1=0x00040039 +fan_roll_status.len_4_1=1 +fan_roll_status.bit_offset_4_1=2 + +fan_roll_status.mode_5_0=config +fan_roll_status.int_cons_5_0= +fan_roll_status.src_5_0=cpld +fan_roll_status.frmt_5_0=bit +fan_roll_status.pola_5_0=positive +fan_roll_status.fpath_5_0= +fan_roll_status.addr_5_0=0x00040038 +fan_roll_status.len_5_0=1 +fan_roll_status.bit_offset_5_0=1 + +fan_roll_status.mode_5_1=config +fan_roll_status.int_cons_5_1= +fan_roll_status.src_5_1=cpld +fan_roll_status.frmt_5_1=bit +fan_roll_status.pola_5_1=positive +fan_roll_status.fpath_5_1= +fan_roll_status.addr_5_1=0x00040039 +fan_roll_status.len_5_1=1 +fan_roll_status.bit_offset_5_1=1 + +fan_roll_status.mode_6_0=config +fan_roll_status.int_cons_6_0= +fan_roll_status.src_6_0=cpld +fan_roll_status.frmt_6_0=bit +fan_roll_status.pola_6_0=positive +fan_roll_status.fpath_6_0= +fan_roll_status.addr_6_0=0x00040038 +fan_roll_status.len_6_0=1 +fan_roll_status.bit_offset_6_0=0 + +fan_roll_status.mode_6_1=config +fan_roll_status.int_cons_6_1= +fan_roll_status.src_6_1=cpld +fan_roll_status.frmt_6_1=bit +fan_roll_status.pola_6_1=positive +fan_roll_status.fpath_6_1= +fan_roll_status.addr_6_1=0x00040039 +fan_roll_status.len_6_1=1 +fan_roll_status.bit_offset_6_1=0 + +fan_speed.mode_1_0=config +fan_speed.int_cons_1_0= +fan_speed.src_1_0=cpld +fan_speed.frmt_1_0=num_bytes +fan_speed.pola_1_0=negative +fan_speed.fpath_1_0= +fan_speed.addr_1_0=0x00040070 +fan_speed.len_1_0=2 +fan_speed.bit_offset_1_0= + +fan_speed.mode_1_1=config +fan_speed.int_cons_1_1= +fan_speed.src_1_1=cpld +fan_speed.frmt_1_1=num_bytes +fan_speed.pola_1_1=negative +fan_speed.fpath_1_1= +fan_speed.addr_1_1=0x0004007c +fan_speed.len_1_1=2 +fan_speed.bit_offset_1_1= + +fan_speed.mode_2_0=config +fan_speed.int_cons_2_0= +fan_speed.src_2_0=cpld +fan_speed.frmt_2_0=num_bytes +fan_speed.pola_2_0=negative +fan_speed.fpath_2_0= +fan_speed.addr_2_0=0x0004006e +fan_speed.len_2_0=2 +fan_speed.bit_offset_2_0= + +fan_speed.mode_2_1=config +fan_speed.int_cons_2_1= +fan_speed.src_2_1=cpld +fan_speed.frmt_2_1=num_bytes +fan_speed.pola_2_1=negative +fan_speed.fpath_2_1= +fan_speed.addr_2_1=0x0004007a +fan_speed.len_2_1=2 +fan_speed.bit_offset_2_1= + +fan_speed.mode_3_0=config +fan_speed.int_cons_3_0= +fan_speed.src_3_0=cpld +fan_speed.frmt_3_0=num_bytes +fan_speed.pola_3_0=negative +fan_speed.fpath_3_0= +fan_speed.addr_3_0=0x0004006c +fan_speed.len_3_0=2 +fan_speed.bit_offset_3_0= + +fan_speed.mode_3_1=config +fan_speed.int_cons_3_1= +fan_speed.src_3_1=cpld +fan_speed.frmt_3_1=num_bytes +fan_speed.pola_3_1=negative +fan_speed.fpath_3_1= +fan_speed.addr_3_1=0x00040078 +fan_speed.len_3_1=2 +fan_speed.bit_offset_3_1= + +fan_speed.mode_4_0=config +fan_speed.int_cons_4_0= +fan_speed.src_4_0=cpld +fan_speed.frmt_4_0=num_bytes +fan_speed.pola_4_0=negative +fan_speed.fpath_4_0= +fan_speed.addr_4_0=0x0004006a +fan_speed.len_4_0=2 +fan_speed.bit_offset_4_0= + +fan_speed.mode_4_1=config +fan_speed.int_cons_4_1= +fan_speed.src_4_1=cpld +fan_speed.frmt_4_1=num_bytes +fan_speed.pola_4_1=negative +fan_speed.fpath_4_1= +fan_speed.addr_4_1=0x00040076 +fan_speed.len_4_1=2 +fan_speed.bit_offset_4_1= + +fan_speed.mode_5_0=config +fan_speed.int_cons_5_0= +fan_speed.src_5_0=cpld +fan_speed.frmt_5_0=num_bytes +fan_speed.pola_5_0=negative +fan_speed.fpath_5_0= +fan_speed.addr_5_0=0x00040068 +fan_speed.len_5_0=2 +fan_speed.bit_offset_5_0= + +fan_speed.mode_5_1=config +fan_speed.int_cons_5_1= +fan_speed.src_5_1=cpld +fan_speed.frmt_5_1=num_bytes +fan_speed.pola_5_1=negative +fan_speed.fpath_5_1= +fan_speed.addr_5_1=0x00040074 +fan_speed.len_5_1=2 +fan_speed.bit_offset_5_1= + +fan_speed.mode_6_0=config +fan_speed.int_cons_6_0= +fan_speed.src_6_0=cpld +fan_speed.frmt_6_0=num_bytes +fan_speed.pola_6_0=negative +fan_speed.fpath_6_0= +fan_speed.addr_6_0=0x00040066 +fan_speed.len_6_0=2 +fan_speed.bit_offset_6_0= + +fan_speed.mode_6_1=config +fan_speed.int_cons_6_1= +fan_speed.src_6_1=cpld +fan_speed.frmt_6_1=num_bytes +fan_speed.pola_6_1=negative +fan_speed.fpath_6_1= +fan_speed.addr_6_1=0x00040072 +fan_speed.len_6_1=2 +fan_speed.bit_offset_6_1= + +fan_ratio.mode_1_0=config +fan_ratio.int_cons_1_0= +fan_ratio.src_1_0=cpld +fan_ratio.frmt_1_0=byte +fan_ratio.pola_1_0= +fan_ratio.fpath_1_0= +fan_ratio.addr_1_0=0x00040065 +fan_ratio.len_1_0=1 +fan_ratio.bit_offset_1_0= + +fan_ratio.mode_1_1=config +fan_ratio.int_cons_1_1= +fan_ratio.src_1_1=cpld +fan_ratio.frmt_1_1=byte +fan_ratio.pola_1_1= +fan_ratio.fpath_1_1= +fan_ratio.addr_1_1=0x00040065 +fan_ratio.len_1_1=1 +fan_ratio.bit_offset_1_1= + +fan_ratio.mode_2_0=config +fan_ratio.int_cons_2_0= +fan_ratio.src_2_0=cpld +fan_ratio.frmt_2_0=byte +fan_ratio.pola_2_0= +fan_ratio.fpath_2_0= +fan_ratio.addr_2_0=0x00040064 +fan_ratio.len_2_0=1 +fan_ratio.bit_offset_2_0= + +fan_ratio.mode_2_1=config +fan_ratio.int_cons_2_1= +fan_ratio.src_2_1=cpld +fan_ratio.frmt_2_1=byte +fan_ratio.pola_2_1= +fan_ratio.fpath_2_1= +fan_ratio.addr_2_1=0x00040064 +fan_ratio.len_2_1=1 +fan_ratio.bit_offset_2_1= + +fan_ratio.mode_3_0=config +fan_ratio.int_cons_3_0= +fan_ratio.src_3_0=cpld +fan_ratio.frmt_3_0=byte +fan_ratio.pola_3_0= +fan_ratio.fpath_3_0= +fan_ratio.addr_3_0=0x00040063 +fan_ratio.len_3_0=1 +fan_ratio.bit_offset_3_0= + +fan_ratio.mode_3_1=config +fan_ratio.int_cons_3_1= +fan_ratio.src_3_1=cpld +fan_ratio.frmt_3_1=byte +fan_ratio.pola_3_1= +fan_ratio.fpath_3_1= +fan_ratio.addr_3_1=0x00040063 +fan_ratio.len_3_1=1 +fan_ratio.bit_offset_3_1= + +fan_ratio.mode_4_0=config +fan_ratio.int_cons_4_0= +fan_ratio.src_4_0=cpld +fan_ratio.frmt_4_0=byte +fan_ratio.pola_4_0= +fan_ratio.fpath_4_0= +fan_ratio.addr_4_0=0x00040062 +fan_ratio.len_4_0=1 +fan_ratio.bit_offset_4_0= + +fan_ratio.mode_4_1=config +fan_ratio.int_cons_4_1= +fan_ratio.src_4_1=cpld +fan_ratio.frmt_4_1=byte +fan_ratio.pola_4_1= +fan_ratio.fpath_4_1= +fan_ratio.addr_4_1=0x00040062 +fan_ratio.len_4_1=1 +fan_ratio.bit_offset_4_1= + +fan_ratio.mode_5_0=config +fan_ratio.int_cons_5_0= +fan_ratio.src_5_0=cpld +fan_ratio.frmt_5_0=byte +fan_ratio.pola_5_0= +fan_ratio.fpath_5_0= +fan_ratio.addr_5_0=0x00040061 +fan_ratio.len_5_0=1 +fan_ratio.bit_offset_5_0= + +fan_ratio.mode_5_1=config +fan_ratio.int_cons_5_1= +fan_ratio.src_5_1=cpld +fan_ratio.frmt_5_1=byte +fan_ratio.pola_5_1= +fan_ratio.fpath_5_1= +fan_ratio.addr_5_1=0x00040061 +fan_ratio.len_5_1=1 +fan_ratio.bit_offset_5_1= + +fan_ratio.mode_6_0=config +fan_ratio.int_cons_6_0= +fan_ratio.src_6_0=cpld +fan_ratio.frmt_6_0=byte +fan_ratio.pola_6_0= +fan_ratio.fpath_6_0= +fan_ratio.addr_6_0=0x00040060 +fan_ratio.len_6_0=1 +fan_ratio.bit_offset_6_0= + +fan_ratio.mode_6_1=config +fan_ratio.int_cons_6_1= +fan_ratio.src_6_1=cpld +fan_ratio.frmt_6_1=byte +fan_ratio.pola_6_1= +fan_ratio.fpath_6_1= +fan_ratio.addr_6_1=0x00040060 +fan_ratio.len_6_1=1 +fan_ratio.bit_offset_6_1= \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-PSU.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-PSU.cfg new file mode 100755 index 000000000000..687d9037d09e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-PSU.cfg @@ -0,0 +1,50 @@ +#psu number +dev_num_2_0=2 + +psu_status.mode_1_0=config +psu_status.src_1_0=cpld +psu_status.frmt_1_0=bit +psu_status.pola_1_0=negative +psu_status.addr_1_0=0x00020034 +psu_status.len_1_0=1 +psu_status.bit_offset_1_0=0 + +psu_status.mode_1_1=config +psu_status.src_1_1=cpld +psu_status.frmt_1_1=bit +psu_status.pola_1_1=positive +psu_status.addr_1_1=0x00020034 +psu_status.len_1_1=1 +psu_status.bit_offset_1_1=1 + +psu_status.mode_1_2=config +psu_status.src_1_2=cpld +psu_status.frmt_1_2=bit +psu_status.pola_1_2=negative +psu_status.addr_1_2=0x00020034 +psu_status.len_1_2=1 +psu_status.bit_offset_1_2=2 + +psu_status.mode_2_0=config +psu_status.src_2_0=cpld +psu_status.frmt_2_0=bit +psu_status.pola_2_0=negative +psu_status.addr_2_0=0x00020034 +psu_status.len_2_0=1 +psu_status.bit_offset_2_0=4 + +psu_status.mode_2_1=config +psu_status.src_2_1=cpld +psu_status.frmt_2_1=bit +psu_status.pola_2_1=positive +psu_status.addr_2_1=0x00020034 +psu_status.len_2_1=1 +psu_status.bit_offset_2_1=5 + +psu_status.mode_2_2=config +psu_status.src_2_2=cpld +psu_status.frmt_2_2=bit +psu_status.pola_2_2=negative +psu_status.addr_2_2=0x00020034 +psu_status.len_2_2=1 +psu_status.bit_offset_2_2=6 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-SFF.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-SFF.cfg new file mode 100755 index 000000000000..20c37e3d66e8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/TCS8400-SFF.cfg @@ -0,0 +1,292 @@ +# sff number +dev_num_3_0=32 + +sff_dir_name_1 =sff1 +sff_dir_name_2 =sff2 +sff_dir_name_3 =sff3 +sff_dir_name_4 =sff4 +sff_dir_name_5 =sff5 +sff_dir_name_6 =sff6 +sff_dir_name_7 =sff7 +sff_dir_name_8 =sff8 +sff_dir_name_9 =sff9 +sff_dir_name_10 =sff10 +sff_dir_name_11 =sff11 +sff_dir_name_12 =sff12 +sff_dir_name_13 =sff13 +sff_dir_name_14 =sff14 +sff_dir_name_15 =sff15 +sff_dir_name_16 =sff16 +sff_dir_name_17 =sff17 +sff_dir_name_18 =sff18 +sff_dir_name_19 =sff19 +sff_dir_name_20 =sff20 +sff_dir_name_21 =sff21 +sff_dir_name_22 =sff22 +sff_dir_name_23 =sff23 +sff_dir_name_24 =sff24 +sff_dir_name_25 =sff25 +sff_dir_name_26 =sff26 +sff_dir_name_27 =sff27 +sff_dir_name_28 =sff28 +sff_dir_name_29 =sff29 +sff_dir_name_30 =sff30 +sff_dir_name_31 =sff31 +sff_dir_name_32 =sff32 + +# present +sff_cpld_reg.mode_1_8=config +sff_cpld_reg.src_1_8=cpld +sff_cpld_reg.frmt_1_8=bit +sff_cpld_reg.pola_1_8=negative +sff_cpld_reg.addr_1_8=0x00020030 +sff_cpld_reg.len_1_8=1 +sff_cpld_reg.bit_offset_1_8=0 + +sff_cpld_reg.mode_2_8=config +sff_cpld_reg.src_2_8=cpld +sff_cpld_reg.frmt_2_8=bit +sff_cpld_reg.pola_2_8=negative +sff_cpld_reg.addr_2_8=0x00020030 +sff_cpld_reg.len_2_8=1 +sff_cpld_reg.bit_offset_2_8=1 + +sff_cpld_reg.mode_3_8=config +sff_cpld_reg.src_3_8=cpld +sff_cpld_reg.frmt_3_8=bit +sff_cpld_reg.pola_3_8=negative +sff_cpld_reg.addr_3_8=0x00020030 +sff_cpld_reg.len_3_8=1 +sff_cpld_reg.bit_offset_3_8=2 + +sff_cpld_reg.mode_4_8=config +sff_cpld_reg.src_4_8=cpld +sff_cpld_reg.frmt_4_8=bit +sff_cpld_reg.pola_4_8=negative +sff_cpld_reg.addr_4_8=0x00020030 +sff_cpld_reg.len_4_8=1 +sff_cpld_reg.bit_offset_4_8=3 + +sff_cpld_reg.mode_5_8=config +sff_cpld_reg.src_5_8=cpld +sff_cpld_reg.frmt_5_8=bit +sff_cpld_reg.pola_5_8=negative +sff_cpld_reg.addr_5_8=0x00020030 +sff_cpld_reg.len_5_8=1 +sff_cpld_reg.bit_offset_5_8=4 + +sff_cpld_reg.mode_6_8=config +sff_cpld_reg.src_6_8=cpld +sff_cpld_reg.frmt_6_8=bit +sff_cpld_reg.pola_6_8=negative +sff_cpld_reg.addr_6_8=0x00020030 +sff_cpld_reg.len_6_8=1 +sff_cpld_reg.bit_offset_6_8=5 + +sff_cpld_reg.mode_7_8=config +sff_cpld_reg.src_7_8=cpld +sff_cpld_reg.frmt_7_8=bit +sff_cpld_reg.pola_7_8=negative +sff_cpld_reg.addr_7_8=0x00020030 +sff_cpld_reg.len_7_8=1 +sff_cpld_reg.bit_offset_7_8=6 + +sff_cpld_reg.mode_8_8=config +sff_cpld_reg.src_8_8=cpld +sff_cpld_reg.frmt_8_8=bit +sff_cpld_reg.pola_8_8=negative +sff_cpld_reg.addr_8_8=0x00020030 +sff_cpld_reg.len_8_8=1 +sff_cpld_reg.bit_offset_8_8=7 + +sff_cpld_reg.mode_9_8=config +sff_cpld_reg.src_9_8=cpld +sff_cpld_reg.frmt_9_8=bit +sff_cpld_reg.pola_9_8=negative +sff_cpld_reg.addr_9_8=0x00020031 +sff_cpld_reg.len_9_8=1 +sff_cpld_reg.bit_offset_9_8=0 + +sff_cpld_reg.mode_10_8=config +sff_cpld_reg.src_10_8=cpld +sff_cpld_reg.frmt_10_8=bit +sff_cpld_reg.pola_10_8=negative +sff_cpld_reg.addr_10_8=0x00020031 +sff_cpld_reg.len_10_8=1 +sff_cpld_reg.bit_offset_10_8=1 + +sff_cpld_reg.mode_11_8=config +sff_cpld_reg.src_11_8=cpld +sff_cpld_reg.frmt_11_8=bit +sff_cpld_reg.pola_11_8=negative +sff_cpld_reg.addr_11_8=0x00020031 +sff_cpld_reg.len_11_8=1 +sff_cpld_reg.bit_offset_11_8=2 + +sff_cpld_reg.mode_12_8=config +sff_cpld_reg.src_12_8=cpld +sff_cpld_reg.frmt_12_8=bit +sff_cpld_reg.pola_12_8=negative +sff_cpld_reg.addr_12_8=0x00020031 +sff_cpld_reg.len_12_8=1 +sff_cpld_reg.bit_offset_12_8=3 + +sff_cpld_reg.mode_13_8=config +sff_cpld_reg.src_13_8=cpld +sff_cpld_reg.frmt_13_8=bit +sff_cpld_reg.pola_13_8=negative +sff_cpld_reg.addr_13_8=0x00020031 +sff_cpld_reg.len_13_8=1 +sff_cpld_reg.bit_offset_13_8=4 + +sff_cpld_reg.mode_14_8=config +sff_cpld_reg.src_14_8=cpld +sff_cpld_reg.frmt_14_8=bit +sff_cpld_reg.pola_14_8=negative +sff_cpld_reg.addr_14_8=0x00020031 +sff_cpld_reg.len_14_8=1 +sff_cpld_reg.bit_offset_14_8=5 + +sff_cpld_reg.mode_15_8=config +sff_cpld_reg.src_15_8=cpld +sff_cpld_reg.frmt_15_8=bit +sff_cpld_reg.pola_15_8=negative +sff_cpld_reg.addr_15_8=0x00020031 +sff_cpld_reg.len_15_8=1 +sff_cpld_reg.bit_offset_15_8=6 + +sff_cpld_reg.mode_16_8=config +sff_cpld_reg.src_16_8=cpld +sff_cpld_reg.frmt_16_8=bit +sff_cpld_reg.pola_16_8=negative +sff_cpld_reg.addr_16_8=0x00020031 +sff_cpld_reg.len_16_8=1 +sff_cpld_reg.bit_offset_16_8=7 + +sff_cpld_reg.mode_17_8=config +sff_cpld_reg.src_17_8=cpld +sff_cpld_reg.frmt_17_8=bit +sff_cpld_reg.pola_17_8=negative +sff_cpld_reg.addr_17_8=0x00020032 +sff_cpld_reg.len_17_8=1 +sff_cpld_reg.bit_offset_17_8=0 + +sff_cpld_reg.mode_18_8=config +sff_cpld_reg.src_18_8=cpld +sff_cpld_reg.frmt_18_8=bit +sff_cpld_reg.pola_18_8=negative +sff_cpld_reg.addr_18_8=0x00020032 +sff_cpld_reg.len_18_8=1 +sff_cpld_reg.bit_offset_18_8=1 + +sff_cpld_reg.mode_19_8=config +sff_cpld_reg.src_19_8=cpld +sff_cpld_reg.frmt_19_8=bit +sff_cpld_reg.pola_19_8=negative +sff_cpld_reg.addr_19_8=0x00020032 +sff_cpld_reg.len_19_8=1 +sff_cpld_reg.bit_offset_19_8=2 + +sff_cpld_reg.mode_20_8=config +sff_cpld_reg.src_20_8=cpld +sff_cpld_reg.frmt_20_8=bit +sff_cpld_reg.pola_20_8=negative +sff_cpld_reg.addr_20_8=0x00020032 +sff_cpld_reg.len_20_8=1 +sff_cpld_reg.bit_offset_20_8=3 + +sff_cpld_reg.mode_21_8=config +sff_cpld_reg.src_21_8=cpld +sff_cpld_reg.frmt_21_8=bit +sff_cpld_reg.pola_21_8=negative +sff_cpld_reg.addr_21_8=0x00020032 +sff_cpld_reg.len_21_8=1 +sff_cpld_reg.bit_offset_21_8=4 + +sff_cpld_reg.mode_22_8=config +sff_cpld_reg.src_22_8=cpld +sff_cpld_reg.frmt_22_8=bit +sff_cpld_reg.pola_22_8=negative +sff_cpld_reg.addr_22_8=0x00020032 +sff_cpld_reg.len_22_8=1 +sff_cpld_reg.bit_offset_22_8=5 + +sff_cpld_reg.mode_23_8=config +sff_cpld_reg.src_23_8=cpld +sff_cpld_reg.frmt_23_8=bit +sff_cpld_reg.pola_23_8=negative +sff_cpld_reg.addr_23_8=0x00020032 +sff_cpld_reg.len_23_8=1 +sff_cpld_reg.bit_offset_23_8=6 + +sff_cpld_reg.mode_24_8=config +sff_cpld_reg.src_24_8=cpld +sff_cpld_reg.frmt_24_8=bit +sff_cpld_reg.pola_24_8=negative +sff_cpld_reg.addr_24_8=0x00020032 +sff_cpld_reg.len_24_8=1 +sff_cpld_reg.bit_offset_24_8=7 + +sff_cpld_reg.mode_25_8=config +sff_cpld_reg.src_25_8=cpld +sff_cpld_reg.frmt_25_8=bit +sff_cpld_reg.pola_25_8=negative +sff_cpld_reg.addr_25_8=0x00020033 +sff_cpld_reg.len_25_8=1 +sff_cpld_reg.bit_offset_25_8=0 + +sff_cpld_reg.mode_26_8=config +sff_cpld_reg.src_26_8=cpld +sff_cpld_reg.frmt_26_8=bit +sff_cpld_reg.pola_26_8=negative +sff_cpld_reg.addr_26_8=0x00020033 +sff_cpld_reg.len_26_8=1 +sff_cpld_reg.bit_offset_26_8=1 + +sff_cpld_reg.mode_27_8=config +sff_cpld_reg.src_27_8=cpld +sff_cpld_reg.frmt_27_8=bit +sff_cpld_reg.pola_27_8=negative +sff_cpld_reg.addr_27_8=0x00020033 +sff_cpld_reg.len_27_8=1 +sff_cpld_reg.bit_offset_27_8=2 + +sff_cpld_reg.mode_28_8=config +sff_cpld_reg.src_28_8=cpld +sff_cpld_reg.frmt_28_8=bit +sff_cpld_reg.pola_28_8=negative +sff_cpld_reg.addr_28_8=0x00020033 +sff_cpld_reg.len_28_8=1 +sff_cpld_reg.bit_offset_28_8=3 + +sff_cpld_reg.mode_29_8=config +sff_cpld_reg.src_29_8=cpld +sff_cpld_reg.frmt_29_8=bit +sff_cpld_reg.pola_29_8=negative +sff_cpld_reg.addr_29_8=0x00020033 +sff_cpld_reg.len_29_8=1 +sff_cpld_reg.bit_offset_29_8=4 + +sff_cpld_reg.mode_30_8=config +sff_cpld_reg.src_30_8=cpld +sff_cpld_reg.frmt_30_8=bit +sff_cpld_reg.pola_30_8=negative +sff_cpld_reg.addr_30_8=0x00020033 +sff_cpld_reg.len_30_8=1 +sff_cpld_reg.bit_offset_30_8=5 + +sff_cpld_reg.mode_31_8=config +sff_cpld_reg.src_31_8=cpld +sff_cpld_reg.frmt_31_8=bit +sff_cpld_reg.pola_31_8=negative +sff_cpld_reg.addr_31_8=0x00020033 +sff_cpld_reg.len_31_8=1 +sff_cpld_reg.bit_offset_31_8=6 + +sff_cpld_reg.mode_32_8=config +sff_cpld_reg.src_32_8=cpld +sff_cpld_reg.frmt_32_8=bit +sff_cpld_reg.pola_32_8=negative +sff_cpld_reg.addr_32_8=0x00020033 +sff_cpld_reg.len_32_8=1 +sff_cpld_reg.bit_offset_32_8=7 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/cfg_file_name b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/cfg_file_name new file mode 100755 index 000000000000..f1a342c5ce58 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/plat_sysfs_cfg/cfg_file_name @@ -0,0 +1,4 @@ +TCS8400-CPLD +TCS8400-FAN +TCS8400-PSU +TCS8400-SFF \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/s3ip_config/customer_sysfs.json b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/s3ip_config/customer_sysfs.json new file mode 100755 index 000000000000..cc02b9e68b50 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/s3ip_config/customer_sysfs.json @@ -0,0 +1,70 @@ +{ + "s3ip_syfs_paths": [ + { + "path": "/sys_switch/temp_sensor", + "type" : "path", + "value" : "/sys/s3ip/temp_sensor", + "description": "temperature sensor information" + }, + { + "path": "/sys_switch/vol_sensor", + "type" : "path", + "value" : "/sys/s3ip/vol_sensor", + "description": "voltage sensor information" + }, + { + "path": "/sys_switch/curr_sensor", + "type" : "path", + "value" : "/sys/s3ip/curr_sensor", + "description": "current sensor information" + }, + { + "path": "/sys_switch/syseeprom", + "type" : "path", + "value" : "/sys/s3ip/syseeprom", + "description": "ONIE EEPROM" + }, + { + "path": "/sys_switch/fan", + "type" : "path", + "value" : "/sys/s3ip/fan", + "description": "fan information" + }, + { + "path": "/sys_switch/psu", + "type" : "path", + "value" : "/sys/s3ip/psu", + "description": "psu information" + }, + { + "path": "/sys_switch/transceiver", + "type" : "path", + "value" : "/sys/s3ip/transceiver", + "description": "transceiver information" + }, + { + "path": "/sys_switch/sysled", + "type" : "path", + "value" : "/sys/s3ip/sysled", + "description": "sysled information" + }, + { + "path": "/sys_switch/fpga", + "type" : "path", + "value" : "/sys/s3ip/fpga", + "description": "FPGA information" + }, + { + "path": "/sys_switch/cpld", + "type" : "path", + "value" : "/sys/s3ip/cpld", + "description": "CPLD information" + }, + { + "path": "/sys_switch/watchdog", + "type" : "path", + "value" : "/sys/s3ip/watchdog", + "description": "watchdog information" + } + ] +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs8400/setup.py b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/setup.py new file mode 100755 index 000000000000..c0875b78fcde --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs8400/setup.py @@ -0,0 +1,40 @@ +from setuptools import setup + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Ruijie TCS8400 Platforms', + license='Apache 2.0', + author='SONiC Team', + author_email='sonic_rd@ruijie.com.cn', + url='', + maintainer='Ruijie TCS8400', + maintainer_email='', + packages=[ + 'sonic_platform', + 'plat_hal', + 'rjutil', + 'eepromutil', + 'hal-config', + 'config', + ], + py_modules=[ + 'hal_pltfm', + 'platform_util', + 'platform_intf', + ], + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Plugins', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3.9', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) + diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/Makefile b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/Makefile new file mode 100755 index 000000000000..d4e576cf6a3f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/Makefile @@ -0,0 +1,28 @@ +PWD = $(shell pwd) +DIR_KERNEL_SRC = $(PWD)/modules/driver +EXTRA_CFLAGS:= -I$(M)/include +EXTRA_CFLAGS+= -Wall +SUB_BUILD_DIR = $(PWD)/build +INSTALL_DIR = $(SUB_BUILD_DIR)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR) +INSTALL_SCRIPT_DIR = $(SUB_BUILD_DIR)/usr/local/bin +INSTALL_LIB_DIR = $(SUB_BUILD_DIR)/usr/lib/python3/dist-packages +INSTALL_SYSFS_CFG_DIR = $(SUB_BUILD_DIR)/etc/plat_sysfs_cfg +INSTALL_S3IP_CONFIG_DIR = $(SUB_BUILD_DIR)/etc/s3ip + +all: + $(MAKE) -C $(KBUILD_OUTPUT) M=$(DIR_KERNEL_SRC) modules + @if [ ! -d ${INSTALL_DIR} ]; then mkdir -p ${INSTALL_DIR} ;fi + cp -r $(DIR_KERNEL_SRC)/*.ko $(INSTALL_DIR) + @if [ ! -d ${INSTALL_SCRIPT_DIR} ]; then mkdir -p ${INSTALL_SCRIPT_DIR} ;fi + cp -r $(PWD)/config/* $(INSTALL_SCRIPT_DIR) + @if [ ! -d ${INSTALL_LIB_DIR} ]; then mkdir -p ${INSTALL_LIB_DIR} ;fi + @if [ -d $(PWD)/hal-config/ ]; then cp -r $(PWD)/hal-config/* ${INSTALL_LIB_DIR} ;fi + @if [ ! -d ${INSTALL_SYSFS_CFG_DIR} ]; then mkdir -p ${INSTALL_SYSFS_CFG_DIR} ;fi + @if [ -d $(PWD)/plat_sysfs_cfg/ ]; then cp -r $(PWD)/plat_sysfs_cfg/* ${INSTALL_SYSFS_CFG_DIR} ;fi + @if [ ! -d ${INSTALL_S3IP_CONFIG_DIR} ]; then mkdir -p ${INSTALL_S3IP_CONFIG_DIR} ;fi + @if [ -d $(PWD)/s3ip_config/ ]; then cp -r $(PWD)/s3ip_config/* ${INSTALL_S3IP_CONFIG_DIR} ;fi +clean: + rm -f ${DIR_KERNEL_SRC}/*.o ${DIR_KERNEL_SRC}/*.ko ${DIR_KERNEL_SRC}/*.mod.c ${DIR_KERNEL_SRC}/.*.cmd ${DIR_KERNEL_SRC}/.*.mod + rm -f ${DIR_KERNEL_SRC}/Module.markers ${DIR_KERNEL_SRC}/Module.symvers ${DIR_KERNEL_SRC}/modules.order + rm -rf ${DIR_KERNEL_SRC}/.tmp_versions + rm -rf $(SUB_BUILD_DIR) diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_0x407c_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_0x407c_config.py new file mode 100755 index 000000000000..71fcb0ab43d6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_0x407c_config.py @@ -0,0 +1,1422 @@ +#!/usr/bin/python3 +from ruijiecommon import * + + +STARTMODULE = { + "xdpe_avscontrol":1, + "dev_monitor": 1, + "hal_fanctrl":1, + "hal_ledctrl":1, + "sff_temp_polling":1, + "rg_pmon_syslog":1, +} + +DEV_MONITOR_PARAM = { + "polling_time" : 10, + "psus": [ + {"name": "psu1", + "present": {"gettype": "io", "io_addr": 0x964, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu1pmbus", "name": "rg_fsp1200", "bus": 79, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu1frue2", "name": "24c02", "bus": 79, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu2", + "present": {"gettype": "io", "io_addr": 0x964, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu2pmbus", "name": "rg_fsp1200", "bus": 80, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu2frue2", "name": "24c02", "bus": 80, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu3", + "present": {"gettype": "io", "io_addr": 0x965, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu3pmbus", "name": "rg_fsp1200", "bus": 82, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu3frue2", "name": "24c02", "bus": 82, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu4", + "present": {"gettype": "io", "io_addr": 0x965, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu4pmbus", "name": "rg_fsp1200", "bus": 81, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu4frue2", "name": "24c02", "bus": 81, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "fans": [ + {"name": "fan1", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan1frue2", "name": "24c64", "bus": 90, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan2", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan2frue2", "name": "24c64", "bus": 98, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan3", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan3frue2", "name": "24c64", "bus": 91, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan4", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan4frue2", "name": "24c64", "bus": 99, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan5", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan5frue2", "name": "24c64", "bus": 92, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan6", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan6frue2", "name": "24c64", "bus": 100, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan7", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan7frue2", "name": "24c64", "bus": 93, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan8", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan8frue2", "name": "24c64", "bus": 101, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "others": [ + {"name":"eeprom", + "device":[ + {"id":"eeprom_1", "name":"24c02","bus":1, "loc":0x56, "attr":"eeprom"}, + ], + }, + {"name":"lm75", + "device":[ + {"id":"lm75_1", "name":"lm75","bus":63, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_2", "name":"lm75","bus":64, "loc":0x4f, "attr":"hwmon"}, + {"id":"lm75_3", "name":"lm75","bus":88, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_4", "name":"lm75","bus":89, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_5", "name":"lm75","bus":96, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_6", "name":"lm75","bus":97, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_7", "name":"lm75","bus":107, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_8", "name":"lm75","bus":109, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_9", "name":"lm75","bus":69, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_10", "name":"lm75","bus":70, "loc":0x4f, "attr":"hwmon"}, + {"id":"lm75_11", "name":"lm75","bus":114, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_12", "name":"lm75","bus":115, "loc":0x4f, "attr":"hwmon"}, + ], + }, + {"name":"mac_bsc", + "device":[ + {"id":"mac_bsc_1", "name":"rg_mac_bsc_th4","bus":74, "loc":0x44, "attr":"hwmon"}, + ], + }, + {"name":"ina3221", + "device":[ + {"id":"ina3221_1", "name":"rg_ina3221","bus":106, "loc":0x43, "attr":"hwmon"}, + ], + }, + {"name":"tps53622", + "device":[ + {"id":"tps53622_1", "name":"rg_tps53622","bus":106, "loc":0x60, "attr":"hwmon"}, + {"id":"tps53622_2", "name":"rg_tps53622","bus":106, "loc":0x6c, "attr":"hwmon"}, + ], + }, + {"name":"ucd90160", + "device":[ + {"id":"ucd90160_1", "name":"rg_ucd90160","bus":62, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_2", "name":"rg_ucd90160","bus":105, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_3", "name":"rg_ucd90160","bus":73, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_4", "name":"rg_ucd90160","bus":113, "loc":0x5b, "attr":"hwmon"}, + ], + }, + {"name":"tmp411", + "device":[ + {"id":"tmp411_1", "name":"tmp411","bus":71, "loc":0x4c, "attr":"hwmon"}, + {"id":"tmp411_2", "name":"tmp411","bus":72, "loc":0x4c, "attr":"hwmon"}, + ], + }, + ], +} + +CPLDVERSIONS = [ ] +MANUINFO_CONF = { + "bios": { + "key": "BIOS", + "head": True, + "next": "bmc" + }, + "bios_vendor": { + "parent": "bios", + "key": "Vendor", + "cmd": "dmidecode -t 0 |grep Vendor", + "pattern": r".*Vendor", + "separator": ":", + "arrt_index" : 1, + }, + "bios_version": { + "parent": "bios", + "key": "Version", + "cmd": "dmidecode -t 0 |grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "bios_date": { + "parent": "bios", + "key": "Release Date", + "cmd": "dmidecode -t 0 |grep Release", + "pattern": r".*Release Date", + "separator": ":", + "arrt_index" : 3, + }, + + "bmc": { + "key": "BMC", + "next": "onie" + }, + "bmc_version": { + "parent": "bmc", + "key": "Version", + "cmd": "ipmitool mc info |grep \"Firmware Revision\"", + "pattern": r".*Firmware Revision", + "separator": ":", + "arrt_index" : 1, + }, + + "onie": { + "key": "ONIE", + "next": "cpu" + }, + "onie_date": { + "parent": "onie", + "key": "Build Date", + "file": "/host/machine.conf", + "pattern": r"^onie_build_date", + "separator": "=", + "arrt_index" : 1, + }, + "onie_version": { + "parent": "onie", + "key": "Version", + "file": "/host/machine.conf", + "pattern": r"^onie_version", + "separator": "=", + "arrt_index" : 2, + }, + "onie_sub_version": { + "parent": "onie", + "key": "Sub Version", + "file": "/host/machine.conf", + "pattern": r"^onie_sub_version", + "separator": "=", + "arrt_index" : 3, + }, + + "cpu": { + "key": "CPU", + "next": "ssd" + }, + "cpu_vendor": { + "parent": "cpu", + "key": "Vendor", + "cmd": "dmidecode --type processor |grep Manufacturer", + "pattern": r".*Manufacturer", + "separator": ":", + "arrt_index" : 1, + }, + "cpu_model": { + "parent": "cpu", + "key": "Device Model", + "cmd": "dmidecode --type processor | grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "cpu_core": { + "parent": "cpu", + "key": "Core Count", + "cmd": "dmidecode --type processor | grep \"Core Count\"", + "pattern": r".*Core Count", + "separator": ":", + "arrt_index" : 3, + }, + "cpu_thread": { + "parent": "cpu", + "key": "Thread Count", + "cmd": "dmidecode --type processor | grep \"Thread Count\"", + "pattern": r".*Thread Count", + "separator": ":", + "arrt_index" : 4, + }, + + "ssd": { + "key": "SSD", + "next": "cpld" + }, + "ssd_model": { + "parent": "ssd", + "key": "Device Model", + "cmd": "smartctl -i /dev/sda |grep \"Device Model\"", + "pattern": r".*Device Model", + "separator": ":", + "arrt_index" : 1, + }, + "ssd_fw": { + "parent": "ssd", + "key": "Firmware Version", + "cmd": "smartctl -i /dev/sda |grep \"Firmware Version\"", + "pattern": r".*Firmware Version", + "separator": ":", + "arrt_index" : 2, + }, + "ssd_user_cap": { + "parent": "ssd", + "key": "User Capacity", + "cmd": "smartctl -i /dev/sda |grep \"User Capacity\"", + "pattern": r".*User Capacity", + "separator": ":", + "arrt_index" : 3, + }, + + "cpld": { + "key": "CPLD", + "next": "psu" + }, + + "cpld1": { + "key": "CPLD1", + "parent": "cpld", + "arrt_index" : 1, + }, + "cpld1_model": { + "key": "Device Model", + "parent": "cpld1", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld1_vender": { + "key": "Vendor", + "parent": "cpld1", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld1_desc": { + "key": "Description", + "parent": "cpld1", + "config" : "CPU_CPLD", + "arrt_index" : 3, + }, + "cpld1_version": { + "key": "Firmware Version", + "parent": "cpld1", + "reg": { + "loc": "/dev/port", + "offset": 0x700, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld2": { + "key": "CPLD2", + "parent": "cpld", + "arrt_index" : 2, + }, + "cpld2_model": { + "key": "Device Model", + "parent": "cpld2", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld2_vender": { + "key": "Vendor", + "parent": "cpld2", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld2_desc": { + "key": "Description", + "parent": "cpld2", + "config" : "BASE_CPLD", + "arrt_index" : 3, + }, + "cpld2_version": { + "key": "Firmware Version", + "parent": "cpld2", + "reg": { + "loc": "/dev/port", + "offset": 0x900, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld3": { + "key": "CPLD3", + "parent": "cpld", + "arrt_index" : 3, + }, + "cpld3_model": { + "key": "Device Model", + "parent": "cpld3", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld3_vender": { + "key": "Vendor", + "parent": "cpld3", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld3_desc": { + "key": "Description", + "parent": "cpld3", + "config" : "UPORT_CPLD", + "arrt_index" : 3, + }, + "cpld3_version": { + "key": "Firmware Version", + "parent": "cpld3", + "i2c": { + "bus": "60", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld4": { + "key": "CPLD4", + "parent": "cpld", + "arrt_index" : 4, + }, + "cpld4_model": { + "key": "Device Model", + "parent": "cpld4", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld4_vender": { + "key": "Vendor", + "parent": "cpld4", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld4_desc": { + "key": "Description", + "parent": "cpld4", + "config" : "UFCB_CPLD", + "arrt_index" : 3, + }, + "cpld4_version": { + "key": "Firmware Version", + "parent": "cpld4", + "i2c": { + "bus": "87", + "loc": "0x0d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld5": { + "key": "CPLD5", + "parent": "cpld", + "arrt_index" : 5, + }, + "cpld5_model": { + "key": "Device Model", + "parent": "cpld5", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld5_vender": { + "key": "Vendor", + "parent": "cpld5", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld5_desc": { + "key": "Description", + "parent": "cpld5", + "config" : "DFCB_CPLD", + "arrt_index" : 3, + }, + "cpld5_version": { + "key": "Firmware Version", + "parent": "cpld5", + "i2c": { + "bus": "95", + "loc": "0x0d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld6": { + "key": "CPLD6", + "parent": "cpld", + "arrt_index" : 6, + }, + "cpld6_model": { + "key": "Device Model", + "parent": "cpld6", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld6_vender": { + "key": "Vendor", + "parent": "cpld6", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld6_desc": { + "key": "Description", + "parent": "cpld6", + "config" : "MAC_CPLDA", + "arrt_index" : 3, + }, + "cpld6_version": { + "key": "Firmware Version", + "parent": "cpld6", + "i2c": { + "bus": "77", + "loc": "0x1d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld7": { + "key": "CPLD7", + "parent": "cpld", + "arrt_index" : 7, + }, + "cpld7_model": { + "key": "Device Model", + "parent": "cpld7", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld7_vender": { + "key": "Vendor", + "parent": "cpld7", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld7_desc": { + "key": "Description", + "parent": "cpld7", + "config" : "MAC_CPLDB", + "arrt_index" : 3, + }, + "cpld7_version": { + "key": "Firmware Version", + "parent": "cpld7", + "i2c": { + "bus": "77", + "loc": "0x2d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld8": { + "key": "CPLD8", + "parent": "cpld", + "arrt_index" : 8, + }, + "cpld8_model": { + "key": "Device Model", + "parent": "cpld8", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld8_vender": { + "key": "Vendor", + "parent": "cpld8", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld8_desc": { + "key": "Description", + "parent": "cpld8", + "config" : "DPORT_CPLD", + "arrt_index" : 3, + }, + "cpld8_version": { + "key": "Firmware Version", + "parent": "cpld8", + "i2c": { + "bus": "111", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "psu": { + "key": "PSU", + "next": "fan" + }, + + "psu1": { + "parent": "psu", + "key": "PSU1", + "arrt_index" : 1, + }, + "psu1_hw_version": { + "key": "Hardware Version", + "parent": "psu1", + "extra": { + "funcname": "getPsu", + "id": "psu1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu1_fw_version": { + "key": "Firmware Version", + "parent": "psu1", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu2": { + "parent": "psu", + "key": "PSU2", + "arrt_index" : 2, + }, + "psu2_hw_version": { + "key": "Hardware Version", + "parent": "psu2", + "extra": { + "funcname": "getPsu", + "id": "psu2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu2_fw_version": { + "key": "Firmware Version", + "parent": "psu2", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu3": { + "parent": "psu", + "key": "PSU3", + "arrt_index" : 3, + }, + "psu3_hw_version": { + "key": "Hardware Version", + "parent": "psu3", + "extra": { + "funcname": "getPsu", + "id": "psu3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu3_fw_version": { + "key": "Firmware Version", + "parent": "psu3", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu4": { + "parent": "psu", + "key": "PSU4", + "arrt_index" : 4, + }, + "psu4_hw_version": { + "key": "Hardware Version", + "parent": "psu4", + "extra": { + "funcname": "getPsu", + "id": "psu4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu4_fw_version": { + "key": "Firmware Version", + "parent": "psu4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan": { + "key": "FAN", + "next": "i210" + }, + + "fan1": { + "key": "FAN1", + "parent": "fan", + "arrt_index" : 1, + }, + "fan1_hw_version": { + "key": "Hardware Version", + "parent": "fan1", + "extra": { + "funcname": "checkFan", + "id": "fan1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan1_fw_version": { + "key": "Firmware Version", + "parent": "fan1", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan2": { + "key": "FAN2", + "parent": "fan", + "arrt_index" : 2, + }, + "fan2_hw_version": { + "key": "Hardware Version", + "parent": "fan2", + "extra": { + "funcname": "checkFan", + "id": "fan2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan2_fw_version": { + "key": "Firmware Version", + "parent": "fan2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan3": { + "key": "FAN3", + "parent": "fan", + "arrt_index" : 3, + }, + "fan3_hw_version": { + "key": "Hardware Version", + "parent": "fan3", + "extra": { + "funcname": "checkFan", + "id": "fan3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan3_fw_version": { + "key": "Firmware Version", + "parent": "fan3", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan4": { + "key": "FAN4", + "parent": "fan", + "arrt_index" : 4, + }, + "fan4_hw_version": { + "key": "Hardware Version", + "parent": "fan4", + "extra": { + "funcname": "checkFan", + "id": "fan4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan4_fw_version": { + "key": "Firmware Version", + "parent": "fan4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan5": { + "key": "FAN5", + "parent": "fan", + "arrt_index" : 5, + }, + "fan5_hw_version": { + "key": "Hardware Version", + "parent": "fan5", + "extra": { + "funcname": "checkFan", + "id": "fan5", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan5_fw_version": { + "key": "Firmware Version", + "parent": "fan5", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan6": { + "key": "FAN6", + "parent": "fan", + "arrt_index" : 6, + }, + "fan6_hw_version": { + "key": "Hardware Version", + "parent": "fan6", + "extra": { + "funcname": "checkFan", + "id": "fan6", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan6_fw_version": { + "key": "Firmware Version", + "parent": "fan6", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan7": { + "key": "FAN7", + "parent": "fan", + "arrt_index" : 7, + }, + "fan7_hw_version": { + "key": "Hardware Version", + "parent": "fan7", + "extra": { + "funcname": "checkFan", + "id": "fan7", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan7_fw_version": { + "key": "Firmware Version", + "parent": "fan7", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan8": { + "key": "FAN8", + "parent": "fan", + "arrt_index" : 8, + }, + "fan8_hw_version": { + "key": "Hardware Version", + "parent": "fan8", + "extra": { + "funcname": "checkFan", + "id": "fan8", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan8_fw_version": { + "key": "Firmware Version", + "parent": "fan8", + "config" : "NA", + "arrt_index" : 2, + }, + + "i210": { + "key": "NIC", + "next": "fpga" + }, + "i210_model": { + "parent": "i210", + "config": "NA", + "key": "Device Model", + "arrt_index" : 1, + }, + "i210_vendor": { + "parent": "i210", + "config": "INTEL", + "key": "Vendor", + "arrt_index" : 2, + }, + "i210_version": { + "parent": "i210", + "cmd": "ethtool -i eth0", + "pattern": r"firmware-version", + "separator": ":", + "key": "Firmware Version", + "arrt_index" : 3, + }, + + "fpga": { + "key": "FPGA", + "next": "others" + }, + + "fpga1": { + "key": "FPGA1", + "parent": "fpga", + "arrt_index" : 1, + }, + "fpga1_model": { + "parent": "fpga1", + "devfile": { + "loc": "/dev/fpga0", + "offset":0x98, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga1_vender": { + "parent": "fpga1", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga1_desc": { + "key": "Description", + "parent": "fpga1", + "config" : "UPORT_FPGA", + "arrt_index" : 3, + }, + "fpga1_hw_version": { + "parent": "fpga1", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga1_fw_version": { + "parent": "fpga1", + "pci": { + "bus" : 0x0a, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "fpga2": { + "key": "FPGA2", + "parent": "fpga", + "arrt_index" : 2, + }, + "fpga2_model": { + "parent": "fpga2", + "devfile": { + "loc": "/dev/fpga1", + "offset":0xb0, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga2_vender": { + "parent": "fpga2", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga2_desc": { + "key": "Description", + "parent": "fpga2", + "config" : "MAC_FPGA", + "arrt_index" : 3, + }, + "fpga2_hw_version": { + "parent": "fpga2", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga2_fw_version": { + "parent": "fpga2", + "pci": { + "bus" : 8, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "fpga3": { + "key": "FPGA3", + "parent": "fpga", + "arrt_index" : 3, + }, + "fpga3_model": { + "parent": "fpga3", + "devfile": { + "loc": "/dev/fpga2", + "offset":0x98, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga3_vender": { + "parent": "fpga3", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga3_desc": { + "key": "Description", + "parent": "fpga3", + "config" : "DPORT_FPGA", + "arrt_index" : 3, + }, + "fpga3_hw_version": { + "parent": "fpga3", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga3_fw_version": { + "parent": "fpga3", + "pci": { + "bus" : 0xb, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "others": { + "key": "OTHERS", + }, + "5387": { + "parent": "others", + "key": "CPU-BMC-SWITCH", + "arrt_index" : 1, + }, + "5387_model": { + "parent": "5387", + "config": "BCM53134O", + "key": "Device Model", + "arrt_index" : 1, + }, + "5387_vendor": { + "parent": "5387", + "config": "Broadcom", + "key": "Vendor", + "arrt_index" : 2, + }, + "5387_hw_version": { + "parent": "5387", + "key": "Hardware Version", + "func": { + "funcname": "get_bcm5387_version", + "params" : { + "before": [ + {"dealtype": "shell", "cmd": "echo 50 > /sys/class/gpio/export"}, + {"dealtype": "shell", "cmd": "echo high > /sys/class/gpio/gpio50/direction"}, + {"dealtype": "shell", "cmd": "echo 48 > /sys/class/gpio/export"}, + {"dealtype": "shell", "cmd": "echo high > /sys/class/gpio/gpio48/direction"}, + {"dealtype": "io_wr", "io_addr": 0x918, "value":0x06}, + {"dealtype": "io_wr", "io_addr": 0x943, "value":0x00}, + ], + "get_version" : "md5sum /sys/bus/spi/devices/spi0.0/eeprom | awk '{print $1}'", + "after": [ + {"dealtype": "shell", "cmd": "echo 0 > /sys/class/gpio/gpio48/value"}, + {"dealtype": "shell", "cmd": "echo 48 > /sys/class/gpio/unexport"}, + {"dealtype": "shell", "cmd": "echo 0 > /sys/class/gpio/gpio50/value"}, + {"dealtype": "shell", "cmd": "echo 50 > /sys/class/gpio/unexport"}, + ], + "finally": [ + {"dealtype": "io_wr", "io_addr": 0x943, "value":0x01}, + {"dealtype": "io_wr", "io_addr": 0x918, "value":0x00}, + ], + }, + }, + "arrt_index" : 3, + }, +} + +MAC_AVS_PARAM = { + 0x7e: 0.882564, + 0x82: 0.859436, + 0x86: 0.836776, + 0x8A: 0.813531, + 0x8E: 0.789233, +} + +AVS_VOUT_MODE_PARAM ={ + 0x18:256, # 2^8 + 0x17:512, # 2^9 + 0x16:1024, # 2^10 + 0x15:2048, # 2^11 + 0x14:4096, # 2^12 +} + +MAC_DEFAULT_PARAM = { + "type": 0, + "default":0x82, + "bus":75, + "devno":0x10, + "loopaddr":0xff, + "loop":0x06, + "vout_cmd_addr":0x42, + "vout_mode_addr":0x40, + "sdktype": 0, + "macregloc":24 , + "mask": 0xff, + "rov_source":0, + "cpld_avs":{"bus":77, "loc":0x1d, "offset":0x24, "gettype":"i2c"}, + "set_avs": {"loc": "/sys/bus/i2c/devices/75-0010/avs_vout", "gettype": "sysfs", "formula": "int((%f)*1000000)"}, +} + +## +DRIVERLISTS = [ + {"name": "rg_gpio_d1500", "delay": 0}, + {"name": "i2c_dev", "delay": 0}, + {"name": "i2c_gpio", "delay":0}, + {"name": "i2c_mux", "delay":0}, + {"name": "rg_fpga_pcie", "delay": 0}, + {"name": "rg_pcie_dev", "delay": 0}, + {"name": "rg_lpc_drv", "delay": 0}, + {"name": "rg_io_dev", "delay": 0}, + {"name": "rg_i2c_dev", "delay": 0}, + {"name": "rg_fpga_i2c_bus_drv", "delay": 0}, + {"name": "rg_fpga_pca954x_drv", "delay": 0}, + {"name": "rg_wdt", "delay": 0}, + {"name": "rg_gpio_device", "delay": 0}, + {"name": "rg_i2c_gpio_device", "delay":0}, + {"name": "rg_pcie_dev_device", "delay": 0}, + {"name": "rg_lpc_drv_device", "delay": 0}, + {"name": "rg_io_dev_device", "delay": 0}, + {"name": "rg_fpga_i2c_bus_device", "delay": 0}, + {"name": "rg_fpga_pca954x_device", "delay": 0}, + {"name": "rg_i2c_dev_device", "delay": 0}, + {"name": "rg_wdt_device", "delay": 0}, + {"name": "ruijie_common dfd_my_type_i2c_bus=1 dfd_my_type_i2c_addr=0x56", "delay": 1}, + {"name": "rg_spi_gpio_device", "delay": 0}, + {"name": "rg_eeprom_93xx46", "delay": 0}, + {"name": "lm75", "delay":0}, + {"name": "tmp401", "delay":0}, + {"name": "rg_optoe", "delay": 0}, + {"name": "at24", "delay": 0}, + {"name": "rg_mac_bsc", "delay": 0}, + {"name": "rg_pmbus_core", "delay":0}, + {"name": "rg_csu550", "delay": 0}, + {"name": "rg_ina3221", "delay": 0}, + {"name": "rg_tps53622", "delay": 0}, + {"name": "rg_ucd9000", "delay": 0}, + {"name": "rg_xdpe132g5c", "delay": 0}, + {"name": "s3ip_sysfs", "delay": 0}, + {"name": "rg_switch_driver", "delay": 0}, + {"name": "syseeprom_device_driver", "delay": 0}, + {"name": "fan_device_driver", "delay": 0}, + {"name": "cpld_device_driver", "delay": 0}, + {"name": "sysled_device_driver", "delay": 0}, + {"name": "psu_device_driver", "delay": 0}, + {"name": "transceiver_device_driver", "delay": 0}, + {"name": "temp_sensor_device_driver", "delay": 0}, + {"name": "vol_sensor_device_driver", "delay": 0}, + {"name": "curr_sensor_device_driver", "delay": 0}, + {"name": "fpga_device_driver", "delay": 0}, + {"name": "watchdog_device_driver", "delay": 0}, + {"name": "rg_plat_dfd", "delay":0}, + {"name": "rg_plat_switch", "delay":0}, + {"name": "rg_plat_fan", "delay":0}, + {"name": "rg_plat_psu", "delay":0}, + {"name": "rg_plat_sff", "delay":0}, + {"name": "rg_plat_sensor", "delay": 0}, +] + +DEVICE = [ + # GPIO-I2C + {"name": "24c02", "bus":1, "loc":0x56 }, + # UP port board + {"name": "rg_ucd90160", "bus": 62, "loc": 0x5b}, + {"name": "lm75", "bus": 63, "loc": 0x4b}, + {"name": "lm75", "bus": 64, "loc": 0x4f}, + # MAC board + # PSU + {"name": "24c02", "bus":79, "loc":0x50}, + {"name": "rg_fsp1200","bus":79, "loc":0x58 }, + {"name": "24c02", "bus":80, "loc": 0x50}, + {"name": "rg_fsp1200","bus":80, "loc":0x58 }, + {"name": "24c02", "bus":81, "loc":0x50}, + {"name": "rg_fsp1200","bus":81, "loc":0x58 }, + {"name": "24c02", "bus":82, "loc": 0x50}, + {"name": "rg_fsp1200","bus":82, "loc":0x58 }, + # FAN + {"name": "24c64","bus":90,"loc":0x50 }, + {"name": "24c64","bus":91,"loc":0x50 }, + {"name": "24c64","bus":92,"loc":0x50 }, + {"name": "24c64","bus":93,"loc":0x50 }, + {"name": "24c64","bus":98,"loc":0x50 }, + {"name": "24c64","bus":99,"loc":0x50 }, + {"name": "24c64","bus":100,"loc":0x50 }, + {"name": "24c64","bus":101,"loc":0x50 }, + # fan temp + {"name": "lm75", "bus": 88, "loc": 0x48}, + {"name": "lm75", "bus": 89, "loc": 0x49}, + {"name": "lm75", "bus": 96, "loc": 0x48}, + {"name": "lm75", "bus": 97, "loc": 0x49}, + # base temp + {"name": "lm75", "bus": 107, "loc": 0x4b}, + {"name": "lm75", "bus": 109, "loc": 0x4b}, + {"name": "lm75", "bus": 69, "loc": 0x4b}, + {"name": "lm75", "bus": 70, "loc": 0x4f}, + {"name": "tmp411", "bus": 71, "loc": 0x4c}, + {"name": "tmp411", "bus": 72, "loc": 0x4c}, + # base dcdc + {"name": "rg_ucd90160", "bus": 105, "loc": 0x5b}, + {"name": "rg_tps53622", "bus": 106, "loc": 0x60}, + {"name": "rg_tps53622", "bus": 106, "loc": 0x6c}, + {"name": "rg_ina3221", "bus": 106, "loc": 0x43}, + {"name": "rg_ucd90160", "bus": 73, "loc": 0x5b}, + # mac bsc + {"name": "rg_mac_bsc_th4", "bus":74, "loc":0x44 }, + # DOWN port board + {"name": "rg_ucd90160", "bus": 113, "loc": 0x5b}, + {"name": "lm75", "bus": 114, "loc": 0x4b}, + {"name": "lm75", "bus": 115, "loc": 0x4f}, + # xdpe avs + {"name": "rg_xdpe132g5c", "bus": 75, "loc": 0x10}, + {"name": "rg_xdpe132g5c", "bus": 76, "loc": 0x5a}, +] + +OPTOE = [ + {"name": "rg_optoe1", "startbus": 124, "endbus": 251}, +] + +PMON_SYSLOG_STATUS = { + "polling_time": 3, + "sffs": { + "present": {"path": ["/sys/s3ip/transceiver/*/present"], "ABSENT":0}, + "nochangedmsgflag": 0, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 1, + "alias": { + "eth1": "Eth200GE1", + "eth2": "Eth200GE2", + "eth3": "Eth200GE3", + "eth4": "Eth200GE4", + "eth5": "Eth200GE5", + "eth6": "Eth200GE6", + "eth7": "Eth200GE7", + "eth8": "Eth200GE8", + "eth9": "Eth200GE9", + "eth10": "Eth200GE10", + "eth11": "Eth200GE11", + "eth12": "Eth200GE12", + "eth13": "Eth200GE13", + "eth14": "Eth200GE14", + "eth15": "Eth200GE15", + "eth16": "Eth200GE16", + "eth17": "Eth200GE17", + "eth18": "Eth200GE18", + "eth19": "Eth200GE19", + "eth20": "Eth200GE20", + "eth21": "Eth200GE21", + "eth22": "Eth200GE22", + "eth23": "Eth200GE23", + "eth24": "Eth200GE24", + "eth25": "Eth200GE25", + "eth26": "Eth200GE26", + "eth27": "Eth200GE27", + "eth28": "Eth200GE28", + "eth29": "Eth200GE29", + "eth30": "Eth200GE30", + "eth31": "Eth200GE31", + "eth32": "Eth200GE32", + "eth33": "Eth200GE33", + "eth34": "Eth200GE34", + "eth35": "Eth200GE35", + "eth36": "Eth200GE36", + "eth37": "Eth200GE37", + "eth38": "Eth200GE38", + "eth39": "Eth200GE39", + "eth40": "Eth200GE40", + "eth41": "Eth200GE41", + "eth42": "Eth200GE42", + "eth43": "Eth200GE43", + "eth44": "Eth200GE44", + "eth45": "Eth200GE45", + "eth46": "Eth200GE46", + "eth47": "Eth200GE47", + "eth48": "Eth200GE48", + "eth49": "Eth200GE49", + "eth50": "Eth200GE50", + "eth51": "Eth200GE51", + "eth52": "Eth200GE52", + "eth53": "Eth200GE53", + "eth54": "Eth200GE54", + "eth55": "Eth200GE55", + "eth56": "Eth200GE56", + "eth57": "Eth200GE57", + "eth58": "Eth200GE58", + "eth59": "Eth200GE59", + "eth60": "Eth200GE60", + "eth61": "Eth200GE61", + "eth62": "Eth200GE62", + "eth63": "Eth200GE63", + "eth64": "Eth200GE64", + "eth65": "Eth200GE65", + "eth66": "Eth200GE66", + "eth67": "Eth200GE67", + "eth68": "Eth200GE68", + "eth69": "Eth200GE69", + "eth70": "Eth200GE70", + "eth71": "Eth200GE71", + "eth72": "Eth200GE72", + "eth73": "Eth200GE73", + "eth74": "Eth200GE74", + "eth75": "Eth200GE75", + "eth76": "Eth200GE76", + "eth77": "Eth200GE77", + "eth78": "Eth200GE78", + "eth79": "Eth200GE79", + "eth80": "Eth200GE80", + "eth81": "Eth200GE81", + "eth82": "Eth200GE82", + "eth83": "Eth200GE83", + "eth84": "Eth200GE84", + "eth85": "Eth200GE85", + "eth86": "Eth200GE86", + "eth87": "Eth200GE87", + "eth88": "Eth200GE88", + "eth89": "Eth200GE89", + "eth90": "Eth200GE90", + "eth91": "Eth200GE91", + "eth92": "Eth200GE92", + "eth93": "Eth200GE93", + "eth94": "Eth200GE94", + "eth95": "Eth200GE95", + "eth96": "Eth200GE96", + "eth97": "Eth200GE97", + "eth98": "Eth200GE98", + "eth99": "Eth200GE99", + "eth100": "Eth200GE100", + "eth101": "Eth200GE101", + "eth102": "Eth200GE102", + "eth103": "Eth200GE103", + "eth104": "Eth200GE104", + "eth105": "Eth200GE105", + "eth106": "Eth200GE106", + "eth107": "Eth200GE107", + "eth108": "Eth200GE108", + "eth109": "Eth200GE109", + "eth110": "Eth200GE110", + "eth111": "Eth200GE111", + "eth112": "Eth200GE112", + "eth113": "Eth200GE113", + "eth114": "Eth200GE114", + "eth115": "Eth200GE115", + "eth116": "Eth200GE116", + "eth117": "Eth200GE117", + "eth118": "Eth200GE118", + "eth119": "Eth200GE119", + "eth120": "Eth200GE120", + "eth121": "Eth200GE121", + "eth122": "Eth200GE122", + "eth123": "Eth200GE123", + "eth124": "Eth200GE124", + "eth125": "Eth200GE125", + "eth126": "Eth200GE126", + "eth127": "Eth200GE127", + "eth128": "Eth200GE128", + } + }, + "fans": { + "present": {"path": ["/sys/s3ip/fan/*/status"], "ABSENT":0}, + "status": [ + {"path": "/sys/s3ip/fan/%s/status", 'okval': 1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "psus": { + "present" : {"path": ["/sys/s3ip/psu/*/present"], "ABSENT":0}, + "status" : [ + {"path": "/sys/s3ip/psu/%s/out_status", "okval":1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "temps": { + "temps_list":[ + {"name":"air_inlet", "input_path":"/sys/bus/i2c/devices/107-004b/hwmon/*/temp1_input", "input_accuracy":1000, "warning":43, "critical":53}, + {"name":"MAC_air_outlet", "input_path":"/sys/bus/i2c/devices/70-004f/hwmon/*/temp1_input", "input_accuracy":1000, "warning":70, "critical":75}, + {"name":"CPU_TEMP", "input_path":"/sys/devices/platform/coretemp.0/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":102}, + {"name":"SWITCH_TEMP", "input_path":"/sys/bus/i2c/devices/74-0044/hwmon/*/temp99_input", "input_accuracy":1000, "warning":100, "critical":105}, + ], + "over_temps_polling_seconds": 60, + }, +} + +INIT_PARAM = [ ] +INIT_COMMAND = [ + "i2cset -f -y 60 0x3d 0x80 0xff", + "i2cset -f -y 77 0x1d 0x7c 0xff", + "i2cset -f -y 111 0x3d 0x80 0xff", + "i2cset -f -y 60 0x3d 0xd0 0xff", + "i2cset -f -y 77 0x1d 0xca 0xff", + "i2cset -f -y 77 0x2d 0xd6 0xff", + "i2cset -f -y 111 0x3d 0xd0 0xff", +] + +INIT_PARAM_PRE = [ + {"loc":"75-0010/avs_vout_max","value": "882564"}, + {"loc":"75-0010/avs_vout_min","value": "789233"}, +] +INIT_COMMAND_PRE = [ ] diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_config.py new file mode 100755 index 000000000000..cb1c18c03717 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_config.py @@ -0,0 +1,1422 @@ +#!/usr/bin/python3 +from ruijiecommon import * + + +STARTMODULE = { + "xdpe_avscontrol":1, + "dev_monitor": 1, + "hal_fanctrl":1, + "hal_ledctrl":1, + "sff_temp_polling":1, + "rg_pmon_syslog":1, +} + +DEV_MONITOR_PARAM = { + "polling_time" : 10, + "psus": [ + {"name": "psu1", + "present": {"gettype": "io", "io_addr": 0x964, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu1pmbus", "name": "rg_fsp1200", "bus": 79, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu1frue2", "name": "24c02", "bus": 79, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu2", + "present": {"gettype": "io", "io_addr": 0x964, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu2pmbus", "name": "rg_fsp1200", "bus": 80, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu2frue2", "name": "24c02", "bus": 80, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu3", + "present": {"gettype": "io", "io_addr": 0x965, "presentbit": 4, "okval": 0}, + "device": [ + {"id": "psu3pmbus", "name": "rg_fsp1200", "bus": 82, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu3frue2", "name": "24c02", "bus": 82, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "psu4", + "present": {"gettype": "io", "io_addr": 0x965, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "psu4pmbus", "name": "rg_fsp1200", "bus": 81, "loc": 0x58, "attr": "hwmon"}, + {"id": "psu4frue2", "name": "24c02", "bus": 81, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "fans": [ + {"name": "fan1", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan1frue2", "name": "24c64", "bus": 90, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan2", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 0, "okval": 0}, + "device": [ + {"id": "fan2frue2", "name": "24c64", "bus": 98, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan3", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan3frue2", "name": "24c64", "bus": 91, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan4", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 1, "okval": 0}, + "device": [ + {"id": "fan4frue2", "name": "24c64", "bus": 99, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan5", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan5frue2", "name": "24c64", "bus": 92, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan6", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 2, "okval": 0}, + "device": [ + {"id": "fan6frue2", "name": "24c64", "bus": 100, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan7", + "present": {"gettype": "i2c", "bus": 87, "loc": 0x0d, "offset": 0x30, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan7frue2", "name": "24c64", "bus": 93, "loc": 0x50, "attr": "eeprom"}, + ], + }, + {"name": "fan8", + "present": {"gettype": "i2c", "bus": 95, "loc": 0x0d, "offset": 0x30, "presentbit": 3, "okval": 0}, + "device": [ + {"id": "fan8frue2", "name": "24c64", "bus": 101, "loc": 0x50, "attr": "eeprom"}, + ], + }, + ], + "others": [ + {"name":"eeprom", + "device":[ + {"id":"eeprom_1", "name":"24c02","bus":1, "loc":0x56, "attr":"eeprom"}, + ], + }, + {"name":"lm75", + "device":[ + {"id":"lm75_1", "name":"lm75","bus":63, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_2", "name":"lm75","bus":64, "loc":0x4f, "attr":"hwmon"}, + {"id":"lm75_3", "name":"lm75","bus":88, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_4", "name":"lm75","bus":89, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_5", "name":"lm75","bus":96, "loc":0x48, "attr":"hwmon"}, + {"id":"lm75_6", "name":"lm75","bus":97, "loc":0x49, "attr":"hwmon"}, + {"id":"lm75_7", "name":"lm75","bus":107, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_8", "name":"lm75","bus":109, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_9", "name":"lm75","bus":69, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_10", "name":"lm75","bus":70, "loc":0x4f, "attr":"hwmon"}, + {"id":"lm75_11", "name":"lm75","bus":114, "loc":0x4b, "attr":"hwmon"}, + {"id":"lm75_12", "name":"lm75","bus":115, "loc":0x4f, "attr":"hwmon"}, + ], + }, + {"name":"mac_bsc", + "device":[ + {"id":"mac_bsc_1", "name":"rg_mac_bsc_th4","bus":74, "loc":0x44, "attr":"hwmon"}, + ], + }, + {"name":"ina3221", + "device":[ + {"id":"ina3221_1", "name":"rg_ina3221","bus":106, "loc":0x43, "attr":"hwmon"}, + ], + }, + {"name":"tps53622", + "device":[ + {"id":"tps53622_1", "name":"rg_tps53622","bus":106, "loc":0x60, "attr":"hwmon"}, + {"id":"tps53622_2", "name":"rg_tps53622","bus":106, "loc":0x6c, "attr":"hwmon"}, + ], + }, + {"name":"ucd90160", + "device":[ + {"id":"ucd90160_1", "name":"rg_ucd90160","bus":62, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_2", "name":"rg_ucd90160","bus":105, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_3", "name":"rg_ucd90160","bus":73, "loc":0x5b, "attr":"hwmon"}, + {"id":"ucd90160_4", "name":"rg_ucd90160","bus":113, "loc":0x5b, "attr":"hwmon"}, + ], + }, + {"name":"tmp411", + "device":[ + {"id":"tmp411_1", "name":"tmp411","bus":71, "loc":0x4c, "attr":"hwmon"}, + {"id":"tmp411_2", "name":"tmp411","bus":72, "loc":0x4c, "attr":"hwmon"}, + ], + }, + ], +} + +CPLDVERSIONS = [ ] +MANUINFO_CONF = { + "bios": { + "key": "BIOS", + "head": True, + "next": "bmc" + }, + "bios_vendor": { + "parent": "bios", + "key": "Vendor", + "cmd": "dmidecode -t 0 |grep Vendor", + "pattern": r".*Vendor", + "separator": ":", + "arrt_index" : 1, + }, + "bios_version": { + "parent": "bios", + "key": "Version", + "cmd": "dmidecode -t 0 |grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "bios_date": { + "parent": "bios", + "key": "Release Date", + "cmd": "dmidecode -t 0 |grep Release", + "pattern": r".*Release Date", + "separator": ":", + "arrt_index" : 3, + }, + + "bmc": { + "key": "BMC", + "next": "onie" + }, + "bmc_version": { + "parent": "bmc", + "key": "Version", + "cmd": "ipmitool mc info |grep \"Firmware Revision\"", + "pattern": r".*Firmware Revision", + "separator": ":", + "arrt_index" : 1, + }, + + "onie": { + "key": "ONIE", + "next": "cpu" + }, + "onie_date": { + "parent": "onie", + "key": "Build Date", + "file": "/host/machine.conf", + "pattern": r"^onie_build_date", + "separator": "=", + "arrt_index" : 1, + }, + "onie_version": { + "parent": "onie", + "key": "Version", + "file": "/host/machine.conf", + "pattern": r"^onie_version", + "separator": "=", + "arrt_index" : 2, + }, + "onie_sub_version": { + "parent": "onie", + "key": "Sub Version", + "file": "/host/machine.conf", + "pattern": r"^onie_sub_version", + "separator": "=", + "arrt_index" : 3, + }, + + "cpu": { + "key": "CPU", + "next": "ssd" + }, + "cpu_vendor": { + "parent": "cpu", + "key": "Vendor", + "cmd": "dmidecode --type processor |grep Manufacturer", + "pattern": r".*Manufacturer", + "separator": ":", + "arrt_index" : 1, + }, + "cpu_model": { + "parent": "cpu", + "key": "Device Model", + "cmd": "dmidecode --type processor | grep Version", + "pattern": r".*Version", + "separator": ":", + "arrt_index" : 2, + }, + "cpu_core": { + "parent": "cpu", + "key": "Core Count", + "cmd": "dmidecode --type processor | grep \"Core Count\"", + "pattern": r".*Core Count", + "separator": ":", + "arrt_index" : 3, + }, + "cpu_thread": { + "parent": "cpu", + "key": "Thread Count", + "cmd": "dmidecode --type processor | grep \"Thread Count\"", + "pattern": r".*Thread Count", + "separator": ":", + "arrt_index" : 4, + }, + + "ssd": { + "key": "SSD", + "next": "cpld" + }, + "ssd_model": { + "parent": "ssd", + "key": "Device Model", + "cmd": "smartctl -i /dev/sda |grep \"Device Model\"", + "pattern": r".*Device Model", + "separator": ":", + "arrt_index" : 1, + }, + "ssd_fw": { + "parent": "ssd", + "key": "Firmware Version", + "cmd": "smartctl -i /dev/sda |grep \"Firmware Version\"", + "pattern": r".*Firmware Version", + "separator": ":", + "arrt_index" : 2, + }, + "ssd_user_cap": { + "parent": "ssd", + "key": "User Capacity", + "cmd": "smartctl -i /dev/sda |grep \"User Capacity\"", + "pattern": r".*User Capacity", + "separator": ":", + "arrt_index" : 3, + }, + + "cpld": { + "key": "CPLD", + "next": "psu" + }, + + "cpld1": { + "key": "CPLD1", + "parent": "cpld", + "arrt_index" : 1, + }, + "cpld1_model": { + "key": "Device Model", + "parent": "cpld1", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld1_vender": { + "key": "Vendor", + "parent": "cpld1", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld1_desc": { + "key": "Description", + "parent": "cpld1", + "config" : "CPU_CPLD", + "arrt_index" : 3, + }, + "cpld1_version": { + "key": "Firmware Version", + "parent": "cpld1", + "reg": { + "loc": "/dev/port", + "offset": 0x700, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld2": { + "key": "CPLD2", + "parent": "cpld", + "arrt_index" : 2, + }, + "cpld2_model": { + "key": "Device Model", + "parent": "cpld2", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld2_vender": { + "key": "Vendor", + "parent": "cpld2", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld2_desc": { + "key": "Description", + "parent": "cpld2", + "config" : "BASE_CPLD", + "arrt_index" : 3, + }, + "cpld2_version": { + "key": "Firmware Version", + "parent": "cpld2", + "reg": { + "loc": "/dev/port", + "offset": 0x900, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld3": { + "key": "CPLD3", + "parent": "cpld", + "arrt_index" : 3, + }, + "cpld3_model": { + "key": "Device Model", + "parent": "cpld3", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld3_vender": { + "key": "Vendor", + "parent": "cpld3", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld3_desc": { + "key": "Description", + "parent": "cpld3", + "config" : "UPORT_CPLD", + "arrt_index" : 3, + }, + "cpld3_version": { + "key": "Firmware Version", + "parent": "cpld3", + "i2c": { + "bus": "60", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld4": { + "key": "CPLD4", + "parent": "cpld", + "arrt_index" : 4, + }, + "cpld4_model": { + "key": "Device Model", + "parent": "cpld4", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld4_vender": { + "key": "Vendor", + "parent": "cpld4", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld4_desc": { + "key": "Description", + "parent": "cpld4", + "config" : "UFCB_CPLD", + "arrt_index" : 3, + }, + "cpld4_version": { + "key": "Firmware Version", + "parent": "cpld4", + "i2c": { + "bus": "87", + "loc": "0x0d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld5": { + "key": "CPLD5", + "parent": "cpld", + "arrt_index" : 5, + }, + "cpld5_model": { + "key": "Device Model", + "parent": "cpld5", + "config" : "LCMXO3LF-2100C-5BG256C", + "arrt_index" : 1, + }, + "cpld5_vender": { + "key": "Vendor", + "parent": "cpld5", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld5_desc": { + "key": "Description", + "parent": "cpld5", + "config" : "DFCB_CPLD", + "arrt_index" : 3, + }, + "cpld5_version": { + "key": "Firmware Version", + "parent": "cpld5", + "i2c": { + "bus": "95", + "loc": "0x0d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld6": { + "key": "CPLD6", + "parent": "cpld", + "arrt_index" : 6, + }, + "cpld6_model": { + "key": "Device Model", + "parent": "cpld6", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld6_vender": { + "key": "Vendor", + "parent": "cpld6", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld6_desc": { + "key": "Description", + "parent": "cpld6", + "config" : "MAC_CPLDA", + "arrt_index" : 3, + }, + "cpld6_version": { + "key": "Firmware Version", + "parent": "cpld6", + "i2c": { + "bus": "77", + "loc": "0x1d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld7": { + "key": "CPLD7", + "parent": "cpld", + "arrt_index" : 7, + }, + "cpld7_model": { + "key": "Device Model", + "parent": "cpld7", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld7_vender": { + "key": "Vendor", + "parent": "cpld7", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld7_desc": { + "key": "Description", + "parent": "cpld7", + "config" : "MAC_CPLDB", + "arrt_index" : 3, + }, + "cpld7_version": { + "key": "Firmware Version", + "parent": "cpld7", + "i2c": { + "bus": "77", + "loc": "0x2d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "cpld8": { + "key": "CPLD8", + "parent": "cpld", + "arrt_index" : 8, + }, + "cpld8_model": { + "key": "Device Model", + "parent": "cpld8", + "config" : "LCMXO3LF-4300C-6BG324I", + "arrt_index" : 1, + }, + "cpld8_vender": { + "key": "Vendor", + "parent": "cpld8", + "config" : "LATTICE", + "arrt_index" : 2, + }, + "cpld8_desc": { + "key": "Description", + "parent": "cpld8", + "config" : "DPORT_CPLD", + "arrt_index" : 3, + }, + "cpld8_version": { + "key": "Firmware Version", + "parent": "cpld8", + "i2c": { + "bus": "111", + "loc": "0x3d", + "offset": 0, + "size": 4 + }, + "callback": "cpld_format", + "arrt_index" : 4, + }, + + "psu": { + "key": "PSU", + "next": "fan" + }, + + "psu1": { + "parent": "psu", + "key": "PSU1", + "arrt_index" : 1, + }, + "psu1_hw_version": { + "key": "Hardware Version", + "parent": "psu1", + "extra": { + "funcname": "getPsu", + "id": "psu1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu1_fw_version": { + "key": "Firmware Version", + "parent": "psu1", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu2": { + "parent": "psu", + "key": "PSU2", + "arrt_index" : 2, + }, + "psu2_hw_version": { + "key": "Hardware Version", + "parent": "psu2", + "extra": { + "funcname": "getPsu", + "id": "psu2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu2_fw_version": { + "key": "Firmware Version", + "parent": "psu2", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu3": { + "parent": "psu", + "key": "PSU3", + "arrt_index" : 3, + }, + "psu3_hw_version": { + "key": "Hardware Version", + "parent": "psu3", + "extra": { + "funcname": "getPsu", + "id": "psu3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu3_fw_version": { + "key": "Firmware Version", + "parent": "psu3", + "config" : "NA", + "arrt_index" : 2, + }, + + "psu4": { + "parent": "psu", + "key": "PSU4", + "arrt_index" : 4, + }, + "psu4_hw_version": { + "key": "Hardware Version", + "parent": "psu4", + "extra": { + "funcname": "getPsu", + "id": "psu4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "psu4_fw_version": { + "key": "Firmware Version", + "parent": "psu4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan": { + "key": "FAN", + "next": "i210" + }, + + "fan1": { + "key": "FAN1", + "parent": "fan", + "arrt_index" : 1, + }, + "fan1_hw_version": { + "key": "Hardware Version", + "parent": "fan1", + "extra": { + "funcname": "checkFan", + "id": "fan1", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan1_fw_version": { + "key": "Firmware Version", + "parent": "fan1", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan2": { + "key": "FAN2", + "parent": "fan", + "arrt_index" : 2, + }, + "fan2_hw_version": { + "key": "Hardware Version", + "parent": "fan2", + "extra": { + "funcname": "checkFan", + "id": "fan2", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan2_fw_version": { + "key": "Firmware Version", + "parent": "fan2", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan3": { + "key": "FAN3", + "parent": "fan", + "arrt_index" : 3, + }, + "fan3_hw_version": { + "key": "Hardware Version", + "parent": "fan3", + "extra": { + "funcname": "checkFan", + "id": "fan3", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan3_fw_version": { + "key": "Firmware Version", + "parent": "fan3", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan4": { + "key": "FAN4", + "parent": "fan", + "arrt_index" : 4, + }, + "fan4_hw_version": { + "key": "Hardware Version", + "parent": "fan4", + "extra": { + "funcname": "checkFan", + "id": "fan4", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan4_fw_version": { + "key": "Firmware Version", + "parent": "fan4", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan5": { + "key": "FAN5", + "parent": "fan", + "arrt_index" : 5, + }, + "fan5_hw_version": { + "key": "Hardware Version", + "parent": "fan5", + "extra": { + "funcname": "checkFan", + "id": "fan5", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan5_fw_version": { + "key": "Firmware Version", + "parent": "fan5", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan6": { + "key": "FAN6", + "parent": "fan", + "arrt_index" : 6, + }, + "fan6_hw_version": { + "key": "Hardware Version", + "parent": "fan6", + "extra": { + "funcname": "checkFan", + "id": "fan6", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan6_fw_version": { + "key": "Firmware Version", + "parent": "fan6", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan7": { + "key": "FAN7", + "parent": "fan", + "arrt_index" : 7, + }, + "fan7_hw_version": { + "key": "Hardware Version", + "parent": "fan7", + "extra": { + "funcname": "checkFan", + "id": "fan7", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan7_fw_version": { + "key": "Firmware Version", + "parent": "fan7", + "config" : "NA", + "arrt_index" : 2, + }, + + "fan8": { + "key": "FAN8", + "parent": "fan", + "arrt_index" : 8, + }, + "fan8_hw_version": { + "key": "Hardware Version", + "parent": "fan8", + "extra": { + "funcname": "checkFan", + "id": "fan8", + "key": "hw_version" + }, + "arrt_index" : 1, + }, + "fan8_fw_version": { + "key": "Firmware Version", + "parent": "fan8", + "config" : "NA", + "arrt_index" : 2, + }, + + "i210": { + "key": "NIC", + "next": "fpga" + }, + "i210_model": { + "parent": "i210", + "config": "NA", + "key": "Device Model", + "arrt_index" : 1, + }, + "i210_vendor": { + "parent": "i210", + "config": "INTEL", + "key": "Vendor", + "arrt_index" : 2, + }, + "i210_version": { + "parent": "i210", + "cmd": "ethtool -i eth0", + "pattern": r"firmware-version", + "separator": ":", + "key": "Firmware Version", + "arrt_index" : 3, + }, + + "fpga": { + "key": "FPGA", + "next": "others" + }, + + "fpga1": { + "key": "FPGA1", + "parent": "fpga", + "arrt_index" : 1, + }, + "fpga1_model": { + "parent": "fpga1", + "devfile": { + "loc": "/dev/fpga0", + "offset":0x98, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga1_vender": { + "parent": "fpga1", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga1_desc": { + "key": "Description", + "parent": "fpga1", + "config" : "UPORT_FPGA", + "arrt_index" : 3, + }, + "fpga1_hw_version": { + "parent": "fpga1", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga1_fw_version": { + "parent": "fpga1", + "pci": { + "bus" : 0x0a, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "fpga2": { + "key": "FPGA2", + "parent": "fpga", + "arrt_index" : 2, + }, + "fpga2_model": { + "parent": "fpga2", + "devfile": { + "loc": "/dev/fpga1", + "offset":0xb0, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga2_vender": { + "parent": "fpga2", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga2_desc": { + "key": "Description", + "parent": "fpga2", + "config" : "MAC_FPGA", + "arrt_index" : 3, + }, + "fpga2_hw_version": { + "parent": "fpga2", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga2_fw_version": { + "parent": "fpga2", + "pci": { + "bus" : 8, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "fpga3": { + "key": "FPGA3", + "parent": "fpga", + "arrt_index" : 3, + }, + "fpga3_model": { + "parent": "fpga3", + "devfile": { + "loc": "/dev/fpga2", + "offset":0x98, + "len":4, + "bit_width":4 + }, + "decode": { + "0x00000000": "XC7A100T-2FGG484C", + "0x00000200": "XC7A200T-2FBG484I" + }, + "key": "Device Model", + "arrt_index" : 1, + }, + "fpga3_vender": { + "parent": "fpga3", + "config" : "XILINX", + "key": "Vendor", + "arrt_index" : 2, + }, + "fpga3_desc": { + "key": "Description", + "parent": "fpga3", + "config" : "DPORT_FPGA", + "arrt_index" : 3, + }, + "fpga3_hw_version": { + "parent": "fpga3", + "config" : "NA", + "key": "Hardware Version", + "arrt_index" : 4, + }, + "fpga3_fw_version": { + "parent": "fpga3", + "pci": { + "bus" : 0xb, + "slot" : 0, + "fn" : 0, + "bar" : 0, + "offset" : 0 + }, + "key": "Firmware Version", + "arrt_index" : 5, + }, + + "others": { + "key": "OTHERS", + }, + "5387": { + "parent": "others", + "key": "CPU-BMC-SWITCH", + "arrt_index" : 1, + }, + "5387_model": { + "parent": "5387", + "config": "BCM5387", + "key": "Device Model", + "arrt_index" : 1, + }, + "5387_vendor": { + "parent": "5387", + "config": "Broadcom", + "key": "Vendor", + "arrt_index" : 2, + }, + "5387_hw_version": { + "parent": "5387", + "key": "Hardware Version", + "func": { + "funcname": "get_bcm5387_version", + "params" : { + "before": [ + {"dealtype": "shell", "cmd": "echo 50 > /sys/class/gpio/export"}, + {"dealtype": "shell", "cmd": "echo high > /sys/class/gpio/gpio50/direction"}, + {"dealtype": "shell", "cmd": "echo 48 > /sys/class/gpio/export"}, + {"dealtype": "shell", "cmd": "echo high > /sys/class/gpio/gpio48/direction"}, + {"dealtype": "io_wr", "io_addr": 0x918, "value":0x06}, + {"dealtype": "io_wr", "io_addr": 0x943, "value":0x00}, + ], + "get_version" : "md5sum /sys/bus/spi/devices/spi0.0/eeprom | awk '{print $1}'", + "after": [ + {"dealtype": "shell", "cmd": "echo 0 > /sys/class/gpio/gpio48/value"}, + {"dealtype": "shell", "cmd": "echo 48 > /sys/class/gpio/unexport"}, + {"dealtype": "shell", "cmd": "echo 0 > /sys/class/gpio/gpio50/value"}, + {"dealtype": "shell", "cmd": "echo 50 > /sys/class/gpio/unexport"}, + ], + "finally": [ + {"dealtype": "io_wr", "io_addr": 0x943, "value":0x01}, + {"dealtype": "io_wr", "io_addr": 0x918, "value":0x00}, + ], + }, + }, + "arrt_index" : 3, + }, +} + +MAC_AVS_PARAM = { + 0x7e: 0.882564, + 0x82: 0.859436, + 0x86: 0.836776, + 0x8A: 0.813531, + 0x8E: 0.789233, +} + +AVS_VOUT_MODE_PARAM ={ + 0x18:256, # 2^8 + 0x17:512, # 2^9 + 0x16:1024, # 2^10 + 0x15:2048, # 2^11 + 0x14:4096, # 2^12 +} + +MAC_DEFAULT_PARAM = { + "type": 0, + "default":0x82, + "bus":75, + "devno":0x10, + "loopaddr":0xff, + "loop":0x06, + "vout_cmd_addr":0x42, + "vout_mode_addr":0x40, + "sdktype": 0, + "macregloc":24 , + "mask": 0xff, + "rov_source":0, + "cpld_avs":{"bus":77, "loc":0x1d, "offset":0x24, "gettype":"i2c"}, + "set_avs": {"loc": "/sys/bus/i2c/devices/75-0010/avs_vout", "gettype": "sysfs", "formula": "int((%f)*1000000)"}, +} + +## +DRIVERLISTS = [ + {"name": "rg_gpio_d1500", "delay": 0}, + {"name": "i2c_dev", "delay": 0}, + {"name": "i2c_gpio", "delay":0}, + {"name": "i2c_mux", "delay":0}, + {"name": "rg_fpga_pcie", "delay": 0}, + {"name": "rg_pcie_dev", "delay": 0}, + {"name": "rg_lpc_drv", "delay": 0}, + {"name": "rg_io_dev", "delay": 0}, + {"name": "rg_i2c_dev", "delay": 0}, + {"name": "rg_fpga_i2c_bus_drv", "delay": 0}, + {"name": "rg_fpga_pca954x_drv", "delay": 0}, + {"name": "rg_wdt", "delay": 0}, + {"name": "rg_gpio_device", "delay": 0}, + {"name": "rg_i2c_gpio_device", "delay":0}, + {"name": "rg_pcie_dev_device", "delay": 0}, + {"name": "rg_lpc_drv_device", "delay": 0}, + {"name": "rg_io_dev_device", "delay": 0}, + {"name": "rg_fpga_i2c_bus_device", "delay": 0}, + {"name": "rg_fpga_pca954x_device", "delay": 0}, + {"name": "rg_i2c_dev_device", "delay": 0}, + {"name": "rg_wdt_device", "delay": 0}, + {"name": "ruijie_common dfd_my_type_i2c_bus=1 dfd_my_type_i2c_addr=0x56", "delay": 1}, + {"name": "rg_spi_gpio_device", "delay": 0}, + {"name": "rg_eeprom_93xx46", "delay": 0}, + {"name": "lm75", "delay":0}, + {"name": "tmp401", "delay":0}, + {"name": "rg_optoe", "delay": 0}, + {"name": "at24", "delay": 0}, + {"name": "rg_mac_bsc", "delay": 0}, + {"name": "rg_pmbus_core", "delay":0}, + {"name": "rg_csu550", "delay": 0}, + {"name": "rg_ina3221", "delay": 0}, + {"name": "rg_tps53622", "delay": 0}, + {"name": "rg_ucd9000", "delay": 0}, + {"name": "rg_xdpe132g5c", "delay": 0}, + {"name": "s3ip_sysfs", "delay": 0}, + {"name": "rg_switch_driver", "delay": 0}, + {"name": "syseeprom_device_driver", "delay": 0}, + {"name": "fan_device_driver", "delay": 0}, + {"name": "cpld_device_driver", "delay": 0}, + {"name": "sysled_device_driver", "delay": 0}, + {"name": "psu_device_driver", "delay": 0}, + {"name": "transceiver_device_driver", "delay": 0}, + {"name": "temp_sensor_device_driver", "delay": 0}, + {"name": "vol_sensor_device_driver", "delay": 0}, + {"name": "curr_sensor_device_driver", "delay": 0}, + {"name": "fpga_device_driver", "delay": 0}, + {"name": "watchdog_device_driver", "delay": 0}, + {"name": "rg_plat_dfd", "delay":0}, + {"name": "rg_plat_switch", "delay":0}, + {"name": "rg_plat_fan", "delay":0}, + {"name": "rg_plat_psu", "delay":0}, + {"name": "rg_plat_sff", "delay":0}, + {"name": "rg_plat_sensor", "delay": 0}, +] + +DEVICE = [ + # GPIO-I2C + {"name": "24c02", "bus":1, "loc":0x56 }, + # UP port board + {"name": "rg_ucd90160", "bus": 62, "loc": 0x5b}, + {"name": "lm75", "bus": 63, "loc": 0x4b}, + {"name": "lm75", "bus": 64, "loc": 0x4f}, + # MAC board + # PSU + {"name": "24c02", "bus":79, "loc":0x50}, + {"name": "rg_fsp1200","bus":79, "loc":0x58 }, + {"name": "24c02", "bus":80, "loc": 0x50}, + {"name": "rg_fsp1200","bus":80, "loc":0x58 }, + {"name": "24c02", "bus":81, "loc":0x50}, + {"name": "rg_fsp1200","bus":81, "loc":0x58 }, + {"name": "24c02", "bus":82, "loc": 0x50}, + {"name": "rg_fsp1200","bus":82, "loc":0x58 }, + # FAN + {"name": "24c64","bus":90,"loc":0x50 }, + {"name": "24c64","bus":91,"loc":0x50 }, + {"name": "24c64","bus":92,"loc":0x50 }, + {"name": "24c64","bus":93,"loc":0x50 }, + {"name": "24c64","bus":98,"loc":0x50 }, + {"name": "24c64","bus":99,"loc":0x50 }, + {"name": "24c64","bus":100,"loc":0x50 }, + {"name": "24c64","bus":101,"loc":0x50 }, + # fan temp + {"name": "lm75", "bus": 88, "loc": 0x48}, + {"name": "lm75", "bus": 89, "loc": 0x49}, + {"name": "lm75", "bus": 96, "loc": 0x48}, + {"name": "lm75", "bus": 97, "loc": 0x49}, + # base temp + {"name": "lm75", "bus": 107, "loc": 0x4b}, + {"name": "lm75", "bus": 109, "loc": 0x4b}, + {"name": "lm75", "bus": 69, "loc": 0x4b}, + {"name": "lm75", "bus": 70, "loc": 0x4f}, + {"name": "tmp411", "bus": 71, "loc": 0x4c}, + {"name": "tmp411", "bus": 72, "loc": 0x4c}, + # base dcdc + {"name": "rg_ucd90160", "bus": 105, "loc": 0x5b}, + {"name": "rg_tps53622", "bus": 106, "loc": 0x60}, + {"name": "rg_tps53622", "bus": 106, "loc": 0x6c}, + {"name": "rg_ina3221", "bus": 106, "loc": 0x43}, + {"name": "rg_ucd90160", "bus": 73, "loc": 0x5b}, + # mac bsc + {"name": "rg_mac_bsc_th4", "bus":74, "loc":0x44 }, + # DOWN port board + {"name": "rg_ucd90160", "bus": 113, "loc": 0x5b}, + {"name": "lm75", "bus": 114, "loc": 0x4b}, + {"name": "lm75", "bus": 115, "loc": 0x4f}, + # xdpe avs + {"name": "rg_xdpe132g5c", "bus": 75, "loc": 0x10}, + {"name": "rg_xdpe132g5c", "bus": 76, "loc": 0x5a}, +] + +OPTOE = [ + {"name": "rg_optoe1", "startbus": 124, "endbus": 251}, +] + +PMON_SYSLOG_STATUS = { + "polling_time": 3, + "sffs": { + "present": {"path": ["/sys/s3ip/transceiver/*/present"], "ABSENT":0}, + "nochangedmsgflag": 0, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 1, + "alias": { + "eth1": "Eth200GE1", + "eth2": "Eth200GE2", + "eth3": "Eth200GE3", + "eth4": "Eth200GE4", + "eth5": "Eth200GE5", + "eth6": "Eth200GE6", + "eth7": "Eth200GE7", + "eth8": "Eth200GE8", + "eth9": "Eth200GE9", + "eth10": "Eth200GE10", + "eth11": "Eth200GE11", + "eth12": "Eth200GE12", + "eth13": "Eth200GE13", + "eth14": "Eth200GE14", + "eth15": "Eth200GE15", + "eth16": "Eth200GE16", + "eth17": "Eth200GE17", + "eth18": "Eth200GE18", + "eth19": "Eth200GE19", + "eth20": "Eth200GE20", + "eth21": "Eth200GE21", + "eth22": "Eth200GE22", + "eth23": "Eth200GE23", + "eth24": "Eth200GE24", + "eth25": "Eth200GE25", + "eth26": "Eth200GE26", + "eth27": "Eth200GE27", + "eth28": "Eth200GE28", + "eth29": "Eth200GE29", + "eth30": "Eth200GE30", + "eth31": "Eth200GE31", + "eth32": "Eth200GE32", + "eth33": "Eth200GE33", + "eth34": "Eth200GE34", + "eth35": "Eth200GE35", + "eth36": "Eth200GE36", + "eth37": "Eth200GE37", + "eth38": "Eth200GE38", + "eth39": "Eth200GE39", + "eth40": "Eth200GE40", + "eth41": "Eth200GE41", + "eth42": "Eth200GE42", + "eth43": "Eth200GE43", + "eth44": "Eth200GE44", + "eth45": "Eth200GE45", + "eth46": "Eth200GE46", + "eth47": "Eth200GE47", + "eth48": "Eth200GE48", + "eth49": "Eth200GE49", + "eth50": "Eth200GE50", + "eth51": "Eth200GE51", + "eth52": "Eth200GE52", + "eth53": "Eth200GE53", + "eth54": "Eth200GE54", + "eth55": "Eth200GE55", + "eth56": "Eth200GE56", + "eth57": "Eth200GE57", + "eth58": "Eth200GE58", + "eth59": "Eth200GE59", + "eth60": "Eth200GE60", + "eth61": "Eth200GE61", + "eth62": "Eth200GE62", + "eth63": "Eth200GE63", + "eth64": "Eth200GE64", + "eth65": "Eth200GE65", + "eth66": "Eth200GE66", + "eth67": "Eth200GE67", + "eth68": "Eth200GE68", + "eth69": "Eth200GE69", + "eth70": "Eth200GE70", + "eth71": "Eth200GE71", + "eth72": "Eth200GE72", + "eth73": "Eth200GE73", + "eth74": "Eth200GE74", + "eth75": "Eth200GE75", + "eth76": "Eth200GE76", + "eth77": "Eth200GE77", + "eth78": "Eth200GE78", + "eth79": "Eth200GE79", + "eth80": "Eth200GE80", + "eth81": "Eth200GE81", + "eth82": "Eth200GE82", + "eth83": "Eth200GE83", + "eth84": "Eth200GE84", + "eth85": "Eth200GE85", + "eth86": "Eth200GE86", + "eth87": "Eth200GE87", + "eth88": "Eth200GE88", + "eth89": "Eth200GE89", + "eth90": "Eth200GE90", + "eth91": "Eth200GE91", + "eth92": "Eth200GE92", + "eth93": "Eth200GE93", + "eth94": "Eth200GE94", + "eth95": "Eth200GE95", + "eth96": "Eth200GE96", + "eth97": "Eth200GE97", + "eth98": "Eth200GE98", + "eth99": "Eth200GE99", + "eth100": "Eth200GE100", + "eth101": "Eth200GE101", + "eth102": "Eth200GE102", + "eth103": "Eth200GE103", + "eth104": "Eth200GE104", + "eth105": "Eth200GE105", + "eth106": "Eth200GE106", + "eth107": "Eth200GE107", + "eth108": "Eth200GE108", + "eth109": "Eth200GE109", + "eth110": "Eth200GE110", + "eth111": "Eth200GE111", + "eth112": "Eth200GE112", + "eth113": "Eth200GE113", + "eth114": "Eth200GE114", + "eth115": "Eth200GE115", + "eth116": "Eth200GE116", + "eth117": "Eth200GE117", + "eth118": "Eth200GE118", + "eth119": "Eth200GE119", + "eth120": "Eth200GE120", + "eth121": "Eth200GE121", + "eth122": "Eth200GE122", + "eth123": "Eth200GE123", + "eth124": "Eth200GE124", + "eth125": "Eth200GE125", + "eth126": "Eth200GE126", + "eth127": "Eth200GE127", + "eth128": "Eth200GE128", + } + }, + "fans": { + "present": {"path": ["/sys/s3ip/fan/*/status"], "ABSENT":0}, + "status": [ + {"path": "/sys/s3ip/fan/%s/status", 'okval': 1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "psus": { + "present" : {"path": ["/sys/s3ip/psu/*/present"], "ABSENT":0}, + "status" : [ + {"path": "/sys/s3ip/psu/%s/out_status", "okval":1}, + ], + "nochangedmsgflag": 1, + "nochangedmsgtime": 60, + "noprintfirsttimeflag": 0 + }, + "temps": { + "temps_list":[ + {"name":"air_inlet", "input_path":"/sys/bus/i2c/devices/107-004b/hwmon/*/temp1_input", "input_accuracy":1000, "warning":43, "critical":53}, + {"name":"MAC_air_outlet", "input_path":"/sys/bus/i2c/devices/70-004f/hwmon/*/temp1_input", "input_accuracy":1000, "warning":70, "critical":75}, + {"name":"CPU_TEMP", "input_path":"/sys/devices/platform/coretemp.0/hwmon/*/temp1_input", "input_accuracy":1000, "warning":100, "critical":102}, + {"name":"SWITCH_TEMP", "input_path":"/sys/bus/i2c/devices/74-0044/hwmon/*/temp99_input", "input_accuracy":1000, "warning":100, "critical":105}, + ], + "over_temps_polling_seconds": 60, + }, +} + +INIT_PARAM = [ ] +INIT_COMMAND = [ + "i2cset -f -y 60 0x3d 0x80 0xff", + "i2cset -f -y 77 0x1d 0x7c 0xff", + "i2cset -f -y 111 0x3d 0x80 0xff", + "i2cset -f -y 60 0x3d 0xd0 0xff", + "i2cset -f -y 77 0x1d 0xca 0xff", + "i2cset -f -y 77 0x2d 0xd6 0xff", + "i2cset -f -y 111 0x3d 0xd0 0xff", +] + +INIT_PARAM_PRE = [ + {"loc":"75-0010/avs_vout_max","value": "882564"}, + {"loc":"75-0010/avs_vout_min","value": "789233"}, +] +INIT_COMMAND_PRE = [ ] diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_port_config.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_port_config.py new file mode 100755 index 000000000000..e5a878918a42 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/config/x86_64_tencent_tcs9400_r0_port_config.py @@ -0,0 +1,6 @@ +#!/usr/bin/python3 + +PLATFORM_INTF_OPTOE = { + "port_num": 128, + "optoe_start_bus": 124, +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_0x407c_device.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_0x407c_device.py new file mode 100755 index 000000000000..d5467528e437 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_0x407c_device.py @@ -0,0 +1,1739 @@ +#!/usr/bin/python3 + +psu_fan_airflow = { + "F2B": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "B2F": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +psu_display_name = { + "PSA1300CRPS-F": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "PSA1300CRPS-R": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +fanairflow = { + "F2B": ["FAN12K8080-F"], +} + +fan_display_name = { + "FAN12K8080-F": ["FAN12K8080-F"], +} + +psutypedecode = { + 0x00: 'N/A', + 0x01: 'AC', + 0x02: 'DC', +} + + +class Unit: + Temperature = "C" + Voltage = "V" + Current = "A" + Power = "W" + Speed = "RPM" + + +PSU_NOT_PRESENT_PWM = 100 + + +class threshold: + PSU_TEMP_MIN = -10 * 1000 + PSU_TEMP_MAX = 60 * 1000 + + PSU_FAN_SPEED_MIN = 2000 + PSU_FAN_SPEED_MAX = 28000 + + PSU_OUTPUT_VOLTAGE_MIN = 11 * 1000 + PSU_OUTPUT_VOLTAGE_MAX = 14 * 1000 + + PSU_AC_INPUT_VOLTAGE_MIN = 200 * 1000 + PSU_AC_INPUT_VOLTAGE_MAX = 240 * 1000 + + PSU_DC_INPUT_VOLTAGE_MIN = 190 * 1000 + PSU_DC_INPUT_VOLTAGE_MAX = 290 * 1000 + + ERR_VALUE = -9999999 + + PSU_OUTPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_OUTPUT_POWER_MAX = 1300 * 1000 * 1000 + + PSU_INPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_INPUT_POWER_MAX = 1444 * 1000 * 1000 + + PSU_OUTPUT_CURRENT_MIN = 2 * 1000 + PSU_OUTPUT_CURRENT_MAX = 107 * 1000 + + PSU_INPUT_CURRENT_MIN = 0.2 * 1000 + PSU_INPUT_CURRENT_MAX = 7 * 1000 + + FRONT_FAN_SPEED_MAX = 13530 + REAR_FAN_SPEED_MAX = 11770 + FAN_SPEED_MIN = 1650 + + +class Description: + CPLD = "Used for managing IO modules, SFP+ modules and system LEDs" + BIOS = "Performs initialization of hardware components during booting" + FPGA = "Platform management controller for on-board temperature monitoring, in-chassis power" + + +devices = { + "onie_e2": [ + { + "name": "ONIE_E2", + "e2loc": {"loc": "/sys/bus/i2c/devices/1-0056/eeprom", "way": "sysfs"}, + }, + ], + "psus": [ + { + "e2loc": {"loc": "/sys/bus/i2c/devices/79-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 79, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu1/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU1", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 79, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/80-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 80, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu2/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU2", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 80, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/82-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 82, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu3/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU3", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 82, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/81-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 81, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu4/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU4", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 81, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + ], + "temps":[ + { + "name": "CPU_TEMP", + "temp_id": "TEMP1", + "api_name": "CPU", + "Temperature": { + "value": {"loc": "/sys/bus/platform/devices/coretemp.0/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 102000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "INLET_TEMP", + "temp_id": "TEMP2", + "api_name": "Inlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/107-004b/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 40000, + "Max": 50000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "OUTLET_TEMP", + "temp_id": "TEMP3", + "api_name": "Outlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/70-004f/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 75000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SWITCH_TEMP", + "temp_id": "TEMP4", + "api_name": "Switch ASIC", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/74-0044/hwmon/hwmon*/temp99_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 105000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SFF_TEMP", + "Temperature": { + "value": {"loc": "/tmp/highest_sff_temp", "way": "sysfs", "flock_path": "/tmp/highest_sff_temp"}, + "Min": -15000, + "Low": 0, + "High": 80000, + "Max": 100000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + ], + "leds": [ + { + "name": "FRONT_SYS_LED", + "led_type": "SYS_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x08, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_PSU_LED", + "led_type": "PSU_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x09, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_FAN_LED", + "led_type": "FAN_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x0a, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + ], + "fans": [ + { + "name": "FAN1", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-90/90-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan1/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3b, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan1/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan1/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan1/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan1/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN2", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-98/98-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan2/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3b, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan2/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan2/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan2/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan2/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN3", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-91/91-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan3/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan3/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan3/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan3/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan3/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN4", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-99/99-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan4/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan4/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan4/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan4/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan4/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN5", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-92/92-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan5/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan5/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan5/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan5/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan5/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN6", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-100/100-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan6/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan6/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan6/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan6/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan6/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN7", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-93/93-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan7/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan7/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan7/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan7/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan7/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan7/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan7/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN8", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-101/101-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan8/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan8/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan8/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan8/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan8/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan8/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan8/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + ], + "cplds": [ + { + "name": "CPU_CPLD", + "cpld_id": "CPLD1", + "VersionFile": {"loc": "/dev/cpld0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for system power", + "slot": 0, + }, + { + "name": "BASE_CPLD", + "cpld_id": "CPLD2", + "VersionFile": {"loc": "/dev/cpld1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + }, + { + "name": "UPORT_CPLD", + "cpld_id": "CPLD3", + "VersionFile": {"loc": "/dev/cpld2", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "UFCB_CPLD", + "cpld_id": "CPLD4", + "VersionFile": {"loc": "/dev/cpld3", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "DFCB_CPLD", + "cpld_id": "CPLD5", + "VersionFile": {"loc": "/dev/cpld4", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "MAC_CPLDA", + "cpld_id": "CPLD6", + "VersionFile": {"loc": "/dev/cpld5", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "MAC_CPLDB", + "cpld_id": "CPLD7", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "DPORT_CPLD", + "cpld_id": "CPLD8", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "UPORT_FPGA", + "cpld_id": "CPLD9", + "VersionFile": {"loc": "/dev/fpga0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + { + "name": "MAC_FPGA", + "cpld_id": "CPLD10", + "VersionFile": {"loc": "/dev/fpga1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + { + "name": "DPORT_FPGA", + "cpld_id": "CPLD11", + "VersionFile": {"loc": "/dev/fpga2", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + ], + "dcdc": [ + { + "name": "MAC_VDD_ANALOG1", + "dcdc_id": "DCDC1", + "Min": 731, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 809, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD12V", + "dcdc_id": "DCDC2", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.0V_FPGA", + "dcdc_id": "DCDC3", + "Min": 969, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1071, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.8V_FPGA", + "dcdc_id": "DCDC4", + "Min": 1710, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1890, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V_FPGA", + "dcdc_id": "DCDC5", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD3.3V", + "dcdc_id": "DCDC6", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_SW_VDD1.2V", + "dcdc_id": "DCDC7", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD5V_CLK_MCU", + "dcdc_id": "DCDC8", + "Min": 4826, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5334, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD5V_VR", + "dcdc_id": "DCDC9", + "Min": 4826, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5334, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD3.3_CLK", + "dcdc_id": "DCDC10", + "Min": 3154, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3486, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDDO1.8V", + "dcdc_id": "DCDC11", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDDO1.2V", + "dcdc_id": "DCDC12", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in12_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD_CORE", + "dcdc_id": "DCDC13", + "Min": 700, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in13_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 950, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD_ANALOG", + "dcdc_id": "DCDC14", + "Min": 731, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in14_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 809, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V_MAC", + "dcdc_id": "DCDC15", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in15_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_AVDD1.8V", + "dcdc_id": "DCDC16", + "Min": 1710, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in16_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1890, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD12V", + "dcdc_id": "DCDC17", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SW_VDD1.0V", + "dcdc_id": "DCDC18", + "Min": 950, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1050, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD3.3V", + "dcdc_id": "DCDC19", + "Min": 3116, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3444, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SW_OVDD", + "dcdc_id": "DCDC20", + "Min": 3116, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3444, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SSD_VDD3.3V", + "dcdc_id": "DCDC21", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_VCCIN", + "dcdc_id": "DCDC22", + "Min": 1600, + "value": { + "loc": "/sys/bus/i2c/devices/106-0060/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1950, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V05", + "dcdc_id": "DCDC23", + "Min": 1000, + "value": { + "loc": "/sys/bus/i2c/devices/106-0060/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1100, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V2_VDDQ", + "dcdc_id": "DCDC24", + "Min": 1160, + "value": { + "loc": "/sys/bus/i2c/devices/106-006c/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P2V5_VPP", + "dcdc_id": "DCDC25", + "Min": 2113, + "value": { + "loc": "/sys/bus/i2c/devices/106-006c/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2447, + "format": "float(float(%s)/1000) * 1.124", + }, + { + "name": "CPU_P3V3_STBY", + "dcdc_id": "DCDC26", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P5V_AUX_IN", + "dcdc_id": "DCDC27", + "Min": 4250, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5500, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V7_VCCSCFUSESUS_IN", + "dcdc_id": "DCDC28", + "Min": 1615, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1785, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.0V_FPGA", + "dcdc_id": "DCDC29", + "Min": 959, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1061, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.8V_FPGA", + "dcdc_id": "DCDC30", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.2V_FPGA", + "dcdc_id": "DCDC31", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD3.3V", + "dcdc_id": "DCDC32", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC33", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC34", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_C", + "dcdc_id": "DCDC35", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_D", + "dcdc_id": "DCDC36", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD3.3_MON", + "dcdc_id": "DCDC37", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD12V", + "dcdc_id": "DCDC38", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.0V_FPGA", + "dcdc_id": "DCDC39", + "Min": 959, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1061, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.8V_FPGA", + "dcdc_id": "DCDC40", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.2V_FPGA", + "dcdc_id": "DCDC41", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD3.3V", + "dcdc_id": "DCDC42", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC43", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC44", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_C", + "dcdc_id": "DCDC45", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_D", + "dcdc_id": "DCDC46", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD3.3_MON", + "dcdc_id": "DCDC47", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD12V", + "dcdc_id": "DCDC48", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_A", + "dcdc_id": "DCDC49", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in0/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_B", + "dcdc_id": "DCDC50", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in1/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_C", + "dcdc_id": "DCDC51", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in2/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_D", + "dcdc_id": "DCDC52", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in3/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_E", + "dcdc_id": "DCDC53", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in4/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_F", + "dcdc_id": "DCDC54", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in5/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_G", + "dcdc_id": "DCDC55", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in6/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_H", + "dcdc_id": "DCDC56", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in7/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + ], + "cpu": [ + { + "name": "cpu", + "CpuResetCntReg": {"loc": "/dev/cpld1", "offset": 0x10, "len": 1, "way": "devfile_ascii"}, + } + ], + "sfps": { + "port_start": 1, + "port_end": 127, + } +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_device.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_device.py new file mode 100755 index 000000000000..182d7e3ddef8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_device.py @@ -0,0 +1,1739 @@ +#!/usr/bin/python3 + +psu_fan_airflow = { + "F2B": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "B2F": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +psu_display_name = { + "PSA1300CRPS-F": ["DPS-1300AB-6 F", "GW-CRPS1300D"], + "PSA1300CRPS-R": ["DPS-1300AB-11 C", "CRPS1300D3R"] +} + +fanairflow = { + "F2B": ["FAN12K8080-F"], +} + +fan_display_name = { + "FAN12K8080-F": ["FAN12K8080-F"], +} + +psutypedecode = { + 0x00: 'N/A', + 0x01: 'AC', + 0x02: 'DC', +} + + +class Unit: + Temperature = "C" + Voltage = "V" + Current = "A" + Power = "W" + Speed = "RPM" + + +PSU_NOT_PRESENT_PWM = 100 + + +class threshold: + PSU_TEMP_MIN = -10 * 1000 + PSU_TEMP_MAX = 60 * 1000 + + PSU_FAN_SPEED_MIN = 2000 + PSU_FAN_SPEED_MAX = 28000 + + PSU_OUTPUT_VOLTAGE_MIN = 11 * 1000 + PSU_OUTPUT_VOLTAGE_MAX = 14 * 1000 + + PSU_AC_INPUT_VOLTAGE_MIN = 200 * 1000 + PSU_AC_INPUT_VOLTAGE_MAX = 240 * 1000 + + PSU_DC_INPUT_VOLTAGE_MIN = 190 * 1000 + PSU_DC_INPUT_VOLTAGE_MAX = 290 * 1000 + + ERR_VALUE = -9999999 + + PSU_OUTPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_OUTPUT_POWER_MAX = 1300 * 1000 * 1000 + + PSU_INPUT_POWER_MIN = 10 * 1000 * 1000 + PSU_INPUT_POWER_MAX = 1444 * 1000 * 1000 + + PSU_OUTPUT_CURRENT_MIN = 2 * 1000 + PSU_OUTPUT_CURRENT_MAX = 107 * 1000 + + PSU_INPUT_CURRENT_MIN = 0.2 * 1000 + PSU_INPUT_CURRENT_MAX = 7 * 1000 + + FRONT_FAN_SPEED_MAX = 13530 + REAR_FAN_SPEED_MAX = 11770 + FAN_SPEED_MIN = 1650 + + +class Description: + CPLD = "Used for managing IO modules, SFP+ modules and system LEDs" + BIOS = "Performs initialization of hardware components during booting" + FPGA = "Platform management controller for on-board temperature monitoring, in-chassis power" + + +devices = { + "onie_e2": [ + { + "name": "ONIE_E2", + "e2loc": {"loc": "/sys/bus/i2c/devices/1-0056/eeprom", "way": "sysfs"}, + }, + ], + "psus": [ + { + "e2loc": {"loc": "/sys/bus/i2c/devices/79-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 79, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu1/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU1", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 79, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 79, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-79/79-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/80-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 80, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu2/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU2", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 80, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 80, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-80/80-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/82-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 82, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu3/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU3", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 82, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 82, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-82/82-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + { + "e2loc": {"loc": "/sys/bus/i2c/devices/81-0050/eeprom", "way": "sysfs"}, + "pmbusloc": {"bus": 81, "addr": 0x58, "way": "i2c"}, + "present": {"loc": "/sys/rg_plat/psu/psu4/present", "way": "sysfs", "mask": 0x01, "okval": 1}, + "name": "PSU4", + "psu_display_name": psu_display_name, + "airflow": psu_fan_airflow, + "psu_not_present_pwm": PSU_NOT_PRESENT_PWM, + "TempStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0004}, + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": threshold.PSU_TEMP_MIN, + "Max": threshold.PSU_TEMP_MAX, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + }, + "FanStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x0400}, + "FanSpeed": { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/fan1_input", "way": "sysfs"}, + "Min": threshold.PSU_FAN_SPEED_MIN, + "Max": threshold.PSU_FAN_SPEED_MAX, + "Unit": Unit.Speed + }, + "InputsStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x2000}, + "InputsType": {"bus": 81, "addr": 0x58, "offset": 0x80, "way": "i2c", 'psutypedecode': psutypedecode}, + "InputsVoltage": { + 'AC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_AC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_AC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + + }, + 'DC': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.PSU_DC_INPUT_VOLTAGE_MIN, + "Max": threshold.PSU_DC_INPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + 'other': { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in1_input", "way": "sysfs"}, + "Min": threshold.ERR_VALUE, + "Max": threshold.ERR_VALUE, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + } + }, + "InputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/curr1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_CURRENT_MIN, + "Max": threshold.PSU_INPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "InputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/power1_input", "way": "sysfs"}, + "Min": threshold.PSU_INPUT_POWER_MIN, + "Max": threshold.PSU_INPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + "OutputsStatus": {"bus": 81, "addr": 0x58, "offset": 0x79, "way": "i2cword", "mask": 0x8800}, + "OutputsVoltage": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/in2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_VOLTAGE_MIN, + "Max": threshold.PSU_OUTPUT_VOLTAGE_MAX, + "Unit": Unit.Voltage, + "format": "float(float(%s)/1000)" + }, + "OutputsCurrent": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/curr2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_CURRENT_MIN, + "Max": threshold.PSU_OUTPUT_CURRENT_MAX, + "Unit": Unit.Current, + "format": "float(float(%s)/1000)" + }, + "OutputsPower": + { + "value": {"loc": "/sys/bus/i2c/devices/i2c-81/81-0058/hwmon/hwmon*/power2_input", "way": "sysfs"}, + "Min": threshold.PSU_OUTPUT_POWER_MIN, + "Max": threshold.PSU_OUTPUT_POWER_MAX, + "Unit": Unit.Power, + "format": "float(float(%s)/1000000)" + }, + }, + ], + "temps":[ + { + "name": "CPU_TEMP", + "temp_id": "TEMP1", + "api_name": "CPU", + "Temperature": { + "value": {"loc": "/sys/bus/platform/devices/coretemp.0/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 102000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "INLET_TEMP", + "temp_id": "TEMP2", + "api_name": "Inlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/107-004b/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 40000, + "Max": 50000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "OUTLET_TEMP", + "temp_id": "TEMP3", + "api_name": "Outlet", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/70-004f/hwmon/hwmon*/temp1_input", "way": "sysfs"}, + "Min": -10000, + "Low": 0, + "High": 70000, + "Max": 75000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SWITCH_TEMP", + "temp_id": "TEMP4", + "api_name": "Switch ASIC", + "Temperature": { + "value": {"loc": "/sys/bus/i2c/devices/74-0044/hwmon/hwmon*/temp99_input", "way": "sysfs"}, + "Min": 2000, + "Low": 10000, + "High": 100000, + "Max": 105000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + { + "name": "SFF_TEMP", + "Temperature": { + "value": {"loc": "/tmp/highest_sff_temp", "way": "sysfs", "flock_path": "/tmp/highest_sff_temp"}, + "Min": -15000, + "Low": 0, + "High": 80000, + "Max": 100000, + "Unit": Unit.Temperature, + "format": "float(float(%s)/1000)" + } + }, + ], + "leds": [ + { + "name": "FRONT_SYS_LED", + "led_type": "SYS_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x08, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_PSU_LED", + "led_type": "PSU_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x09, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + { + "name": "FRONT_FAN_LED", + "led_type": "FAN_LED", + "led": {"bus": 77, "addr": 0x1d, "offset": 0x0a, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + }, + ], + "fans": [ + { + "name": "FAN1", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-90/90-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan1/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3b, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan1/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan1/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan1/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan1/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan1/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN2", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-98/98-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan2/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3b, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan2/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan2/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x14, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan2/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan2/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan2/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN3", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-91/91-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan3/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan3/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan3/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan3/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan3/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan3/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN4", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-99/99-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan4/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3c, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan4/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan4/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x15, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan4/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan4/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan4/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN5", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-92/92-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan5/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan5/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan5/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan5/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan5/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan5/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN6", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-100/100-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan6/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3d, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan6/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan6/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x16, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan6/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan6/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan6/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN7", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-93/93-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan7/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 87, "addr": 0x0d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan7/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan7/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan7/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 87, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan7/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan7/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan7/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + { + "name": "FAN8", + "airflow": fanairflow, + "fan_display_name": fan_display_name, + "e2loc": {'loc': '/sys/bus/i2c/devices/i2c-101/101-0050/eeprom', 'offset': 0, 'len': 256, 'way': 'devfile'}, + "present": {"loc":"/sys/rg_plat/fan/fan8/present","way":"sysfs", "mask": 0x01, "okval": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "led": {"bus": 95, "addr": 0x0d, "offset": 0x3e, "way": "i2c"}, + "led_attrs": { + "off":0x00, "red_flash":0x01, "red":0x02, + "green_flash":0x03, "green":0x04, "yellow_flash":0x05, + "yellow":0x06, "mask": 0x07 + }, + "Rotor": { + "Rotor1_config": { + "name": "Rotor1", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan8/motor0/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan8/motor0/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.FRONT_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan8/motor0/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.FRONT_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + "Rotor2_config": { + "name": "Rotor2", + "Set_speed": {"bus": 95, "addr": 0x0d, "offset": 0x17, "way": "i2c"}, + "Running": {"loc":"/sys/rg_plat/fan/fan8/motor1/status","way":"sysfs", "mask": 0x01, "is_runing": 1}, + "HwAlarm": {"loc":"/sys/rg_plat/fan/fan8/motor1/status","way":"sysfs", "mask": 0x01, "no_alarm": 1}, + "SpeedMin": threshold.FAN_SPEED_MIN, + "SpeedMax": threshold.REAR_FAN_SPEED_MAX, + "Speed": { + "value": {"loc": "/sys/rg_plat/fan/fan8/motor1/speed", "way": "sysfs"}, + "Min": threshold.FAN_SPEED_MIN, + "Max": threshold.REAR_FAN_SPEED_MAX, + "Unit": Unit.Speed, + }, + }, + }, + }, + ], + "cplds": [ + { + "name": "CPU_CPLD", + "cpld_id": "CPLD1", + "VersionFile": {"loc": "/dev/cpld0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for system power", + "slot": 0, + }, + { + "name": "BASE_CPLD", + "cpld_id": "CPLD2", + "VersionFile": {"loc": "/dev/cpld1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + }, + { + "name": "UPORT_CPLD", + "cpld_id": "CPLD3", + "VersionFile": {"loc": "/dev/cpld2", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "UFCB_CPLD", + "cpld_id": "CPLD4", + "VersionFile": {"loc": "/dev/cpld3", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "DFCB_CPLD", + "cpld_id": "CPLD5", + "VersionFile": {"loc": "/dev/cpld4", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for fan modules", + "slot": 0, + }, + { + "name": "MAC_CPLDA", + "cpld_id": "CPLD6", + "VersionFile": {"loc": "/dev/cpld5", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "MAC_CPLDB", + "cpld_id": "CPLD7", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "DPORT_CPLD", + "cpld_id": "CPLD8", + "VersionFile": {"loc": "/dev/cpld6", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for sff modules", + "slot": 0, + }, + { + "name": "UPORT_FPGA", + "cpld_id": "CPLD9", + "VersionFile": {"loc": "/dev/fpga0", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + { + "name": "MAC_FPGA", + "cpld_id": "CPLD10", + "VersionFile": {"loc": "/dev/fpga1", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + { + "name": "DPORT_FPGA", + "cpld_id": "CPLD11", + "VersionFile": {"loc": "/dev/fpga2", "offset": 0, "len": 4, "way": "devfile_ascii"}, + "desc": "Used for base functions", + "slot": 0, + "format": "little_endian", + }, + ], + "dcdc": [ + { + "name": "MAC_VDD_ANALOG1", + "dcdc_id": "DCDC1", + "Min": 731, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 809, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD12V", + "dcdc_id": "DCDC2", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.0V_FPGA", + "dcdc_id": "DCDC3", + "Min": 969, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1071, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.8V_FPGA", + "dcdc_id": "DCDC4", + "Min": 1710, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1890, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V_FPGA", + "dcdc_id": "DCDC5", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD3.3V", + "dcdc_id": "DCDC6", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_SW_VDD1.2V", + "dcdc_id": "DCDC7", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD5V_CLK_MCU", + "dcdc_id": "DCDC8", + "Min": 4826, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5334, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD5V_VR", + "dcdc_id": "DCDC9", + "Min": 4826, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5334, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD3.3_CLK", + "dcdc_id": "DCDC10", + "Min": 3154, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3486, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDDO1.8V", + "dcdc_id": "DCDC11", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in11_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDDO1.2V", + "dcdc_id": "DCDC12", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in12_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD_CORE", + "dcdc_id": "DCDC13", + "Min": 700, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in13_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 950, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD_ANALOG", + "dcdc_id": "DCDC14", + "Min": 731, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in14_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 809, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_VDD1.2V_MAC", + "dcdc_id": "DCDC15", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in15_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_AVDD1.8V", + "dcdc_id": "DCDC16", + "Min": 1710, + "value": { + "loc": "/sys/bus/i2c/devices/73-005b/hwmon/hwmon*/in16_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1890, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD12V", + "dcdc_id": "DCDC17", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SW_VDD1.2V", + "dcdc_id": "DCDC18", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD2.5V", + "dcdc_id": "DCDC19", + "Min": 2365, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2615, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_VDD3.3V", + "dcdc_id": "DCDC20", + "Min": 3116, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3444, + "format": "float(float(%s)/1000)", + }, + { + "name": "BASE_SSD_VDD3.3V", + "dcdc_id": "DCDC21", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/105-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_VCCIN", + "dcdc_id": "DCDC22", + "Min": 1600, + "value": { + "loc": "/sys/bus/i2c/devices/106-0060/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1950, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V05", + "dcdc_id": "DCDC23", + "Min": 1000, + "value": { + "loc": "/sys/bus/i2c/devices/106-0060/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1100, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V2_VDDQ", + "dcdc_id": "DCDC24", + "Min": 1160, + "value": { + "loc": "/sys/bus/i2c/devices/106-006c/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P2V5_VPP", + "dcdc_id": "DCDC25", + "Min": 2113, + "value": { + "loc": "/sys/bus/i2c/devices/106-006c/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 2447, + "format": "float(float(%s)/1000) * 1.124", + }, + { + "name": "CPU_P3V3_STBY", + "dcdc_id": "DCDC26", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P5V_AUX_IN", + "dcdc_id": "DCDC27", + "Min": 4250, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 5500, + "format": "float(float(%s)/1000)", + }, + { + "name": "CPU_P1V7_VCCSCFUSESUS_IN", + "dcdc_id": "DCDC28", + "Min": 1615, + "value": { + "loc": "/sys/bus/i2c/devices/106-0043/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1785, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.0V_FPGA", + "dcdc_id": "DCDC29", + "Min": 959, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1061, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.8V_FPGA", + "dcdc_id": "DCDC30", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD1.2V_FPGA", + "dcdc_id": "DCDC31", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD3.3V", + "dcdc_id": "DCDC32", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC33", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC34", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_C", + "dcdc_id": "DCDC35", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_QSFP56_VDD3.3V_D", + "dcdc_id": "DCDC36", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD3.3_MON", + "dcdc_id": "DCDC37", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "UPORT_VDD12V", + "dcdc_id": "DCDC38", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/62-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.0V_FPGA", + "dcdc_id": "DCDC39", + "Min": 959, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in1_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1061, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.8V_FPGA", + "dcdc_id": "DCDC40", + "Min": 1719, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in2_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1901, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD1.2V_FPGA", + "dcdc_id": "DCDC41", + "Min": 1140, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in3_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 1260, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD3.3V", + "dcdc_id": "DCDC42", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in4_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_A", + "dcdc_id": "DCDC43", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in5_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_B", + "dcdc_id": "DCDC44", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in6_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_C", + "dcdc_id": "DCDC45", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in7_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_QSFP56_VDD3.3V_D", + "dcdc_id": "DCDC46", + "Min": 3200, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in8_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3600, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD3.3_MON", + "dcdc_id": "DCDC47", + "Min": 3135, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in9_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3465, + "format": "float(float(%s)/1000)", + }, + { + "name": "DPORT_VDD12V", + "dcdc_id": "DCDC48", + "Min": 11400, + "value": { + "loc": "/sys/bus/i2c/devices/113-005b/hwmon/hwmon*/in10_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 12600, + "format": "float(float(%s)/1000)", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_A", + "dcdc_id": "DCDC49", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in0/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_B", + "dcdc_id": "DCDC50", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in1/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_C", + "dcdc_id": "DCDC51", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in2/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_D", + "dcdc_id": "DCDC52", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in3/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_E", + "dcdc_id": "DCDC53", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in4/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_F", + "dcdc_id": "DCDC54", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in5/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_G", + "dcdc_id": "DCDC55", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in6/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + { + "name": "MAC_QSFPDD_VDD3.3V_H", + "dcdc_id": "DCDC56", + "Min": 3.200, + "value": { + "loc": "/sys/rg_plat/sensor/in7/in_input", + "way": "sysfs", + }, + "read_times": 11, + "Unit": "V", + "Max": 3.600, + "format": "%s", + }, + ], + "cpu": [ + { + "name": "cpu", + "CpuResetCntReg": {"loc": "/dev/cpld1", "offset": 0x10, "len": 1, "way": "devfile_ascii"}, + } + ], + "sfps": { + "port_start": 1, + "port_end": 127, + } +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_monitor.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_monitor.py new file mode 100755 index 000000000000..bc13f5e26f38 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/hal-config/x86_64_tencent_tcs9400_r0_monitor.py @@ -0,0 +1,154 @@ +#!/usr/bin/python3 + +monitor = { + "openloop": { + "linear": { + "name": "linear", + "flag": 0, + "pwm_min": 0x80, + "pwm_max": 0xff, + "K": 11, + "tin_min": 38, + }, + "curve": { + "name": "curve", + "flag": 1, + "pwm_min": 0x5a, + "pwm_max": 0xff, + "a": 0.086, + "b": 0.318, + "c": 28, + "tin_min": 25, + }, + }, + + "pid": { + "CPU_TEMP": { + "name": "CPU_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x5a, + "pwm_max": 0xff, + "Kp": 1.5, + "Ki": 1, + "Kd": 0.3, + "target": 80, + "value": [None, None, None], + }, + "SWITCH_TEMP": { + "name": "SWITCH_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x5a, + "pwm_max": 0xff, + "Kp": 1.5, + "Ki": 1, + "Kd": 0.3, + "target": 90, + "value": [None, None, None], + }, + "OUTLET_TEMP": { + "name": "OUTLET_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x5a, + "pwm_max": 0xff, + "Kp": 2, + "Ki": 0.4, + "Kd": 0.3, + "target": 65, + "value": [None, None, None], + }, + "SFF_TEMP": { + "name": "SFF_TEMP", + "flag": 1, + "type": "duty", + "pwm_min": 0x5a, + "pwm_max": 0xff, + "Kp": 0.1, + "Ki": 0.4, + "Kd": 0, + "target": 60, + "value": [None, None, None], + }, + }, + + "temps_threshold": { + "SWITCH_TEMP": {"name": "SWITCH_TEMP", "warning": 100, "critical": 105, "invalid": -100000, "error": -99999}, + "INLET_TEMP": {"name": "INLET_TEMP", "warning": 40, "critical": 50, "fix": -3}, + "OUTLET_TEMP": {"name": "OUTLET_TEMP", "warning": 70, "critical": 75}, + "CPU_TEMP": {"name": "CPU_TEMP", "warning": 100, "critical": 102}, + "SFF_TEMP": {"name": "SFF_TEMP", "warning": 999, "critical": 1000, "ignore_threshold": 1, "invalid": -10000, "error": -9999}, + }, + + "fancontrol_para": { + "interval": 5, + "fan_air_flow_monitor": 1, + "max_pwm": 0xff, + "min_pwm": 0x5a, + "abnormal_pwm": 0xff, + "warning_pwm": 0xff, + "temp_invalid_pid_pwm": 0x5a, + "temp_error_pid_pwm": 0x5a, + "temp_fail_num": 3, + "check_temp_fail" : [ + {"temp_name" : "INLET_TEMP"}, + {"temp_name" : "SWITCH_TEMP"}, + {"temp_name" : "CPU_TEMP"}, + ], + "temp_warning_num": 3, # temp over warning 3 times continuously + "temp_critical_num": 3, # temp over critical 3 times continuously + "temp_warning_countdown": 60, # 5 min warning speed after not warning + "temp_critical_countdown": 60, # 5 min full speed after not critical + "rotor_error_count": 6, # fan rotor error 6 times continuously + "inlet_mac_diff": 999, + "check_crit_reboot_flag": 1, + "check_crit_reboot_num": 3, + "check_crit_sleep_time": 20, + "psu_absent_fullspeed_num": 0xFF, + "fan_absent_fullspeed_num": 1, + "rotor_error_fullspeed_num": 1, + }, + + "ledcontrol_para": { + "interval": 5, + "checkpsu": 1, + "checkfan": 1, + "psu_yellow_num": 1, + "fan_yellow_num": 1, + "board_sys_led" : [ + {"led_name" : "FRONT_SYS_LED"}, + ], + "board_psu_led" : [ + {"led_name" : "FRONT_PSU_LED"}, + ], + "board_fan_led" : [ + {"led_name" : "FRONT_FAN_LED"}, + ], + "psu_air_flow_monitor": 1, + "fan_air_flow_monitor": 1, + }, + + "intelligent_monitor_para": { + "interval": 60, + }, + + "dcdc_monitor_whitelist": { #not monitor when checkbit equal okval + "UPORT_QSFP56_VDD3.3V_A": {"gettype": "i2c", "bus": 60, "addr": 0x3d, "offset": 0x80, "checkbit": 0, "okval": 0}, + "UPORT_QSFP56_VDD3.3V_B": {"gettype": "i2c", "bus": 60, "addr": 0x3d, "offset": 0x80, "checkbit": 1, "okval": 0}, + "UPORT_QSFP56_VDD3.3V_C": {"gettype": "i2c", "bus": 60, "addr": 0x3d, "offset": 0x80, "checkbit": 2, "okval": 0}, + "UPORT_QSFP56_VDD3.3V_D": {"gettype": "i2c", "bus": 60, "addr": 0x3d, "offset": 0x80, "checkbit": 3, "okval": 0}, + "DPORT_QSFP56_VDD3.3V_A": {"gettype": "i2c", "bus": 111, "addr": 0x3d, "offset": 0x80, "checkbit": 0, "okval": 0}, + "DPORT_QSFP56_VDD3.3V_B": {"gettype": "i2c", "bus": 111, "addr": 0x3d, "offset": 0x80, "checkbit": 1, "okval": 0}, + "DPORT_QSFP56_VDD3.3V_C": {"gettype": "i2c", "bus": 111, "addr": 0x3d, "offset": 0x80, "checkbit": 2, "okval": 0}, + "DPORT_QSFP56_VDD3.3V_D": {"gettype": "i2c", "bus": 111, "addr": 0x3d, "offset": 0x80, "checkbit": 3, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_A": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 0, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_B": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 1, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_C": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 2, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_D": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 3, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_E": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 4, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_F": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 5, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_G": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 6, "okval": 0}, + "MAC_QSFPDD_VDD3.3V_H": {"gettype": "i2c", "bus": 77, "addr": 0x1d, "offset": 0x7c, "checkbit": 7, "okval": 0}, + }, +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/Makefile b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/Makefile new file mode 100755 index 000000000000..873cb472f957 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/Makefile @@ -0,0 +1,12 @@ +MAKEFILE_FILE_PATH = $(abspath $(lastword $(MAKEFILE_LIST))) +MODULES_DIR = $(abspath $(MAKEFILE_FILE_PATH)/../../../../common/modules) + +EXTRA_CFLAGS+= -I$(MODULES_DIR) + +obj-m += rg_pcie_dev_device.o +obj-m += rg_fpga_i2c_bus_device.o +obj-m += rg_fpga_pca954x_device.o +obj-m += rg_lpc_drv_device.o +obj-m += rg_i2c_dev_device.o +obj-m += rg_io_dev_device.o +obj-m += rg_wdt_device.o \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_i2c_bus_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_i2c_bus_device.c new file mode 100644 index 000000000000..f3022cec2bbb --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_i2c_bus_device.c @@ -0,0 +1,2394 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_fpga_i2c_debug = 0; +static int g_rg_fpga_i2c_error = 0; + +module_param(g_rg_fpga_i2c_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_i2c_error, int, S_IRUGO | S_IWUSR); + +#define RG_FPGA_I2C_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_i2c_debug) { \ + printk(KERN_INFO "[RG_FPGA_I2C][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_FPGA_I2C_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_fpga_i2c_error) { \ + printk(KERN_ERR "[RG_FPGA_I2C][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static fpga_i2c_bus_device_t fpga0_i2c_bus_device_data0 = { + .adap_nr = 2, + .i2c_timeout = 3000, + .i2c_scale = 0x300, + .i2c_filter = 0x304, + .i2c_stretch = 0x308, + .i2c_ext_9548_exits_flag = 0x30c, + .i2c_ext_9548_addr = 0x310, + .i2c_ext_9548_chan = 0x314, + .i2c_in_9548_chan = 0x318, + .i2c_slave = 0x31c, + .i2c_reg = 0x320, + .i2c_reg_len = 0x330, + .i2c_data_len = 0x334, + .i2c_ctrl = 0x338, + .i2c_status = 0x33c, + .i2c_err_vec = 0x348, + .i2c_data_buf = 0x380, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_i2c_bus_device_data1 = { + .adap_nr = 3, + .i2c_timeout = 3000, + .i2c_scale = 0x400, + .i2c_filter = 0x404, + .i2c_stretch = 0x408, + .i2c_ext_9548_exits_flag = 0x40c, + .i2c_ext_9548_addr = 0x410, + .i2c_ext_9548_chan = 0x414, + .i2c_in_9548_chan = 0x418, + .i2c_slave = 0x41c, + .i2c_reg = 0x420, + .i2c_reg_len = 0x430, + .i2c_data_len = 0x434, + .i2c_ctrl = 0x438, + .i2c_status = 0x43c, + .i2c_err_vec = 0x448, + .i2c_data_buf = 0x480, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data0 = { + .adap_nr = 4, + .i2c_timeout = 3000, + .i2c_scale = 0x2c00, + .i2c_filter = 0x2c04, + .i2c_stretch = 0x2c08, + .i2c_ext_9548_exits_flag = 0x2c0c, + .i2c_ext_9548_addr = 0x2c10, + .i2c_ext_9548_chan = 0x2c14, + .i2c_in_9548_chan = 0x2c18, + .i2c_slave = 0x2c1c, + .i2c_reg = 0x2c20, + .i2c_reg_len = 0x2c30, + .i2c_data_len = 0x2c34, + .i2c_ctrl = 0x2c38, + .i2c_status = 0x2c3c, + .i2c_err_vec = 0x2c48, + .i2c_data_buf = 0x2c80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data1 = { + .adap_nr = 5, + .i2c_timeout = 3000, + .i2c_scale = 0x2d00, + .i2c_filter = 0x2d04, + .i2c_stretch = 0x2d08, + .i2c_ext_9548_exits_flag = 0x2d0c, + .i2c_ext_9548_addr = 0x2d10, + .i2c_ext_9548_chan = 0x2d14, + .i2c_in_9548_chan = 0x2d18, + .i2c_slave = 0x2d1c, + .i2c_reg = 0x2d20, + .i2c_reg_len = 0x2d30, + .i2c_data_len = 0x2d34, + .i2c_ctrl = 0x2d38, + .i2c_status = 0x2d3c, + .i2c_err_vec = 0x2d48, + .i2c_data_buf = 0x2d80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data2 = { + .adap_nr = 6, + .i2c_timeout = 3000, + .i2c_scale = 0x2e00, + .i2c_filter = 0x2e04, + .i2c_stretch = 0x2e08, + .i2c_ext_9548_exits_flag = 0x2e0c, + .i2c_ext_9548_addr = 0x2e10, + .i2c_ext_9548_chan = 0x2e14, + .i2c_in_9548_chan = 0x2e18, + .i2c_slave = 0x2e1c, + .i2c_reg = 0x2e20, + .i2c_reg_len = 0x2e30, + .i2c_data_len = 0x2e34, + .i2c_ctrl = 0x2e38, + .i2c_status = 0x2e3c, + .i2c_err_vec = 0x2e48, + .i2c_data_buf = 0x2e80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000004, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data3 = { + .adap_nr = 7, + .i2c_timeout = 3000, + .i2c_scale = 0x2f00, + .i2c_filter = 0x2f04, + .i2c_stretch = 0x2f08, + .i2c_ext_9548_exits_flag = 0x2f0c, + .i2c_ext_9548_addr = 0x2f10, + .i2c_ext_9548_chan = 0x2f14, + .i2c_in_9548_chan = 0x2f18, + .i2c_slave = 0x2f1c, + .i2c_reg = 0x2f20, + .i2c_reg_len = 0x2f30, + .i2c_data_len = 0x2f34, + .i2c_ctrl = 0x2f38, + .i2c_status = 0x2f3c, + .i2c_err_vec = 0x2f48, + .i2c_data_buf = 0x2f80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000008, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data4 = { + .adap_nr = 8, + .i2c_timeout = 3000, + .i2c_scale = 0x3000, + .i2c_filter = 0x3004, + .i2c_stretch = 0x3008, + .i2c_ext_9548_exits_flag = 0x300c, + .i2c_ext_9548_addr = 0x3010, + .i2c_ext_9548_chan = 0x3014, + .i2c_in_9548_chan = 0x3018, + .i2c_slave = 0x301c, + .i2c_reg = 0x3020, + .i2c_reg_len = 0x3030, + .i2c_data_len = 0x3034, + .i2c_ctrl = 0x3038, + .i2c_status = 0x303c, + .i2c_err_vec = 0x3048, + .i2c_data_buf = 0x3080, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000010, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data5 = { + .adap_nr = 9, + .i2c_timeout = 3000, + .i2c_scale = 0x3100, + .i2c_filter = 0x3104, + .i2c_stretch = 0x3108, + .i2c_ext_9548_exits_flag = 0x310c, + .i2c_ext_9548_addr = 0x3110, + .i2c_ext_9548_chan = 0x3114, + .i2c_in_9548_chan = 0x3118, + .i2c_slave = 0x311c, + .i2c_reg = 0x3120, + .i2c_reg_len = 0x3130, + .i2c_data_len = 0x3134, + .i2c_ctrl = 0x3138, + .i2c_status = 0x313c, + .i2c_err_vec = 0x3148, + .i2c_data_buf = 0x3180, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000020, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data6 = { + .adap_nr = 10, + .i2c_timeout = 3000, + .i2c_scale = 0x3200, + .i2c_filter = 0x3204, + .i2c_stretch = 0x3208, + .i2c_ext_9548_exits_flag = 0x320c, + .i2c_ext_9548_addr = 0x3210, + .i2c_ext_9548_chan = 0x3214, + .i2c_in_9548_chan = 0x3218, + .i2c_slave = 0x321c, + .i2c_reg = 0x3220, + .i2c_reg_len = 0x3230, + .i2c_data_len = 0x3234, + .i2c_ctrl = 0x3238, + .i2c_status = 0x323c, + .i2c_err_vec = 0x3248, + .i2c_data_buf = 0x3280, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000040, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data7 = { + .adap_nr = 11, + .i2c_timeout = 3000, + .i2c_scale = 0x3300, + .i2c_filter = 0x3304, + .i2c_stretch = 0x3308, + .i2c_ext_9548_exits_flag = 0x330c, + .i2c_ext_9548_addr = 0x3310, + .i2c_ext_9548_chan = 0x3314, + .i2c_in_9548_chan = 0x3318, + .i2c_slave = 0x331c, + .i2c_reg = 0x3320, + .i2c_reg_len = 0x3330, + .i2c_data_len = 0x3334, + .i2c_ctrl = 0x3338, + .i2c_status = 0x333c, + .i2c_err_vec = 0x3348, + .i2c_data_buf = 0x3380, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000080, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data8 = { + .adap_nr = 12, + .i2c_timeout = 3000, + .i2c_scale = 0x3400, + .i2c_filter = 0x3404, + .i2c_stretch = 0x3408, + .i2c_ext_9548_exits_flag = 0x340c, + .i2c_ext_9548_addr = 0x3410, + .i2c_ext_9548_chan = 0x3414, + .i2c_in_9548_chan = 0x3418, + .i2c_slave = 0x341c, + .i2c_reg = 0x3420, + .i2c_reg_len = 0x3430, + .i2c_data_len = 0x3434, + .i2c_ctrl = 0x3438, + .i2c_status = 0x343c, + .i2c_err_vec = 0x3448, + .i2c_data_buf = 0x3480, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000100, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data9 = { + .adap_nr = 13, + .i2c_timeout = 3000, + .i2c_scale = 0x3500, + .i2c_filter = 0x3504, + .i2c_stretch = 0x3508, + .i2c_ext_9548_exits_flag = 0x350c, + .i2c_ext_9548_addr = 0x3510, + .i2c_ext_9548_chan = 0x3514, + .i2c_in_9548_chan = 0x3518, + .i2c_slave = 0x351c, + .i2c_reg = 0x3520, + .i2c_reg_len = 0x3530, + .i2c_data_len = 0x3534, + .i2c_ctrl = 0x3538, + .i2c_status = 0x353c, + .i2c_err_vec = 0x3548, + .i2c_data_buf = 0x3580, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000200, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data10 = { + .adap_nr = 14, + .i2c_timeout = 3000, + .i2c_scale = 0x3600, + .i2c_filter = 0x3604, + .i2c_stretch = 0x3608, + .i2c_ext_9548_exits_flag = 0x360c, + .i2c_ext_9548_addr = 0x3610, + .i2c_ext_9548_chan = 0x3614, + .i2c_in_9548_chan = 0x3618, + .i2c_slave = 0x361c, + .i2c_reg = 0x3620, + .i2c_reg_len = 0x3630, + .i2c_data_len = 0x3634, + .i2c_ctrl = 0x3638, + .i2c_status = 0x363c, + .i2c_err_vec = 0x3648, + .i2c_data_buf = 0x3680, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000400, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data11 = { + .adap_nr = 15, + .i2c_timeout = 3000, + .i2c_scale = 0x3700, + .i2c_filter = 0x3704, + .i2c_stretch = 0x3708, + .i2c_ext_9548_exits_flag = 0x370c, + .i2c_ext_9548_addr = 0x3710, + .i2c_ext_9548_chan = 0x3714, + .i2c_in_9548_chan = 0x3718, + .i2c_slave = 0x371c, + .i2c_reg = 0x3720, + .i2c_reg_len = 0x3730, + .i2c_data_len = 0x3734, + .i2c_ctrl = 0x3738, + .i2c_status = 0x373c, + .i2c_err_vec = 0x3748, + .i2c_data_buf = 0x3780, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000800, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data12 = { + .adap_nr = 16, + .i2c_timeout = 3000, + .i2c_scale = 0x3800, + .i2c_filter = 0x3804, + .i2c_stretch = 0x3808, + .i2c_ext_9548_exits_flag = 0x380c, + .i2c_ext_9548_addr = 0x3810, + .i2c_ext_9548_chan = 0x3814, + .i2c_in_9548_chan = 0x3818, + .i2c_slave = 0x381c, + .i2c_reg = 0x3820, + .i2c_reg_len = 0x3830, + .i2c_data_len = 0x3834, + .i2c_ctrl = 0x3838, + .i2c_status = 0x383c, + .i2c_err_vec = 0x3848, + .i2c_data_buf = 0x3880, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00001000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data13 = { + .adap_nr = 17, + .i2c_timeout = 3000, + .i2c_scale = 0x3900, + .i2c_filter = 0x3904, + .i2c_stretch = 0x3908, + .i2c_ext_9548_exits_flag = 0x390c, + .i2c_ext_9548_addr = 0x3910, + .i2c_ext_9548_chan = 0x3914, + .i2c_in_9548_chan = 0x3918, + .i2c_slave = 0x391c, + .i2c_reg = 0x3920, + .i2c_reg_len = 0x3930, + .i2c_data_len = 0x3934, + .i2c_ctrl = 0x3938, + .i2c_status = 0x393c, + .i2c_err_vec = 0x3948, + .i2c_data_buf = 0x3980, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00002000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data14 = { + .adap_nr = 18, + .i2c_timeout = 3000, + .i2c_scale = 0x3a00, + .i2c_filter = 0x3a04, + .i2c_stretch = 0x3a08, + .i2c_ext_9548_exits_flag = 0x3a0c, + .i2c_ext_9548_addr = 0x3a10, + .i2c_ext_9548_chan = 0x3a14, + .i2c_in_9548_chan = 0x3a18, + .i2c_slave = 0x3a1c, + .i2c_reg = 0x3a20, + .i2c_reg_len = 0x3a30, + .i2c_data_len = 0x3a34, + .i2c_ctrl = 0x3a38, + .i2c_status = 0x3a3c, + .i2c_err_vec = 0x3a48, + .i2c_data_buf = 0x3a80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00004000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga0_dom_i2c_bus_device_data15 = { + .adap_nr = 19, + .i2c_timeout = 3000, + .i2c_scale = 0x3b00, + .i2c_filter = 0x3b04, + .i2c_stretch = 0x3b08, + .i2c_ext_9548_exits_flag = 0x3b0c, + .i2c_ext_9548_addr = 0x3b10, + .i2c_ext_9548_chan = 0x3b14, + .i2c_in_9548_chan = 0x3b18, + .i2c_slave = 0x3b1c, + .i2c_reg = 0x3b20, + .i2c_reg_len = 0x3b30, + .i2c_data_len = 0x3b34, + .i2c_ctrl = 0x3b38, + .i2c_status = 0x3b3c, + .i2c_err_vec = 0x3b48, + .i2c_data_buf = 0x3b80, + .dev_name = "/dev/fpga0", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00008000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data0 = { + .adap_nr = 20, + .i2c_timeout = 3000, + .i2c_scale = 0x1000, + .i2c_filter = 0x1004, + .i2c_stretch = 0x1008, + .i2c_ext_9548_exits_flag = 0x100c, + .i2c_ext_9548_addr = 0x1010, + .i2c_ext_9548_chan = 0x1014, + .i2c_in_9548_chan = 0x1018, + .i2c_slave = 0x101c, + .i2c_reg = 0x1020, + .i2c_reg_len = 0x1030, + .i2c_data_len = 0x1034, + .i2c_ctrl = 0x1038, + .i2c_status = 0x103c, + .i2c_err_vec = 0x1048, + .i2c_data_buf = 0x1080, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ + .i2c_offset_reg = 0xac, + .i2c_data_buf_len_reg = 0xa4, +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data1 = { + .adap_nr = 21, + .i2c_timeout = 3000, + .i2c_scale = 0x1100, + .i2c_filter = 0x1104, + .i2c_stretch = 0x1108, + .i2c_ext_9548_exits_flag = 0x110c, + .i2c_ext_9548_addr = 0x1110, + .i2c_ext_9548_chan = 0x1114, + .i2c_in_9548_chan = 0x1118, + .i2c_slave = 0x111c, + .i2c_reg = 0x1120, + .i2c_reg_len = 0x1130, + .i2c_data_len = 0x1134, + .i2c_ctrl = 0x1138, + .i2c_status = 0x113c, + .i2c_err_vec = 0x1148, + .i2c_data_buf = 0x1180, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x84, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data2 = { + .adap_nr = 22, + .i2c_timeout = 3000, + .i2c_scale = 0x1200, + .i2c_filter = 0x1204, + .i2c_stretch = 0x1208, + .i2c_ext_9548_exits_flag = 0x120c, + .i2c_ext_9548_addr = 0x1210, + .i2c_ext_9548_chan = 0x1214, + .i2c_in_9548_chan = 0x1218, + .i2c_slave = 0x121c, + .i2c_reg = 0x1220, + .i2c_reg_len = 0x1230, + .i2c_data_len = 0x1234, + .i2c_ctrl = 0x1238, + .i2c_status = 0x123c, + .i2c_err_vec = 0x1248, + .i2c_data_buf = 0x1280, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x88, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data3 = { + .adap_nr = 23, + .i2c_timeout = 3000, + .i2c_scale = 0x1300, + .i2c_filter = 0x1304, + .i2c_stretch = 0x1308, + .i2c_ext_9548_exits_flag = 0x130c, + .i2c_ext_9548_addr = 0x1310, + .i2c_ext_9548_chan = 0x1314, + .i2c_in_9548_chan = 0x1318, + .i2c_slave = 0x131c, + .i2c_reg = 0x1320, + .i2c_reg_len = 0x1330, + .i2c_data_len = 0x1334, + .i2c_ctrl = 0x1338, + .i2c_status = 0x133c, + .i2c_err_vec = 0x1348, + .i2c_data_buf = 0x1380, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x8c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data4 = { + .adap_nr = 24, + .i2c_timeout = 3000, + .i2c_scale = 0x1400, + .i2c_filter = 0x1404, + .i2c_stretch = 0x1408, + .i2c_ext_9548_exits_flag = 0x140c, + .i2c_ext_9548_addr = 0x1410, + .i2c_ext_9548_chan = 0x1414, + .i2c_in_9548_chan = 0x1418, + .i2c_slave = 0x141c, + .i2c_reg = 0x1420, + .i2c_reg_len = 0x1430, + .i2c_data_len = 0x1434, + .i2c_ctrl = 0x1438, + .i2c_status = 0x143c, + .i2c_err_vec = 0x1448, + .i2c_data_buf = 0x1480, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x4c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_i2c_bus_device_data5 = { + .adap_nr = 25, + .i2c_timeout = 3000, + .i2c_scale = 0x1500, + .i2c_filter = 0x1504, + .i2c_stretch = 0x1508, + .i2c_ext_9548_exits_flag = 0x150c, + .i2c_ext_9548_addr = 0x1510, + .i2c_ext_9548_chan = 0x1514, + .i2c_in_9548_chan = 0x1518, + .i2c_slave = 0x151c, + .i2c_reg = 0x1520, + .i2c_reg_len = 0x1530, + .i2c_data_len = 0x1534, + .i2c_ctrl = 0x1538, + .i2c_status = 0x153c, + .i2c_err_vec = 0x1548, + .i2c_data_buf = 0x1580, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x50, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data0 = { + .adap_nr = 26, + .i2c_timeout = 3000, + .i2c_scale = 0x2000, + .i2c_filter = 0x2004, + .i2c_stretch = 0x2008, + .i2c_ext_9548_exits_flag = 0x200c, + .i2c_ext_9548_addr = 0x2010, + .i2c_ext_9548_chan = 0x2014, + .i2c_in_9548_chan = 0x2018, + .i2c_slave = 0x201c, + .i2c_reg = 0x2020, + .i2c_reg_len = 0x2030, + .i2c_data_len = 0x2034, + .i2c_ctrl = 0x2038, + .i2c_status = 0x203c, + .i2c_err_vec = 0x2048, + .i2c_data_buf = 0x2080, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data1 = { + .adap_nr = 27, + .i2c_timeout = 3000, + .i2c_scale = 0x2100, + .i2c_filter = 0x2104, + .i2c_stretch = 0x2108, + .i2c_ext_9548_exits_flag = 0x210c, + .i2c_ext_9548_addr = 0x2110, + .i2c_ext_9548_chan = 0x2114, + .i2c_in_9548_chan = 0x2118, + .i2c_slave = 0x211c, + .i2c_reg = 0x2120, + .i2c_reg_len = 0x2130, + .i2c_data_len = 0x2134, + .i2c_ctrl = 0x2138, + .i2c_status = 0x213c, + .i2c_err_vec = 0x2148, + .i2c_data_buf = 0x2180, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data2 = { + .adap_nr = 28, + .i2c_timeout = 3000, + .i2c_scale = 0x2200, + .i2c_filter = 0x2204, + .i2c_stretch = 0x2208, + .i2c_ext_9548_exits_flag = 0x220c, + .i2c_ext_9548_addr = 0x2210, + .i2c_ext_9548_chan = 0x2214, + .i2c_in_9548_chan = 0x2218, + .i2c_slave = 0x221c, + .i2c_reg = 0x2220, + .i2c_reg_len = 0x2230, + .i2c_data_len = 0x2234, + .i2c_ctrl = 0x2238, + .i2c_status = 0x223c, + .i2c_err_vec = 0x2248, + .i2c_data_buf = 0x2280, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000004, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data3 = { + .adap_nr = 29, + .i2c_timeout = 3000, + .i2c_scale = 0x2300, + .i2c_filter = 0x2304, + .i2c_stretch = 0x2308, + .i2c_ext_9548_exits_flag = 0x230c, + .i2c_ext_9548_addr = 0x2310, + .i2c_ext_9548_chan = 0x2314, + .i2c_in_9548_chan = 0x2318, + .i2c_slave = 0x231c, + .i2c_reg = 0x2320, + .i2c_reg_len = 0x2330, + .i2c_data_len = 0x2334, + .i2c_ctrl = 0x2338, + .i2c_status = 0x233c, + .i2c_err_vec = 0x2348, + .i2c_data_buf = 0x2380, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000008, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data4 = { + .adap_nr = 30, + .i2c_timeout = 3000, + .i2c_scale = 0x2400, + .i2c_filter = 0x2404, + .i2c_stretch = 0x2408, + .i2c_ext_9548_exits_flag = 0x240c, + .i2c_ext_9548_addr = 0x2410, + .i2c_ext_9548_chan = 0x2414, + .i2c_in_9548_chan = 0x2418, + .i2c_slave = 0x241c, + .i2c_reg = 0x2420, + .i2c_reg_len = 0x2430, + .i2c_data_len = 0x2434, + .i2c_ctrl = 0x2438, + .i2c_status = 0x243c, + .i2c_err_vec = 0x2448, + .i2c_data_buf = 0x2480, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000010, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data5 = { + .adap_nr = 31, + .i2c_timeout = 3000, + .i2c_scale = 0x2500, + .i2c_filter = 0x2504, + .i2c_stretch = 0x2508, + .i2c_ext_9548_exits_flag = 0x250c, + .i2c_ext_9548_addr = 0x2510, + .i2c_ext_9548_chan = 0x2514, + .i2c_in_9548_chan = 0x2518, + .i2c_slave = 0x251c, + .i2c_reg = 0x2520, + .i2c_reg_len = 0x2530, + .i2c_data_len = 0x2534, + .i2c_ctrl = 0x2538, + .i2c_status = 0x253c, + .i2c_err_vec = 0x2548, + .i2c_data_buf = 0x2580, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000020, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data6 = { + .adap_nr = 32, + .i2c_timeout = 3000, + .i2c_scale = 0x2600, + .i2c_filter = 0x2604, + .i2c_stretch = 0x2608, + .i2c_ext_9548_exits_flag = 0x260c, + .i2c_ext_9548_addr = 0x2610, + .i2c_ext_9548_chan = 0x2614, + .i2c_in_9548_chan = 0x2618, + .i2c_slave = 0x261c, + .i2c_reg = 0x2620, + .i2c_reg_len = 0x2630, + .i2c_data_len = 0x2634, + .i2c_ctrl = 0x2638, + .i2c_status = 0x263c, + .i2c_err_vec = 0x2648, + .i2c_data_buf = 0x2680, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000040, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data7 = { + .adap_nr = 33, + .i2c_timeout = 3000, + .i2c_scale = 0x2700, + .i2c_filter = 0x2704, + .i2c_stretch = 0x2708, + .i2c_ext_9548_exits_flag = 0x270c, + .i2c_ext_9548_addr = 0x2710, + .i2c_ext_9548_chan = 0x2714, + .i2c_in_9548_chan = 0x2718, + .i2c_slave = 0x271c, + .i2c_reg = 0x2720, + .i2c_reg_len = 0x2730, + .i2c_data_len = 0x2734, + .i2c_ctrl = 0x2738, + .i2c_status = 0x273c, + .i2c_err_vec = 0x2748, + .i2c_data_buf = 0x2780, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000080, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data8 = { + .adap_nr = 34, + .i2c_timeout = 3000, + .i2c_scale = 0x2800, + .i2c_filter = 0x2804, + .i2c_stretch = 0x2808, + .i2c_ext_9548_exits_flag = 0x280c, + .i2c_ext_9548_addr = 0x2810, + .i2c_ext_9548_chan = 0x2814, + .i2c_in_9548_chan = 0x2818, + .i2c_slave = 0x281c, + .i2c_reg = 0x2820, + .i2c_reg_len = 0x2830, + .i2c_data_len = 0x2834, + .i2c_ctrl = 0x2838, + .i2c_status = 0x283c, + .i2c_err_vec = 0x2848, + .i2c_data_buf = 0x2880, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000100, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data9 = { + .adap_nr = 35, + .i2c_timeout = 3000, + .i2c_scale = 0x2900, + .i2c_filter = 0x2904, + .i2c_stretch = 0x2908, + .i2c_ext_9548_exits_flag = 0x290c, + .i2c_ext_9548_addr = 0x2910, + .i2c_ext_9548_chan = 0x2914, + .i2c_in_9548_chan = 0x2918, + .i2c_slave = 0x291c, + .i2c_reg = 0x2920, + .i2c_reg_len = 0x2930, + .i2c_data_len = 0x2934, + .i2c_ctrl = 0x2938, + .i2c_status = 0x293c, + .i2c_err_vec = 0x2948, + .i2c_data_buf = 0x2980, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000200, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data10 = { + .adap_nr = 36, + .i2c_timeout = 3000, + .i2c_scale = 0x2a00, + .i2c_filter = 0x2a04, + .i2c_stretch = 0x2a08, + .i2c_ext_9548_exits_flag = 0x2a0c, + .i2c_ext_9548_addr = 0x2a10, + .i2c_ext_9548_chan = 0x2a14, + .i2c_in_9548_chan = 0x2a18, + .i2c_slave = 0x2a1c, + .i2c_reg = 0x2a20, + .i2c_reg_len = 0x2a30, + .i2c_data_len = 0x2a34, + .i2c_ctrl = 0x2a38, + .i2c_status = 0x2a3c, + .i2c_err_vec = 0x2a48, + .i2c_data_buf = 0x2a80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000400, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data11 = { + .adap_nr = 37, + .i2c_timeout = 3000, + .i2c_scale = 0x2b00, + .i2c_filter = 0x2b04, + .i2c_stretch = 0x2b08, + .i2c_ext_9548_exits_flag = 0x2b0c, + .i2c_ext_9548_addr = 0x2b10, + .i2c_ext_9548_chan = 0x2b14, + .i2c_in_9548_chan = 0x2b18, + .i2c_slave = 0x2b1c, + .i2c_reg = 0x2b20, + .i2c_reg_len = 0x2b30, + .i2c_data_len = 0x2b34, + .i2c_ctrl = 0x2b38, + .i2c_status = 0x2b3c, + .i2c_err_vec = 0x2b48, + .i2c_data_buf = 0x2b80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000800, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data12 = { + .adap_nr = 38, + .i2c_timeout = 3000, + .i2c_scale = 0x2c00, + .i2c_filter = 0x2c04, + .i2c_stretch = 0x2c08, + .i2c_ext_9548_exits_flag = 0x2c0c, + .i2c_ext_9548_addr = 0x2c10, + .i2c_ext_9548_chan = 0x2c14, + .i2c_in_9548_chan = 0x2c18, + .i2c_slave = 0x2c1c, + .i2c_reg = 0x2c20, + .i2c_reg_len = 0x2c30, + .i2c_data_len = 0x2c34, + .i2c_ctrl = 0x2c38, + .i2c_status = 0x2c3c, + .i2c_err_vec = 0x2c48, + .i2c_data_buf = 0x2c80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00001000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data13 = { + .adap_nr = 39, + .i2c_timeout = 3000, + .i2c_scale = 0x2d00, + .i2c_filter = 0x2d04, + .i2c_stretch = 0x2d08, + .i2c_ext_9548_exits_flag = 0x2d0c, + .i2c_ext_9548_addr = 0x2d10, + .i2c_ext_9548_chan = 0x2d14, + .i2c_in_9548_chan = 0x2d18, + .i2c_slave = 0x2d1c, + .i2c_reg = 0x2d20, + .i2c_reg_len = 0x2d30, + .i2c_data_len = 0x2d34, + .i2c_ctrl = 0x2d38, + .i2c_status = 0x2d3c, + .i2c_err_vec = 0x2d48, + .i2c_data_buf = 0x2d80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00002000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data14 = { + .adap_nr = 40, + .i2c_timeout = 3000, + .i2c_scale = 0x2e00, + .i2c_filter = 0x2e04, + .i2c_stretch = 0x2e08, + .i2c_ext_9548_exits_flag = 0x2e0c, + .i2c_ext_9548_addr = 0x2e10, + .i2c_ext_9548_chan = 0x2e14, + .i2c_in_9548_chan = 0x2e18, + .i2c_slave = 0x2e1c, + .i2c_reg = 0x2e20, + .i2c_reg_len = 0x2e30, + .i2c_data_len = 0x2e34, + .i2c_ctrl = 0x2e38, + .i2c_status = 0x2e3c, + .i2c_err_vec = 0x2e48, + .i2c_data_buf = 0x2e80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00004000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga1_dom_i2c_bus_device_data15 = { + .adap_nr = 41, + .i2c_timeout = 3000, + .i2c_scale = 0x2f00, + .i2c_filter = 0x2f04, + .i2c_stretch = 0x2f08, + .i2c_ext_9548_exits_flag = 0x2f0c, + .i2c_ext_9548_addr = 0x2f10, + .i2c_ext_9548_chan = 0x2f14, + .i2c_in_9548_chan = 0x2f18, + .i2c_slave = 0x2f1c, + .i2c_reg = 0x2f20, + .i2c_reg_len = 0x2f30, + .i2c_data_len = 0x2f34, + .i2c_ctrl = 0x2f38, + .i2c_status = 0x2f3c, + .i2c_err_vec = 0x2f48, + .i2c_data_buf = 0x2f80, + .dev_name = "/dev/fpga1", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00008000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_i2c_bus_device_data0 = { + .adap_nr = 42, + .i2c_timeout = 3000, + .i2c_scale = 0x300, + .i2c_filter = 0x304, + .i2c_stretch = 0x308, + .i2c_ext_9548_exits_flag = 0x30c, + .i2c_ext_9548_addr = 0x310, + .i2c_ext_9548_chan = 0x314, + .i2c_in_9548_chan = 0x318, + .i2c_slave = 0x31c, + .i2c_reg = 0x320, + .i2c_reg_len = 0x330, + .i2c_data_len = 0x334, + .i2c_ctrl = 0x338, + .i2c_status = 0x33c, + .i2c_err_vec = 0x348, + .i2c_data_buf = 0x380, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_i2c_bus_device_data1 = { + .adap_nr = 43, + .i2c_timeout = 3000, + .i2c_scale = 0x400, + .i2c_filter = 0x404, + .i2c_stretch = 0x408, + .i2c_ext_9548_exits_flag = 0x40c, + .i2c_ext_9548_addr = 0x410, + .i2c_ext_9548_chan = 0x414, + .i2c_in_9548_chan = 0x418, + .i2c_slave = 0x41c, + .i2c_reg = 0x420, + .i2c_reg_len = 0x430, + .i2c_data_len = 0x434, + .i2c_ctrl = 0x438, + .i2c_status = 0x43c, + .i2c_err_vec = 0x448, + .i2c_data_buf = 0x480, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x80, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data0 = { + .adap_nr = 44, + .i2c_timeout = 3000, + .i2c_scale = 0x2c00, + .i2c_filter = 0x2c04, + .i2c_stretch = 0x2c08, + .i2c_ext_9548_exits_flag = 0x2c0c, + .i2c_ext_9548_addr = 0x2c10, + .i2c_ext_9548_chan = 0x2c14, + .i2c_in_9548_chan = 0x2c18, + .i2c_slave = 0x2c1c, + .i2c_reg = 0x2c20, + .i2c_reg_len = 0x2c30, + .i2c_data_len = 0x2c34, + .i2c_ctrl = 0x2c38, + .i2c_status = 0x2c3c, + .i2c_err_vec = 0x2c48, + .i2c_data_buf = 0x2c80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000001, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data1 = { + .adap_nr = 45, + .i2c_timeout = 3000, + .i2c_scale = 0x2d00, + .i2c_filter = 0x2d04, + .i2c_stretch = 0x2d08, + .i2c_ext_9548_exits_flag = 0x2d0c, + .i2c_ext_9548_addr = 0x2d10, + .i2c_ext_9548_chan = 0x2d14, + .i2c_in_9548_chan = 0x2d18, + .i2c_slave = 0x2d1c, + .i2c_reg = 0x2d20, + .i2c_reg_len = 0x2d30, + .i2c_data_len = 0x2d34, + .i2c_ctrl = 0x2d38, + .i2c_status = 0x2d3c, + .i2c_err_vec = 0x2d48, + .i2c_data_buf = 0x2d80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000002, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data2 = { + .adap_nr = 46, + .i2c_timeout = 3000, + .i2c_scale = 0x2e00, + .i2c_filter = 0x2e04, + .i2c_stretch = 0x2e08, + .i2c_ext_9548_exits_flag = 0x2e0c, + .i2c_ext_9548_addr = 0x2e10, + .i2c_ext_9548_chan = 0x2e14, + .i2c_in_9548_chan = 0x2e18, + .i2c_slave = 0x2e1c, + .i2c_reg = 0x2e20, + .i2c_reg_len = 0x2e30, + .i2c_data_len = 0x2e34, + .i2c_ctrl = 0x2e38, + .i2c_status = 0x2e3c, + .i2c_err_vec = 0x2e48, + .i2c_data_buf = 0x2e80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000004, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data3 = { + .adap_nr = 47, + .i2c_timeout = 3000, + .i2c_scale = 0x2f00, + .i2c_filter = 0x2f04, + .i2c_stretch = 0x2f08, + .i2c_ext_9548_exits_flag = 0x2f0c, + .i2c_ext_9548_addr = 0x2f10, + .i2c_ext_9548_chan = 0x2f14, + .i2c_in_9548_chan = 0x2f18, + .i2c_slave = 0x2f1c, + .i2c_reg = 0x2f20, + .i2c_reg_len = 0x2f30, + .i2c_data_len = 0x2f34, + .i2c_ctrl = 0x2f38, + .i2c_status = 0x2f3c, + .i2c_err_vec = 0x2f48, + .i2c_data_buf = 0x2f80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000008, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data4 = { + .adap_nr = 48, + .i2c_timeout = 3000, + .i2c_scale = 0x3000, + .i2c_filter = 0x3004, + .i2c_stretch = 0x3008, + .i2c_ext_9548_exits_flag = 0x300c, + .i2c_ext_9548_addr = 0x3010, + .i2c_ext_9548_chan = 0x3014, + .i2c_in_9548_chan = 0x3018, + .i2c_slave = 0x301c, + .i2c_reg = 0x3020, + .i2c_reg_len = 0x3030, + .i2c_data_len = 0x3034, + .i2c_ctrl = 0x3038, + .i2c_status = 0x303c, + .i2c_err_vec = 0x3048, + .i2c_data_buf = 0x3080, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000010, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data5 = { + .adap_nr = 49, + .i2c_timeout = 3000, + .i2c_scale = 0x3100, + .i2c_filter = 0x3104, + .i2c_stretch = 0x3108, + .i2c_ext_9548_exits_flag = 0x310c, + .i2c_ext_9548_addr = 0x3110, + .i2c_ext_9548_chan = 0x3114, + .i2c_in_9548_chan = 0x3118, + .i2c_slave = 0x311c, + .i2c_reg = 0x3120, + .i2c_reg_len = 0x3130, + .i2c_data_len = 0x3134, + .i2c_ctrl = 0x3138, + .i2c_status = 0x313c, + .i2c_err_vec = 0x3148, + .i2c_data_buf = 0x3180, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000020, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data6 = { + .adap_nr = 50, + .i2c_timeout = 3000, + .i2c_scale = 0x3200, + .i2c_filter = 0x3204, + .i2c_stretch = 0x3208, + .i2c_ext_9548_exits_flag = 0x320c, + .i2c_ext_9548_addr = 0x3210, + .i2c_ext_9548_chan = 0x3214, + .i2c_in_9548_chan = 0x3218, + .i2c_slave = 0x321c, + .i2c_reg = 0x3220, + .i2c_reg_len = 0x3230, + .i2c_data_len = 0x3234, + .i2c_ctrl = 0x3238, + .i2c_status = 0x323c, + .i2c_err_vec = 0x3248, + .i2c_data_buf = 0x3280, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000040, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data7 = { + .adap_nr = 51, + .i2c_timeout = 3000, + .i2c_scale = 0x3300, + .i2c_filter = 0x3304, + .i2c_stretch = 0x3308, + .i2c_ext_9548_exits_flag = 0x330c, + .i2c_ext_9548_addr = 0x3310, + .i2c_ext_9548_chan = 0x3314, + .i2c_in_9548_chan = 0x3318, + .i2c_slave = 0x331c, + .i2c_reg = 0x3320, + .i2c_reg_len = 0x3330, + .i2c_data_len = 0x3334, + .i2c_ctrl = 0x3338, + .i2c_status = 0x333c, + .i2c_err_vec = 0x3348, + .i2c_data_buf = 0x3380, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000080, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data8 = { + .adap_nr = 52, + .i2c_timeout = 3000, + .i2c_scale = 0x3400, + .i2c_filter = 0x3404, + .i2c_stretch = 0x3408, + .i2c_ext_9548_exits_flag = 0x340c, + .i2c_ext_9548_addr = 0x3410, + .i2c_ext_9548_chan = 0x3414, + .i2c_in_9548_chan = 0x3418, + .i2c_slave = 0x341c, + .i2c_reg = 0x3420, + .i2c_reg_len = 0x3430, + .i2c_data_len = 0x3434, + .i2c_ctrl = 0x3438, + .i2c_status = 0x343c, + .i2c_err_vec = 0x3448, + .i2c_data_buf = 0x3480, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000100, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data9 = { + .adap_nr = 53, + .i2c_timeout = 3000, + .i2c_scale = 0x3500, + .i2c_filter = 0x3504, + .i2c_stretch = 0x3508, + .i2c_ext_9548_exits_flag = 0x350c, + .i2c_ext_9548_addr = 0x3510, + .i2c_ext_9548_chan = 0x3514, + .i2c_in_9548_chan = 0x3518, + .i2c_slave = 0x351c, + .i2c_reg = 0x3520, + .i2c_reg_len = 0x3530, + .i2c_data_len = 0x3534, + .i2c_ctrl = 0x3538, + .i2c_status = 0x353c, + .i2c_err_vec = 0x3548, + .i2c_data_buf = 0x3580, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000200, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data10 = { + .adap_nr = 54, + .i2c_timeout = 3000, + .i2c_scale = 0x3600, + .i2c_filter = 0x3604, + .i2c_stretch = 0x3608, + .i2c_ext_9548_exits_flag = 0x360c, + .i2c_ext_9548_addr = 0x3610, + .i2c_ext_9548_chan = 0x3614, + .i2c_in_9548_chan = 0x3618, + .i2c_slave = 0x361c, + .i2c_reg = 0x3620, + .i2c_reg_len = 0x3630, + .i2c_data_len = 0x3634, + .i2c_ctrl = 0x3638, + .i2c_status = 0x363c, + .i2c_err_vec = 0x3648, + .i2c_data_buf = 0x3680, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000400, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data11 = { + .adap_nr = 55, + .i2c_timeout = 3000, + .i2c_scale = 0x3700, + .i2c_filter = 0x3704, + .i2c_stretch = 0x3708, + .i2c_ext_9548_exits_flag = 0x370c, + .i2c_ext_9548_addr = 0x3710, + .i2c_ext_9548_chan = 0x3714, + .i2c_in_9548_chan = 0x3718, + .i2c_slave = 0x371c, + .i2c_reg = 0x3720, + .i2c_reg_len = 0x3730, + .i2c_data_len = 0x3734, + .i2c_ctrl = 0x3738, + .i2c_status = 0x373c, + .i2c_err_vec = 0x3748, + .i2c_data_buf = 0x3780, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00000800, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data12 = { + .adap_nr = 56, + .i2c_timeout = 3000, + .i2c_scale = 0x3800, + .i2c_filter = 0x3804, + .i2c_stretch = 0x3808, + .i2c_ext_9548_exits_flag = 0x380c, + .i2c_ext_9548_addr = 0x3810, + .i2c_ext_9548_chan = 0x3814, + .i2c_in_9548_chan = 0x3818, + .i2c_slave = 0x381c, + .i2c_reg = 0x3820, + .i2c_reg_len = 0x3830, + .i2c_data_len = 0x3834, + .i2c_ctrl = 0x3838, + .i2c_status = 0x383c, + .i2c_err_vec = 0x3848, + .i2c_data_buf = 0x3880, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00001000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data13 = { + .adap_nr = 57, + .i2c_timeout = 3000, + .i2c_scale = 0x3900, + .i2c_filter = 0x3904, + .i2c_stretch = 0x3908, + .i2c_ext_9548_exits_flag = 0x390c, + .i2c_ext_9548_addr = 0x3910, + .i2c_ext_9548_chan = 0x3914, + .i2c_in_9548_chan = 0x3918, + .i2c_slave = 0x391c, + .i2c_reg = 0x3920, + .i2c_reg_len = 0x3930, + .i2c_data_len = 0x3934, + .i2c_ctrl = 0x3938, + .i2c_status = 0x393c, + .i2c_err_vec = 0x3948, + .i2c_data_buf = 0x3980, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00002000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data14 = { + .adap_nr = 58, + .i2c_timeout = 3000, + .i2c_scale = 0x3a00, + .i2c_filter = 0x3a04, + .i2c_stretch = 0x3a08, + .i2c_ext_9548_exits_flag = 0x3a0c, + .i2c_ext_9548_addr = 0x3a10, + .i2c_ext_9548_chan = 0x3a14, + .i2c_in_9548_chan = 0x3a18, + .i2c_slave = 0x3a1c, + .i2c_reg = 0x3a20, + .i2c_reg_len = 0x3a30, + .i2c_data_len = 0x3a34, + .i2c_ctrl = 0x3a38, + .i2c_status = 0x3a3c, + .i2c_err_vec = 0x3a48, + .i2c_data_buf = 0x3a80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00004000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static fpga_i2c_bus_device_t fpga2_dom_i2c_bus_device_data15 = { + .adap_nr = 59, + .i2c_timeout = 3000, + .i2c_scale = 0x3b00, + .i2c_filter = 0x3b04, + .i2c_stretch = 0x3b08, + .i2c_ext_9548_exits_flag = 0x3b0c, + .i2c_ext_9548_addr = 0x3b10, + .i2c_ext_9548_chan = 0x3b14, + .i2c_in_9548_chan = 0x3b18, + .i2c_slave = 0x3b1c, + .i2c_reg = 0x3b20, + .i2c_reg_len = 0x3b30, + .i2c_data_len = 0x3b34, + .i2c_ctrl = 0x3b38, + .i2c_status = 0x3b3c, + .i2c_err_vec = 0x3b48, + .i2c_data_buf = 0x3b80, + .dev_name = "/dev/fpga2", + .i2c_scale_value = 0x4e, + .i2c_filter_value = 0x7c, + .i2c_stretch_value = 0x7c, + .i2c_func_mode = 2, + .i2c_adap_reset_flag = 1, + .i2c_reset_addr = 0x7c, + .i2c_reset_on = 0x00008000, + .i2c_reset_off = 0x00000000, + .i2c_rst_delay_b = 0, /* delay time before reset(us) */ + .i2c_rst_delay = 1, /* reset time(us) */ + .i2c_rst_delay_a = 1, /* delay time after reset(us) */ +}; + +static void rg_fpga_i2c_bus_device_release(struct device *dev) +{ + return; +} + +static struct platform_device fpga_i2c_bus_device[] = { + { + .name = "rg-fpga-i2c", + .id = 1, + .dev = { + .platform_data = &fpga0_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 2, + .dev = { + .platform_data = &fpga0_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 3, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 4, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 5, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 6, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 7, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 8, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 9, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data6, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 10, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data7, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 11, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data8, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 12, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data9, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 13, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data10, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 14, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data11, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 15, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data12, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 16, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data13, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 17, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data14, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 18, + .dev = { + .platform_data = &fpga0_dom_i2c_bus_device_data15, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 19, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 20, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 21, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 22, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 23, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 24, + .dev = { + .platform_data = &fpga1_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 25, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 26, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 27, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 28, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 29, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 30, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 31, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data6, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 32, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data7, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 33, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data8, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 34, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data9, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 35, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data10, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 36, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data11, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 37, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data12, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 38, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data13, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 39, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data14, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 40, + .dev = { + .platform_data = &fpga1_dom_i2c_bus_device_data15, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 41, + .dev = { + .platform_data = &fpga2_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 42, + .dev = { + .platform_data = &fpga2_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 43, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data0, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 44, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data1, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 45, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data2, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 46, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data3, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 47, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data4, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 48, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data5, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 49, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data6, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 50, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data7, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 51, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data8, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 52, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data9, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 53, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data10, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 54, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data11, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 55, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data12, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 56, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data13, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 57, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data14, + .release = rg_fpga_i2c_bus_device_release, + }, + }, + { + .name = "rg-fpga-i2c", + .id = 58, + .dev = { + .platform_data = &fpga2_dom_i2c_bus_device_data15, + .release = rg_fpga_i2c_bus_device_release, + }, + }, +}; + +static int __init rg_fpga_i2c_bus_device_init(void) +{ + int i; + int ret = 0; + fpga_i2c_bus_device_t *fpga_i2c_bus_device_data; + + RG_FPGA_I2C_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(fpga_i2c_bus_device); i++) { + fpga_i2c_bus_device_data = fpga_i2c_bus_device[i].dev.platform_data; + ret = platform_device_register(&fpga_i2c_bus_device[i]); + if (ret < 0) { + fpga_i2c_bus_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-fpga-i2c.%d register failed!\n", i + 1); + } else { + fpga_i2c_bus_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_fpga_i2c_bus_device_exit(void) +{ + int i; + fpga_i2c_bus_device_t *fpga_i2c_bus_device_data; + + RG_FPGA_I2C_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(fpga_i2c_bus_device) - 1; i >= 0; i--) { + fpga_i2c_bus_device_data = fpga_i2c_bus_device[i].dev.platform_data; + if (fpga_i2c_bus_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&fpga_i2c_bus_device[i]); + } + } +} + +module_init(rg_fpga_i2c_bus_device_init); +module_exit(rg_fpga_i2c_bus_device_exit); +MODULE_DESCRIPTION("FPGA I2C Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_pca954x_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_pca954x_device.c new file mode 100644 index 000000000000..4fd4539da6f3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_fpga_pca954x_device.c @@ -0,0 +1,824 @@ +#include +#include +#include +#include +#include +#include + +#include + +static int g_rg_fpga_pca954x_device_debug = 0; +static int g_rg_fpga_pca954x_device_error = 0; + +module_param(g_rg_fpga_pca954x_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_fpga_pca954x_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_fpga_pca954x_device_debug) { \ + printk(KERN_INFO "[RG_FPGA_PCA954X_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_FPGA_PCA954X_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_fpga_pca954x_device_error) { \ + printk(KERN_ERR "[RG_FPGA_PCA954X_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static fpga_pca954x_device_t fpga0_i2c0_pca954x_device_data = { + .i2c_bus = 2, + .i2c_addr = 0x70, + .pca9548_base_nr = 60, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_i2c1_pca954x_device_data = { + .i2c_bus = 3, + .i2c_addr = 0x70, + .pca9548_base_nr = 61, /* 61~64 */ + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c0_pca954x_device_data = { + .i2c_bus = 20, + .i2c_addr = 0x70, + .pca9548_base_nr = 65, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c1_pca954x_device_data = { + .i2c_bus = 21, + .i2c_addr = 0x70, + .pca9548_base_nr = 66, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c2_pca954x_device_data = { + .i2c_bus = 22, + .i2c_addr = 0x70, + .pca9548_base_nr = 67, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c3_pca954x_device_data = { + .i2c_bus = 23, + .i2c_addr = 0x70, + .pca9548_base_nr = 68, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c4_pca954x_device_data = { + .i2c_bus = 24, + .i2c_addr = 0x70, + .pca9548_base_nr = 69, /* 69~76 */ + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c5_pca954x_device_data = { + .i2c_bus = 25, + .i2c_addr = 0x70, + .pca9548_base_nr = 77, /* 77~78 */ + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_i2c0_in0_pca954x_device_data = { + .i2c_bus = 65, + .i2c_addr = 0x76, + .pca9548_base_nr = 79, /* 79~86 */ + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga1_i2c1_in0_pca954x_device_data = { + .i2c_bus = 66, + .i2c_addr = 0x77, + .pca9548_base_nr = 87, /* 87~94 */ + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga1_i2c2_in0_pca954x_device_data = { + .i2c_bus = 67, + .i2c_addr = 0x77, + .pca9548_base_nr = 95, /* 95~102 */ + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga1_i2c3_in0_pca954x_device_data = { + .i2c_bus = 68, + .i2c_addr = 0x77, + .pca9548_base_nr = 103, /* 103~110 */ + .fpga_9548_flag = 2, + .fpga_9548_reset_flag = 1, +}; + +static fpga_pca954x_device_t fpga2_i2c0_pca954x_device_data = { + .i2c_bus = 42, + .i2c_addr = 0x70, + .pca9548_base_nr = 111, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_i2c1_pca954x_device_data = { + .i2c_bus = 43, + .i2c_addr = 0x70, + .pca9548_base_nr = 112, /* 112~115 */ + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c0_pca954x_device_data = { + .i2c_bus = 4, + .i2c_addr = 0x70, + .pca9548_base_nr = 124, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c1_pca954x_device_data = { + .i2c_bus = 5, + .i2c_addr = 0x70, + .pca9548_base_nr = 126, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c2_pca954x_device_data = { + .i2c_bus = 6, + .i2c_addr = 0x70, + .pca9548_base_nr = 128, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c3_pca954x_device_data = { + .i2c_bus = 7, + .i2c_addr = 0x70, + .pca9548_base_nr = 130, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c4_pca954x_device_data = { + .i2c_bus = 8, + .i2c_addr = 0x70, + .pca9548_base_nr = 132, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c5_pca954x_device_data = { + .i2c_bus = 9, + .i2c_addr = 0x70, + .pca9548_base_nr = 134, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c6_pca954x_device_data = { + .i2c_bus = 10, + .i2c_addr = 0x70, + .pca9548_base_nr = 136, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c7_pca954x_device_data = { + .i2c_bus = 11, + .i2c_addr = 0x70, + .pca9548_base_nr = 138, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c8_pca954x_device_data = { + .i2c_bus = 12, + .i2c_addr = 0x70, + .pca9548_base_nr = 140, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c9_pca954x_device_data = { + .i2c_bus = 13, + .i2c_addr = 0x70, + .pca9548_base_nr = 142, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c10_pca954x_device_data = { + .i2c_bus = 14, + .i2c_addr = 0x70, + .pca9548_base_nr = 144, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c11_pca954x_device_data = { + .i2c_bus = 15, + .i2c_addr = 0x70, + .pca9548_base_nr = 146, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c12_pca954x_device_data = { + .i2c_bus = 16, + .i2c_addr = 0x70, + .pca9548_base_nr = 148, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c13_pca954x_device_data = { + .i2c_bus = 17, + .i2c_addr = 0x70, + .pca9548_base_nr = 150, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c14_pca954x_device_data = { + .i2c_bus = 18, + .i2c_addr = 0x70, + .pca9548_base_nr = 152, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga0_dom_i2c15_pca954x_device_data = { + .i2c_bus = 19, + .i2c_addr = 0x70, + .pca9548_base_nr = 154, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c0_pca954x_device_data = { + .i2c_bus = 26, + .i2c_addr = 0x70, + .pca9548_base_nr = 156, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c1_pca954x_device_data = { + .i2c_bus = 27, + .i2c_addr = 0x70, + .pca9548_base_nr = 160, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c2_pca954x_device_data = { + .i2c_bus = 28, + .i2c_addr = 0x70, + .pca9548_base_nr = 164, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c3_pca954x_device_data = { + .i2c_bus = 29, + .i2c_addr = 0x70, + .pca9548_base_nr = 168, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c4_pca954x_device_data = { + .i2c_bus = 30, + .i2c_addr = 0x70, + .pca9548_base_nr = 172, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c5_pca954x_device_data = { + .i2c_bus = 31, + .i2c_addr = 0x70, + .pca9548_base_nr = 176, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c6_pca954x_device_data = { + .i2c_bus = 32, + .i2c_addr = 0x70, + .pca9548_base_nr = 180, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c7_pca954x_device_data = { + .i2c_bus = 33, + .i2c_addr = 0x70, + .pca9548_base_nr = 184, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c8_pca954x_device_data = { + .i2c_bus = 34, + .i2c_addr = 0x70, + .pca9548_base_nr = 188, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c9_pca954x_device_data = { + .i2c_bus = 35, + .i2c_addr = 0x70, + .pca9548_base_nr = 192, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c10_pca954x_device_data = { + .i2c_bus = 36, + .i2c_addr = 0x70, + .pca9548_base_nr = 196, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c11_pca954x_device_data = { + .i2c_bus = 37, + .i2c_addr = 0x70, + .pca9548_base_nr = 200, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c12_pca954x_device_data = { + .i2c_bus = 38, + .i2c_addr = 0x70, + .pca9548_base_nr = 204, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c13_pca954x_device_data = { + .i2c_bus = 39, + .i2c_addr = 0x70, + .pca9548_base_nr = 208, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c14_pca954x_device_data = { + .i2c_bus = 40, + .i2c_addr = 0x70, + .pca9548_base_nr = 212, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga1_dom_i2c15_pca954x_device_data = { + .i2c_bus = 41, + .i2c_addr = 0x70, + .pca9548_base_nr = 216, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c0_pca954x_device_data = { + .i2c_bus = 44, + .i2c_addr = 0x70, + .pca9548_base_nr = 220, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c1_pca954x_device_data = { + .i2c_bus = 45, + .i2c_addr = 0x70, + .pca9548_base_nr = 222, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c2_pca954x_device_data = { + .i2c_bus = 46, + .i2c_addr = 0x70, + .pca9548_base_nr = 224, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c3_pca954x_device_data = { + .i2c_bus = 47, + .i2c_addr = 0x70, + .pca9548_base_nr = 226, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c4_pca954x_device_data = { + .i2c_bus = 48, + .i2c_addr = 0x70, + .pca9548_base_nr = 228, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c5_pca954x_device_data = { + .i2c_bus = 49, + .i2c_addr = 0x70, + .pca9548_base_nr = 230, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c6_pca954x_device_data = { + .i2c_bus = 50, + .i2c_addr = 0x70, + .pca9548_base_nr = 232, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c7_pca954x_device_data = { + .i2c_bus = 51, + .i2c_addr = 0x70, + .pca9548_base_nr = 234, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c8_pca954x_device_data = { + .i2c_bus = 52, + .i2c_addr = 0x70, + .pca9548_base_nr = 236, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c9_pca954x_device_data = { + .i2c_bus = 53, + .i2c_addr = 0x70, + .pca9548_base_nr = 238, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c10_pca954x_device_data = { + .i2c_bus = 54, + .i2c_addr = 0x70, + .pca9548_base_nr = 240, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c11_pca954x_device_data = { + .i2c_bus = 55, + .i2c_addr = 0x70, + .pca9548_base_nr = 242, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c12_pca954x_device_data = { + .i2c_bus = 56, + .i2c_addr = 0x70, + .pca9548_base_nr = 244, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c13_pca954x_device_data = { + .i2c_bus = 57, + .i2c_addr = 0x70, + .pca9548_base_nr = 246, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c14_pca954x_device_data = { + .i2c_bus = 58, + .i2c_addr = 0x70, + .pca9548_base_nr = 248, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +static fpga_pca954x_device_t fpga2_dom_i2c15_pca954x_device_data = { + .i2c_bus = 59, + .i2c_addr = 0x70, + .pca9548_base_nr = 250, + .fpga_9548_flag = 1, + .fpga_9548_reset_flag = 0, +}; + +struct i2c_board_info fpga_pca954x_device_info[] = { + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga0_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga0_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga1_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga1_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga1_i2c2_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga1_i2c3_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c4_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga1_i2c5_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c0_in0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c1_in0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c2_in0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9548", + .platform_data = &fpga1_i2c3_in0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9541", + .platform_data = &fpga2_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga2_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c2_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c3_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c4_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c5_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c6_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c7_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c8_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c9_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c10_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c11_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c12_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c13_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c14_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga0_dom_i2c15_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c2_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c3_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c4_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c5_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c6_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c7_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c8_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c9_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c10_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c11_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c12_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c13_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c14_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9545", + .platform_data = &fpga1_dom_i2c15_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c0_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c1_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c2_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c3_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c4_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c5_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c6_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c7_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c8_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c9_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c10_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c11_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c12_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c13_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c14_pca954x_device_data, + }, + { + .type = "rg_fpga_pca9542", + .platform_data = &fpga2_dom_i2c15_pca954x_device_data, + }, +}; + +static int __init rg_fpga_pca954x_device_init(void) +{ + int i; + struct i2c_adapter *adap; + struct i2c_client *client; + fpga_pca954x_device_t *fpga_pca954x_device_data; + + RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(fpga_pca954x_device_info); i++) { + fpga_pca954x_device_data = fpga_pca954x_device_info[i].platform_data; + fpga_pca954x_device_info[i].addr = fpga_pca954x_device_data->i2c_addr; + adap = i2c_get_adapter(fpga_pca954x_device_data->i2c_bus); + if (adap == NULL) { + fpga_pca954x_device_data->client = NULL; + printk(KERN_ERR "get i2c bus %d adapter fail.\n", fpga_pca954x_device_data->i2c_bus); + continue; + } + client = i2c_new_client_device(adap, &fpga_pca954x_device_info[i]); + if (!client) { + fpga_pca954x_device_data->client = NULL; + printk(KERN_ERR "Failed to register fpga pca954x device %d at bus %d!\n", + fpga_pca954x_device_data->i2c_addr, fpga_pca954x_device_data->i2c_bus); + } else { + fpga_pca954x_device_data->client = client; + } + i2c_put_adapter(adap); + } + return 0; +} + +static void __exit rg_fpga_pca954x_device_exit(void) +{ + int i; + fpga_pca954x_device_t *fpga_pca954x_device_data; + + RG_FPGA_PCA954X_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(fpga_pca954x_device_info) - 1; i >= 0; i--) { + fpga_pca954x_device_data = fpga_pca954x_device_info[i].platform_data; + if (fpga_pca954x_device_data->client) { + i2c_unregister_device(fpga_pca954x_device_data->client); + fpga_pca954x_device_data->client = NULL; + } + } +} + +module_init(rg_fpga_pca954x_device_init); +module_exit(rg_fpga_pca954x_device_exit); +MODULE_DESCRIPTION("RG FPGA PCA954X Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_i2c_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_i2c_dev_device.c new file mode 100644 index 000000000000..651d5e794417 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_i2c_dev_device.c @@ -0,0 +1,185 @@ +#include +#include +#include +#include +#include +#include + +#include + +static int g_rg_i2c_dev_device_debug = 0; +static int g_rg_i2c_dev_device_error = 0; + +module_param(g_rg_i2c_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_i2c_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_I2C_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_i2c_dev_device_debug) { \ + printk(KERN_INFO "[RG_I2C_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_I2C_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_i2c_dev_device_error) { \ + printk(KERN_ERR "[RG_I2C_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static i2c_dev_device_t i2c_dev_device_data0 = { + .i2c_bus = 60, + .i2c_addr = 0x3d, + .i2c_name = "cpld2", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data1 = { + .i2c_bus = 87, + .i2c_addr = 0x0d, + .i2c_name = "cpld3", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data2 = { + .i2c_bus = 95, + .i2c_addr = 0x0d, + .i2c_name = "cpld4", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data3 = { + .i2c_bus = 77, + .i2c_addr = 0x1d, + .i2c_name = "cpld5", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data4 = { + .i2c_bus = 77, + .i2c_addr = 0x2d, + .i2c_name = "cpld6", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data5 = { + .i2c_bus = 111, + .i2c_addr = 0x3d, + .i2c_name = "cpld7", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +static i2c_dev_device_t i2c_dev_device_data6 = { + .i2c_bus = 108, + .i2c_addr = 0x3b, + .i2c_name = "cpld8", + .data_bus_width = 1, + .addr_bus_width = 1, + .per_rd_len = 256, + .per_wr_len = 256, + .i2c_len = 256, +}; + +struct i2c_board_info i2c_dev_device_info[] = { + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data0, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data1, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data2, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data3, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data4, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data5, + }, + { + .type = "rg-i2c-dev", + .platform_data = &i2c_dev_device_data6, + }, +}; + +static int __init rg_i2c_dev_device_init(void) +{ + int i; + struct i2c_adapter *adap; + struct i2c_client *client; + i2c_dev_device_t *i2c_dev_device_data; + + RG_I2C_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(i2c_dev_device_info); i++) { + i2c_dev_device_data = i2c_dev_device_info[i].platform_data; + i2c_dev_device_info[i].addr = i2c_dev_device_data->i2c_addr; + adap = i2c_get_adapter(i2c_dev_device_data->i2c_bus); + if (adap == NULL) { + i2c_dev_device_data->client = NULL; + printk(KERN_ERR "get i2c bus %d adapter fail.\n", i2c_dev_device_data->i2c_bus); + continue; + } + client = i2c_new_client_device(adap, &i2c_dev_device_info[i]); + if (!client) { + i2c_dev_device_data->client = NULL; + printk(KERN_ERR "Failed to register i2c dev device %d at bus %d!\n", + i2c_dev_device_data->i2c_addr, i2c_dev_device_data->i2c_bus); + } else { + i2c_dev_device_data->client = client; + } + i2c_put_adapter(adap); + } + return 0; +} + +static void __exit rg_i2c_dev_device_exit(void) +{ + int i; + i2c_dev_device_t *i2c_dev_device_data; + + RG_I2C_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(i2c_dev_device_info) - 1; i >= 0; i--) { + i2c_dev_device_data = i2c_dev_device_info[i].platform_data; + if (i2c_dev_device_data->client) { + i2c_unregister_device(i2c_dev_device_data->client); + i2c_dev_device_data->client = NULL; + } + } +} + +module_init(rg_i2c_dev_device_init); +module_exit(rg_i2c_dev_device_exit); +MODULE_DESCRIPTION("RG I2C DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_io_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_io_dev_device.c new file mode 100644 index 000000000000..42d887e9f2d1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_io_dev_device.c @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_io_dev_device_debug = 0; +static int g_rg_io_dev_device_error = 0; + +module_param(g_rg_io_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_io_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_IO_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_io_dev_device_debug) { \ + printk(KERN_INFO "[RG_IO_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_IO_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_io_dev_device_error) { \ + printk(KERN_ERR "[RG_IO_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static io_dev_device_t io_dev_device_data0 = { + .io_dev_name = "cpld0", + .io_base = 0x700, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static io_dev_device_t io_dev_device_data1 = { + .io_dev_name = "cpld1", + .io_base = 0x900, + .io_len = 0x100, + .indirect_addr = 0, +}; + +static void rg_io_dev_device_release(struct device *dev) +{ + return; +} + +static struct platform_device io_dev_device[] = { + { + .name = "rg-io-dev", + .id = 1, + .dev = { + .platform_data = &io_dev_device_data0, + .release = rg_io_dev_device_release, + }, + }, + { + .name = "rg-io-dev", + .id = 2, + .dev = { + .platform_data = &io_dev_device_data1, + .release = rg_io_dev_device_release, + }, + }, +}; + +static int __init rg_io_dev_device_init(void) +{ + int i; + int ret = 0; + io_dev_device_t *io_dev_device_data; + + RG_IO_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(io_dev_device); i++) { + io_dev_device_data = io_dev_device[i].dev.platform_data; + ret = platform_device_register(&io_dev_device[i]); + if (ret < 0) { + io_dev_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-io-dev.%d register failed!\n", i + 1); + } else { + io_dev_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_io_dev_device_exit(void) +{ + int i; + io_dev_device_t *io_dev_device_data; + + RG_IO_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(io_dev_device) - 1; i >= 0; i--) { + io_dev_device_data = io_dev_device[i].dev.platform_data; + if (io_dev_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&io_dev_device[i]); + } + } +} + +module_init(rg_io_dev_device_init); +module_exit(rg_io_dev_device_exit); +MODULE_DESCRIPTION("RG IO DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_lpc_drv_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_lpc_drv_device.c new file mode 100644 index 000000000000..c6a0d37c1428 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_lpc_drv_device.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_lpc_drv_device_debug = 0; +static int g_rg_lpc_drv_device_error = 0; + +module_param(g_rg_lpc_drv_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_lpc_drv_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_LPC_DRV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_lpc_drv_device_debug) { \ + printk(KERN_INFO "[RG_LPC_DRV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_LPC_DRV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_lpc_drv_device_error) { \ + printk(KERN_ERR "[RG_LPC_DRV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static lpc_drv_device_t lpc_drv_device_data_0 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0x700, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x84, +}; + +static lpc_drv_device_t lpc_drv_device_data_1 = { + .lpc_io_name = "rg_lpc", + .pci_domain = 0x0000, + .pci_bus = 0x00, + .pci_slot = 0x1f, + .pci_fn = 0, + .lpc_io_base = 0x900, + .lpc_io_size = 0x100, + .lpc_gen_dec = 0x88, +}; + +static void rg_lpc_drv_device_release(struct device *dev) +{ + return; +} + +static struct platform_device lpc_drv_device[] = { + { + .name = "rg-lpc", + .id = 1, + .dev = { + .platform_data = &lpc_drv_device_data_0, + .release = rg_lpc_drv_device_release, + }, + }, + { + .name = "rg-lpc", + .id = 2, + .dev = { + .platform_data = &lpc_drv_device_data_1, + .release = rg_lpc_drv_device_release, + }, + }, +}; + +static int __init rg_lpc_drv_device_init(void) +{ + int i; + int ret = 0; + lpc_drv_device_t *lpc_drv_device_data; + + RG_LPC_DRV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(lpc_drv_device); i++) { + lpc_drv_device_data = lpc_drv_device[i].dev.platform_data; + ret = platform_device_register(&lpc_drv_device[i]); + if (ret < 0) { + lpc_drv_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-lpc.%d register failed!\n", i + 1); + } else { + lpc_drv_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_lpc_drv_device_exit(void) +{ + int i; + lpc_drv_device_t *lpc_drv_device_data; + + RG_LPC_DRV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(lpc_drv_device) - 1; i >= 0; i--) { + lpc_drv_device_data = lpc_drv_device[i].dev.platform_data; + if (lpc_drv_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&lpc_drv_device[i]); + } + } +} + +module_init(rg_lpc_drv_device_init); +module_exit(rg_lpc_drv_device_exit); +MODULE_DESCRIPTION("RG LPC DRV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_pcie_dev_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_pcie_dev_device.c new file mode 100644 index 000000000000..bafa2715e38b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_pcie_dev_device.c @@ -0,0 +1,132 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_pcie_dev_device_debug = 0; +static int g_rg_pcie_dev_device_error = 0; + +module_param(g_rg_pcie_dev_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_pcie_dev_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_pcie_dev_device_debug) { \ + printk(KERN_INFO "[RG_PCIE_DEV_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_PCIE_DEV_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_pcie_dev_device_error) { \ + printk(KERN_ERR "[RG_PCIE_DEV_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static pci_dev_device_t pcie_dev_device_data0 = { + .pci_dev_name = "fpga0", + .pci_domain = 0x0000, + .pci_bus = 0x0a, + .pci_slot = 0x00, + .pci_fn = 0, + .pci_bar = 0, + .bus_width = 4, + .upg_ctrl_base = 0xa00, + .upg_flash_base = 0x2f0000, +}; + +static pci_dev_device_t pcie_dev_device_data1 = { + .pci_dev_name = "fpga1", + .pci_domain = 0x0000, + .pci_bus = 0x08, + .pci_slot = 0x00, + .pci_fn = 0, + .pci_bar = 0, + .bus_width = 4, + .upg_ctrl_base = 0xa00, + .upg_flash_base = 0x2f0000, +}; + +static pci_dev_device_t pcie_dev_device_data2 = { + .pci_dev_name = "fpga2", + .pci_domain = 0x0000, + .pci_bus = 0x0b, + .pci_slot = 0x00, + .pci_fn = 0, + .pci_bar = 0, + .bus_width = 4, + .upg_ctrl_base = 0xa00, + .upg_flash_base = 0x2f0000, +}; +static void rg_pcie_dev_device_release(struct device *dev) +{ + return; +} + +static struct platform_device pcie_dev_device[] = { + { + .name = "rg-pci-dev", + .id = 1, + .dev = { + .platform_data = &pcie_dev_device_data0, + .release = rg_pcie_dev_device_release, + }, + }, + { + .name = "rg-pci-dev", + .id = 2, + .dev = { + .platform_data = &pcie_dev_device_data1, + .release = rg_pcie_dev_device_release, + }, + }, + { + .name = "rg-pci-dev", + .id = 3, + .dev = { + .platform_data = &pcie_dev_device_data2, + .release = rg_pcie_dev_device_release, + }, + }, +}; + +static int __init rg_pcie_dev_device_init(void) +{ + int i; + int ret = 0; + pci_dev_device_t *pcie_dev_device_data; + + RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(pcie_dev_device); i++) { + pcie_dev_device_data = pcie_dev_device[i].dev.platform_data; + ret = platform_device_register(&pcie_dev_device[i]); + if (ret < 0) { + pcie_dev_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-pci-dev.%d register failed!\n", i + 1); + } else { + pcie_dev_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_pcie_dev_device_exit(void) +{ + int i; + pci_dev_device_t *pcie_dev_device_data; + + RG_PCIE_DEV_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(pcie_dev_device) - 1; i >= 0; i--) { + pcie_dev_device_data = pcie_dev_device[i].dev.platform_data; + if (pcie_dev_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&pcie_dev_device[i]); + } + } +} + +module_init(rg_pcie_dev_device_init); +module_exit(rg_pcie_dev_device_exit); +MODULE_DESCRIPTION("RG PCIE DEV Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_wdt_device.c b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_wdt_device.c new file mode 100644 index 000000000000..4b3b1217afb0 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/modules/driver/rg_wdt_device.c @@ -0,0 +1,104 @@ +#include +#include +#include +#include +#include + +#include + +static int g_rg_wdt_device_debug = 0; +static int g_rg_wdt_device_error = 0; + +module_param(g_rg_wdt_device_debug, int, S_IRUGO | S_IWUSR); +module_param(g_rg_wdt_device_error, int, S_IRUGO | S_IWUSR); + +#define RG_WDT_DEVICE_DEBUG_VERBOSE(fmt, args...) do { \ + if (g_rg_wdt_device_debug) { \ + printk(KERN_INFO "[RG_WDT_DEVICE][VER][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +#define RG_WDT_DEVICE_DEBUG_ERROR(fmt, args...) do { \ + if (g_rg_wdt_device_error) { \ + printk(KERN_ERR "[RG_WDT_DEVICE][ERR][func:%s line:%d]\r\n"fmt, __func__, __LINE__, ## args); \ + } \ +} while (0) + +static rg_wdt_device_t rg_wdt_device_data_0 = { + .feed_wdt_type = 2, + .hw_margin = 180000, + .feed_time = 30000, + .config_dev_name = "/dev/cpld5", + .config_mode = 2, + .priv_func_mode = 4, + .enable_reg = 0x42, + .enable_val = 0x1, + .disable_val = 0x0, + .enable_mask = 0x1, + .timeout_cfg_reg = 0x43, + .hw_algo = "toggle", + .wdt_config_mode.logic_wdt = { + .feed_dev_name = "/dev/cpld5", + .feed_reg = 0x42, + .active_val = 0x1, + .logic_func_mode = 0x1, + }, + .timer_accuracy = 6000, /* 6s */ + .sysfs_index = SYSFS_NO_CFG, +}; + +static void rg_wdt_device_release(struct device *dev) +{ + return; +} + +static struct platform_device rg_wdt_device[] = { + { + .name = "rg_wdt", + .id = 0, + .dev = { + .platform_data = &rg_wdt_device_data_0, + .release = rg_wdt_device_release, + }, + }, +}; + +static int __init rg_wdt_device_init(void) +{ + int i; + int ret = 0; + rg_wdt_device_t *rg_wdt_device_data; + + RG_WDT_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = 0; i < ARRAY_SIZE(rg_wdt_device); i++) { + rg_wdt_device_data = rg_wdt_device[i].dev.platform_data; + ret = platform_device_register(&rg_wdt_device[i]); + if (ret < 0) { + rg_wdt_device_data->device_flag = -1; /* device register failed, set flag -1 */ + printk(KERN_ERR "rg-wdt.%d register failed!\n", i + 1); + } else { + rg_wdt_device_data->device_flag = 0; /* device register suucess, set flag 0 */ + } + } + return 0; +} + +static void __exit rg_wdt_device_exit(void) +{ + int i; + rg_wdt_device_t *rg_wdt_device_data; + + RG_WDT_DEVICE_DEBUG_VERBOSE("enter!\n"); + for (i = ARRAY_SIZE(rg_wdt_device) - 1; i >= 0; i--) { + rg_wdt_device_data = rg_wdt_device[i].dev.platform_data; + if (rg_wdt_device_data->device_flag == 0) { /* device register success, need unregister */ + platform_device_unregister(&rg_wdt_device[i]); + } + } +} + +module_init(rg_wdt_device_init); +module_exit(rg_wdt_device_exit); +MODULE_DESCRIPTION("RG WDT Devices"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("sonic_rd@ruijie.com.cn"); diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-CPLD.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-CPLD.cfg new file mode 100755 index 000000000000..e1dbac4b94f9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-CPLD.cfg @@ -0,0 +1,29 @@ +# cpld_id: 0:CPLD_A 1:CPLD_B +cpld_i2c_dev.bus_0_2=60 +cpld_i2c_dev.addr_0_2=0x3d +cpld_i2c_dev.bus_0_3=87 +cpld_i2c_dev.addr_0_3=0x0d +cpld_i2c_dev.bus_0_4=95 +cpld_i2c_dev.addr_0_4=0x0d +cpld_i2c_dev.bus_0_5=77 +cpld_i2c_dev.addr_0_5=0x1d +cpld_i2c_dev.bus_0_6=77 +cpld_i2c_dev.addr_0_6=0x2d +cpld_i2c_dev.bus_0_7=111 +cpld_i2c_dev.addr_0_7=0x3d + +# cpld_id: 0:X86_CPLD, 1:MAC_CPLDA, 2:MAC_CPLDB +cpld_lpc_dev_0_0=0x700 +cpld_lpc_dev_0_1=0x900 + +mode_cpld_0_0=lpc +mode_cpld_0_1=lpc +mode_cpld_0_2=i2c +mode_cpld_0_3=i2c +mode_cpld_0_4=i2c +mode_cpld_0_5=i2c +mode_cpld_0_6=i2c +mode_cpld_0_7=i2c + +# cpld number +dev_num_4_0=8 diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-FAN.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-FAN.cfg new file mode 100755 index 000000000000..d8134e221bc2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-FAN.cfg @@ -0,0 +1,422 @@ +# fan number +dev_num_1_0=8 + +# motor number +dev_num_1_5=2 + +dev_present_status.mode_1_1=config +dev_present_status.src_1_1=cpld +dev_present_status.frmt_1_1=bit +dev_present_status.pola_1_1=negative +dev_present_status.addr_1_1=0x00030030 +dev_present_status.len_1_1=1 +dev_present_status.bit_offset_1_1=0 + +dev_present_status.mode_1_2=config +dev_present_status.src_1_2=cpld +dev_present_status.frmt_1_2=bit +dev_present_status.pola_1_2=negative +dev_present_status.addr_1_2=0x00040030 +dev_present_status.len_1_2=1 +dev_present_status.bit_offset_1_2=0 + +dev_present_status.mode_1_3=config +dev_present_status.src_1_3=cpld +dev_present_status.frmt_1_3=bit +dev_present_status.pola_1_3=negative +dev_present_status.addr_1_3=0x00030030 +dev_present_status.len_1_3=1 +dev_present_status.bit_offset_1_3=1 + +dev_present_status.mode_1_4=config +dev_present_status.src_1_4=cpld +dev_present_status.frmt_1_4=bit +dev_present_status.pola_1_4=negative +dev_present_status.addr_1_4=0x00040030 +dev_present_status.len_1_4=1 +dev_present_status.bit_offset_1_4=1 + +dev_present_status.mode_1_5=config +dev_present_status.src_1_5=cpld +dev_present_status.frmt_1_5=bit +dev_present_status.pola_1_5=negative +dev_present_status.addr_1_5=0x00030030 +dev_present_status.len_1_5=1 +dev_present_status.bit_offset_1_5=2 + +dev_present_status.mode_1_6=config +dev_present_status.src_1_6=cpld +dev_present_status.frmt_1_6=bit +dev_present_status.pola_1_6=negative +dev_present_status.addr_1_6=0x00040030 +dev_present_status.len_1_6=1 +dev_present_status.bit_offset_1_6=2 + +dev_present_status.mode_1_7=config +dev_present_status.src_1_7=cpld +dev_present_status.frmt_1_7=bit +dev_present_status.pola_1_7=negative +dev_present_status.addr_1_7=0x00030030 +dev_present_status.len_1_7=1 +dev_present_status.bit_offset_1_7=3 + +dev_present_status.mode_1_8=config +dev_present_status.src_1_8=cpld +dev_present_status.frmt_1_8=bit +dev_present_status.pola_1_8=negative +dev_present_status.addr_1_8=0x00040030 +dev_present_status.len_1_8=1 +dev_present_status.bit_offset_1_8=3 + +fan_ratio.mode_1_0=config +fan_ratio.src_1_0=cpld +fan_ratio.frmt_1_0=byte +fan_ratio.addr_1_0=0x00030014 +fan_ratio.len_1_0=1 + +fan_ratio.mode_1_1=config +fan_ratio.src_1_1=cpld +fan_ratio.frmt_1_1=byte +fan_ratio.addr_1_1=0x00030014 +fan_ratio.len_1_1=1 + +fan_ratio.mode_2_0=config +fan_ratio.src_2_0=cpld +fan_ratio.frmt_2_0=byte +fan_ratio.addr_2_0=0x00040014 +fan_ratio.len_2_0=1 + +fan_ratio.mode_2_1=config +fan_ratio.src_2_1=cpld +fan_ratio.frmt_2_1=byte +fan_ratio.addr_2_1=0x00040014 +fan_ratio.len_2_1=1 + +fan_ratio.mode_3_0=config +fan_ratio.src_3_0=cpld +fan_ratio.frmt_3_0=byte +fan_ratio.addr_3_0=0x00030015 +fan_ratio.len_3_0=1 + +fan_ratio.mode_3_1=config +fan_ratio.src_3_1=cpld +fan_ratio.frmt_3_1=byte +fan_ratio.addr_3_1=0x00030015 +fan_ratio.len_3_1=1 + +fan_ratio.mode_4_0=config +fan_ratio.src_4_0=cpld +fan_ratio.frmt_4_0=byte +fan_ratio.addr_4_0=0x00040015 +fan_ratio.len_4_0=1 + +fan_ratio.mode_4_1=config +fan_ratio.src_4_1=cpld +fan_ratio.frmt_4_1=byte +fan_ratio.addr_4_1=0x00040015 +fan_ratio.len_4_1=1 + +fan_ratio.mode_5_0=config +fan_ratio.src_5_0=cpld +fan_ratio.frmt_5_0=byte +fan_ratio.addr_5_0=0x00030016 +fan_ratio.len_5_0=1 + +fan_ratio.mode_5_1=config +fan_ratio.src_5_1=cpld +fan_ratio.frmt_5_1=byte +fan_ratio.addr_5_1=0x00030016 +fan_ratio.len_5_1=1 + +fan_ratio.mode_6_0=config +fan_ratio.src_6_0=cpld +fan_ratio.frmt_6_0=byte +fan_ratio.addr_6_0=0x00040016 +fan_ratio.len_6_0=1 + +fan_ratio.mode_6_1=config +fan_ratio.src_6_1=cpld +fan_ratio.frmt_6_1=byte +fan_ratio.addr_6_1=0x00040016 +fan_ratio.len_6_1=1 + +fan_ratio.mode_7_0=config +fan_ratio.src_7_0=cpld +fan_ratio.frmt_7_0=byte +fan_ratio.addr_7_0=0x00030017 +fan_ratio.len_7_0=1 + +fan_ratio.mode_7_1=config +fan_ratio.src_7_1=cpld +fan_ratio.frmt_7_1=byte +fan_ratio.addr_7_1=0x00030017 +fan_ratio.len_7_1=1 + +fan_ratio.mode_8_0=config +fan_ratio.src_8_0=cpld +fan_ratio.frmt_8_0=byte +fan_ratio.addr_8_0=0x00040017 +fan_ratio.len_8_0=1 + +fan_ratio.mode_8_1=config +fan_ratio.src_8_1=cpld +fan_ratio.frmt_8_1=byte +fan_ratio.addr_8_1=0x00040017 +fan_ratio.len_8_1=1 + + +fan_roll_status.mode_1_0=config +fan_roll_status.src_1_0=cpld +fan_roll_status.frmt_1_0=bit +fan_roll_status.pola_1_0=positive +fan_roll_status.addr_1_0=0x00030031 +fan_roll_status.len_1_0=1 +fan_roll_status.bit_offset_1_0=0 + +fan_roll_status.mode_1_1=config +fan_roll_status.src_1_1=cpld +fan_roll_status.frmt_1_1=bit +fan_roll_status.pola_1_1=positive +fan_roll_status.addr_1_1=0x00030034 +fan_roll_status.len_1_1=1 +fan_roll_status.bit_offset_1_1=0 + +fan_roll_status.mode_2_0=config +fan_roll_status.src_2_0=cpld +fan_roll_status.frmt_2_0=bit +fan_roll_status.pola_2_0=positive +fan_roll_status.addr_2_0=0x00040031 +fan_roll_status.len_2_0=1 +fan_roll_status.bit_offset_2_0=0 + +fan_roll_status.mode_2_1=config +fan_roll_status.src_2_1=cpld +fan_roll_status.frmt_2_1=bit +fan_roll_status.pola_2_1=positive +fan_roll_status.addr_2_1=0x00040034 +fan_roll_status.len_2_1=1 +fan_roll_status.bit_offset_2_1=0 + +fan_roll_status.mode_3_0=config +fan_roll_status.src_3_0=cpld +fan_roll_status.frmt_3_0=bit +fan_roll_status.pola_3_0=positive +fan_roll_status.addr_3_0=0x00030031 +fan_roll_status.len_3_0=1 +fan_roll_status.bit_offset_3_0=1 + +fan_roll_status.mode_3_1=config +fan_roll_status.src_3_1=cpld +fan_roll_status.frmt_3_1=bit +fan_roll_status.pola_3_1=positive +fan_roll_status.addr_3_1=0x00030034 +fan_roll_status.len_3_1=1 +fan_roll_status.bit_offset_3_1=1 + +fan_roll_status.mode_4_0=config +fan_roll_status.src_4_0=cpld +fan_roll_status.frmt_4_0=bit +fan_roll_status.pola_4_0=positive +fan_roll_status.addr_4_0=0x00040031 +fan_roll_status.len_4_0=1 +fan_roll_status.bit_offset_4_0=1 + +fan_roll_status.mode_4_1=config +fan_roll_status.src_4_1=cpld +fan_roll_status.frmt_4_1=bit +fan_roll_status.pola_4_1=positive +fan_roll_status.addr_4_1=0x00040034 +fan_roll_status.len_4_1=1 +fan_roll_status.bit_offset_4_1=1 + +fan_roll_status.mode_5_0=config +fan_roll_status.src_5_0=cpld +fan_roll_status.frmt_5_0=bit +fan_roll_status.pola_5_0=positive +fan_roll_status.addr_5_0=0x00030031 +fan_roll_status.len_5_0=1 +fan_roll_status.bit_offset_5_0=2 + +fan_roll_status.mode_5_1=config +fan_roll_status.src_5_1=cpld +fan_roll_status.frmt_5_1=bit +fan_roll_status.pola_5_1=positive +fan_roll_status.addr_5_1=0x00030034 +fan_roll_status.len_5_1=1 +fan_roll_status.bit_offset_5_1=2 + +fan_roll_status.mode_6_0=config +fan_roll_status.src_6_0=cpld +fan_roll_status.frmt_6_0=bit +fan_roll_status.pola_6_0=positive +fan_roll_status.addr_6_0=0x00040031 +fan_roll_status.len_6_0=1 +fan_roll_status.bit_offset_6_0=2 + +fan_roll_status.mode_6_1=config +fan_roll_status.src_6_1=cpld +fan_roll_status.frmt_6_1=bit +fan_roll_status.pola_6_1=positive +fan_roll_status.addr_6_1=0x00040034 +fan_roll_status.len_6_1=1 +fan_roll_status.bit_offset_6_1=2 + +fan_roll_status.mode_7_0=config +fan_roll_status.src_7_0=cpld +fan_roll_status.frmt_7_0=bit +fan_roll_status.pola_7_0=positive +fan_roll_status.addr_7_0=0x00030031 +fan_roll_status.len_7_0=1 +fan_roll_status.bit_offset_7_0=3 + +fan_roll_status.mode_7_1=config +fan_roll_status.src_7_1=cpld +fan_roll_status.frmt_7_1=bit +fan_roll_status.pola_7_1=positive +fan_roll_status.addr_7_1=0x00030034 +fan_roll_status.len_7_1=1 +fan_roll_status.bit_offset_7_1=3 + +fan_roll_status.mode_8_0=config +fan_roll_status.src_8_0=cpld +fan_roll_status.frmt_8_0=bit +fan_roll_status.pola_8_0=positive +fan_roll_status.addr_8_0=0x00040031 +fan_roll_status.len_8_0=1 +fan_roll_status.bit_offset_8_0=3 + +fan_roll_status.mode_8_1=config +fan_roll_status.src_8_1=cpld +fan_roll_status.frmt_8_1=bit +fan_roll_status.pola_8_1=positive +fan_roll_status.addr_8_1=0x00040034 +fan_roll_status.len_8_1=1 +fan_roll_status.bit_offset_8_1=3 + +fan_speed.mode_1_0=config +fan_speed.src_1_0=cpld +fan_speed.frmt_1_0=num_bytes +fan_speed.pola_1_0=negative +fan_speed.addr_1_0=0x0003001B +fan_speed.len_1_0=2 +fan_speed.bit_offset_1_0=0 + +fan_speed.mode_1_1=config +fan_speed.src_1_1=cpld +fan_speed.frmt_1_1=num_bytes +fan_speed.pola_1_1=negative +fan_speed.addr_1_1=0x00030025 +fan_speed.len_1_1=2 +fan_speed.bit_offset_1_1=0 + +fan_speed.mode_2_0=config +fan_speed.src_2_0=cpld +fan_speed.frmt_2_0=num_bytes +fan_speed.pola_2_0=negative +fan_speed.addr_2_0=0x0004001B +fan_speed.len_2_0=2 +fan_speed.bit_offset_2_0=0 + +fan_speed.mode_2_1=config +fan_speed.src_2_1=cpld +fan_speed.frmt_2_1=num_bytes +fan_speed.pola_2_1=negative +fan_speed.addr_2_1=0x00040025 +fan_speed.len_2_1=2 +fan_speed.bit_offset_2_1=0 + +fan_speed.mode_3_0=config +fan_speed.src_3_0=cpld +fan_speed.frmt_3_0=num_bytes +fan_speed.pola_3_0=negative +fan_speed.addr_3_0=0x0003001D +fan_speed.len_3_0=2 +fan_speed.bit_offset_3_0=0 + +fan_speed.mode_3_1=config +fan_speed.src_3_1=cpld +fan_speed.frmt_3_1=num_bytes +fan_speed.pola_3_1=negative +fan_speed.addr_3_1=0x00030027 +fan_speed.len_3_1=2 +fan_speed.bit_offset_3_1=0 + +fan_speed.mode_4_0=config +fan_speed.src_4_0=cpld +fan_speed.frmt_4_0=num_bytes +fan_speed.pola_4_0=negative +fan_speed.addr_4_0=0x0004001D +fan_speed.len_4_0=2 +fan_speed.bit_offset_4_0=0 + +fan_speed.mode_4_1=config +fan_speed.src_4_1=cpld +fan_speed.frmt_4_1=num_bytes +fan_speed.pola_4_1=negative +fan_speed.addr_4_1=0x00040027 +fan_speed.len_4_1=2 +fan_speed.bit_offset_4_1=0 + +fan_speed.mode_5_0=config +fan_speed.src_5_0=cpld +fan_speed.frmt_5_0=num_bytes +fan_speed.pola_5_0=negative +fan_speed.addr_5_0=0x0003001F +fan_speed.len_5_0=2 +fan_speed.bit_offset_5_0=0 + +fan_speed.mode_5_1=config +fan_speed.src_5_1=cpld +fan_speed.frmt_5_1=num_bytes +fan_speed.pola_5_1=negative +fan_speed.addr_5_1=0x00030029 +fan_speed.len_5_1=2 +fan_speed.bit_offset_5_1=0 + +fan_speed.mode_6_0=config +fan_speed.src_6_0=cpld +fan_speed.frmt_6_0=num_bytes +fan_speed.pola_6_0=negative +fan_speed.addr_6_0=0x0004001F +fan_speed.len_6_0=2 +fan_speed.bit_offset_6_0=0 + +fan_speed.mode_6_1=config +fan_speed.src_6_1=cpld +fan_speed.frmt_6_1=num_bytes +fan_speed.pola_6_1=negative +fan_speed.addr_6_1=0x00040029 +fan_speed.len_6_1=2 +fan_speed.bit_offset_6_1=0 + +fan_speed.mode_7_0=config +fan_speed.src_7_0=cpld +fan_speed.frmt_7_0=num_bytes +fan_speed.pola_7_0=negative +fan_speed.addr_7_0=0x00030021 +fan_speed.len_7_0=2 +fan_speed.bit_offset_7_0=0 + +fan_speed.mode_7_1=config +fan_speed.src_7_1=cpld +fan_speed.frmt_7_1=num_bytes +fan_speed.pola_7_1=negative +fan_speed.addr_7_1=0x0003002b +fan_speed.len_7_1=2 +fan_speed.bit_offset_7_1=0 + +fan_speed.mode_8_0=config +fan_speed.src_8_0=cpld +fan_speed.frmt_8_0=num_bytes +fan_speed.pola_8_0=negative +fan_speed.addr_8_0=0x00040021 +fan_speed.len_8_0=2 +fan_speed.bit_offset_8_0=0 + +fan_speed.mode_8_1=config +fan_speed.src_8_1=cpld +fan_speed.frmt_8_1=num_bytes +fan_speed.pola_8_1=negative +fan_speed.addr_8_1=0x0004002b +fan_speed.len_8_1=2 +fan_speed.bit_offset_8_1=0 diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-PSU.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-PSU.cfg new file mode 100755 index 000000000000..aa53cf0cfa95 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-PSU.cfg @@ -0,0 +1,98 @@ +# psu number +dev_num_2_0=4 + +psu_status.mode_1_0=config +psu_status.src_1_0=cpld +psu_status.frmt_1_0=bit +psu_status.pola_1_0=negative +psu_status.addr_1_0=0x00010064 +psu_status.len_1_0=1 +psu_status.bit_offset_1_0=0 + +psu_status.mode_1_1=config +psu_status.src_1_1=cpld +psu_status.frmt_1_1=bit +psu_status.pola_1_1=positive +psu_status.addr_1_1=0x00010064 +psu_status.len_1_1=1 +psu_status.bit_offset_1_1=1 + +psu_status.mode_1_2=config +psu_status.src_1_2=cpld +psu_status.frmt_1_2=bit +psu_status.pola_1_2=negative +psu_status.addr_1_2=0x00010064 +psu_status.len_1_2=1 +psu_status.bit_offset_1_2=2 + +psu_status.mode_2_0=config +psu_status.src_2_0=cpld +psu_status.frmt_2_0=bit +psu_status.pola_2_0=negative +psu_status.addr_2_0=0x00010064 +psu_status.len_2_0=1 +psu_status.bit_offset_2_0=4 + +psu_status.mode_2_1=config +psu_status.src_2_1=cpld +psu_status.frmt_2_1=bit +psu_status.pola_2_1=positive +psu_status.addr_2_1=0x00010064 +psu_status.len_2_1=1 +psu_status.bit_offset_2_1=5 + +psu_status.mode_2_2=config +psu_status.src_2_2=cpld +psu_status.frmt_2_2=bit +psu_status.pola_2_2=negative +psu_status.addr_2_2=0x00010064 +psu_status.len_2_2=1 +psu_status.bit_offset_2_2=6 + +psu_status.mode_3_0=config +psu_status.src_3_0=cpld +psu_status.frmt_3_0=bit +psu_status.pola_3_0=negative +psu_status.addr_3_0=0x00010065 +psu_status.len_3_0=1 +psu_status.bit_offset_3_0=4 + +psu_status.mode_3_1=config +psu_status.src_3_1=cpld +psu_status.frmt_3_1=bit +psu_status.pola_3_1=positive +psu_status.addr_3_1=0x00010065 +psu_status.len_3_1=1 +psu_status.bit_offset_3_1=5 + +psu_status.mode_3_2=config +psu_status.src_3_2=cpld +psu_status.frmt_3_2=bit +psu_status.pola_3_2=negative +psu_status.addr_3_2=0x00010065 +psu_status.len_3_2=1 +psu_status.bit_offset_3_2=6 + +psu_status.mode_4_0=config +psu_status.src_4_0=cpld +psu_status.frmt_4_0=bit +psu_status.pola_4_0=negative +psu_status.addr_4_0=0x00010065 +psu_status.len_4_0=1 +psu_status.bit_offset_4_0=0 + +psu_status.mode_4_1=config +psu_status.src_4_1=cpld +psu_status.frmt_4_1=bit +psu_status.pola_4_1=positive +psu_status.addr_4_1=0x00010065 +psu_status.len_4_1=1 +psu_status.bit_offset_4_1=1 + +psu_status.mode_4_2=config +psu_status.src_4_2=cpld +psu_status.frmt_4_2=bit +psu_status.pola_4_2=negative +psu_status.addr_4_2=0x00010065 +psu_status.len_4_2=1 +psu_status.bit_offset_4_2=2 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SENSOR.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SENSOR.cfg new file mode 100755 index 000000000000..0b7f4dead885 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SENSOR.cfg @@ -0,0 +1,188 @@ +# main board temp sensors +dev_num_0_1=0 + +# main board voltage sensors +dev_num_0_2=8 + +# in0 MAC_QSFPDD_VDD3.3V_A +hwmon_in.mode_0x0000_0x00=config +hwmon_in.int_cons_0x0000_0x00=3 +hwmon_in.src_0x0000_0x00=cpld +hwmon_in.frmt_0x0000_0x00=num_bytes +hwmon_in.addr_0x0000_0x00=0x00050030 +hwmon_in.len_0x0000_0x00=2 +hwmon_in.int_extra1_0x0000_0x00=0x00050030 +hwmon_in.int_extra2_0x0000_0x00=2000 + +hwmon_in.mode_0x0000_0x01=str_constant +hwmon_in.str_cons_0x0000_0x01=MAC_QSFPDD_VDD3.3V_A + +hwmon_in.mode_0x0000_0x02=str_constant +hwmon_in.str_cons_0x0000_0x02=cpld + +hwmon_in.mode_0x0000_0x03=str_constant +hwmon_in.str_cons_0x0000_0x03=3.600 + +hwmon_in.mode_0x0000_0x05=str_constant +hwmon_in.str_cons_0x0000_0x05=3.200 + + +# in1 MAC_QSFPDD_VDD3.3V_B +hwmon_in.mode_0x0001_0x00=config +hwmon_in.int_cons_0x0001_0x00=3 +hwmon_in.src_0x0001_0x00=cpld +hwmon_in.frmt_0x0001_0x00=num_bytes +hwmon_in.addr_0x0001_0x00=0x00050032 +hwmon_in.len_0x0001_0x00=2 +hwmon_in.int_extra1_0x0001_0x00=0x00050032 +hwmon_in.int_extra2_0x0001_0x00=2000 + +hwmon_in.mode_0x0001_0x01=str_constant +hwmon_in.str_cons_0x0001_0x01=MAC_QSFPDD_VDD3.3V_B + +hwmon_in.mode_0x0001_0x02=str_constant +hwmon_in.str_cons_0x0001_0x02=cpld + +hwmon_in.mode_0x0001_0x03=str_constant +hwmon_in.str_cons_0x0001_0x03=3.600 + +hwmon_in.mode_0x0001_0x05=str_constant +hwmon_in.str_cons_0x0001_0x05=3.200 + + +# in2 MAC_QSFPDD_VDD3.3V_C +hwmon_in.mode_0x0002_0x00=config +hwmon_in.int_cons_0x0002_0x00=3 +hwmon_in.src_0x0002_0x00=cpld +hwmon_in.frmt_0x0002_0x00=num_bytes +hwmon_in.addr_0x0002_0x00=0x00050034 +hwmon_in.len_0x0002_0x00=2 +hwmon_in.int_extra1_0x0002_0x00=0x00050034 +hwmon_in.int_extra2_0x0002_0x00=2000 + +hwmon_in.mode_0x0002_0x01=str_constant +hwmon_in.str_cons_0x0002_0x01=MAC_QSFPDD_VDD3.3V_C + +hwmon_in.mode_0x0002_0x02=str_constant +hwmon_in.str_cons_0x0002_0x02=cpld + +hwmon_in.mode_0x0002_0x03=str_constant +hwmon_in.str_cons_0x0002_0x03=3.600 + +hwmon_in.mode_0x0002_0x05=str_constant +hwmon_in.str_cons_0x0002_0x05=3.200 + + +# in3 MAC_QSFPDD_VDD3.3V_D +hwmon_in.mode_0x0003_0x00=config +hwmon_in.int_cons_0x0003_0x00=3 +hwmon_in.src_0x0003_0x00=cpld +hwmon_in.frmt_0x0003_0x00=num_bytes +hwmon_in.addr_0x0003_0x00=0x00050036 +hwmon_in.len_0x0003_0x00=2 +hwmon_in.int_extra1_0x0003_0x00=0x00050036 +hwmon_in.int_extra2_0x0003_0x00=2000 + +hwmon_in.mode_0x0003_0x01=str_constant +hwmon_in.str_cons_0x0003_0x01=MAC_QSFPDD_VDD3.3V_D + +hwmon_in.mode_0x0003_0x02=str_constant +hwmon_in.str_cons_0x0003_0x02=cpld + +hwmon_in.mode_0x0003_0x03=str_constant +hwmon_in.str_cons_0x0003_0x03=3.600 + +hwmon_in.mode_0x0003_0x05=str_constant +hwmon_in.str_cons_0x0003_0x05=3.200 + + +# in4 MAC_QSFPDD_VDD3.3V_E +hwmon_in.mode_0x0004_0x00=config +hwmon_in.int_cons_0x0004_0x00=3 +hwmon_in.src_0x0004_0x00=cpld +hwmon_in.frmt_0x0004_0x00=num_bytes +hwmon_in.addr_0x0004_0x00=0x00050038 +hwmon_in.len_0x0004_0x00=2 +hwmon_in.int_extra1_0x0004_0x00=0x00050038 +hwmon_in.int_extra2_0x0004_0x00=2000 + +hwmon_in.mode_0x0004_0x01=str_constant +hwmon_in.str_cons_0x0004_0x01=MAC_QSFPDD_VDD3.3V_E + +hwmon_in.mode_0x0004_0x02=str_constant +hwmon_in.str_cons_0x0004_0x02=cpld + +hwmon_in.mode_0x0004_0x03=str_constant +hwmon_in.str_cons_0x0004_0x03=3.600 + +hwmon_in.mode_0x0004_0x05=str_constant +hwmon_in.str_cons_0x0004_0x05=3.200 + + +# in5 MAC_QSFPDD_VDD3.3V_F +hwmon_in.mode_0x0005_0x00=config +hwmon_in.int_cons_0x0005_0x00=3 +hwmon_in.src_0x0005_0x00=cpld +hwmon_in.frmt_0x0005_0x00=num_bytes +hwmon_in.addr_0x0005_0x00=0x0005003a +hwmon_in.len_0x0005_0x00=2 +hwmon_in.int_extra1_0x0005_0x00=0x0005003a +hwmon_in.int_extra2_0x0005_0x00=2000 + +hwmon_in.mode_0x0005_0x01=str_constant +hwmon_in.str_cons_0x0005_0x01=MAC_QSFPDD_VDD3.3V_F + +hwmon_in.mode_0x0005_0x02=str_constant +hwmon_in.str_cons_0x0005_0x02=cpld + +hwmon_in.mode_0x0005_0x03=str_constant +hwmon_in.str_cons_0x0005_0x03=3.600 + +hwmon_in.mode_0x0005_0x05=str_constant +hwmon_in.str_cons_0x0005_0x05=3.200 + + +# in6 MAC_QSFPDD_VDD3.3V_G +hwmon_in.mode_0x0006_0x00=config +hwmon_in.int_cons_0x0006_0x00=3 +hwmon_in.src_0x0006_0x00=cpld +hwmon_in.frmt_0x0006_0x00=num_bytes +hwmon_in.addr_0x0006_0x00=0x0005003c +hwmon_in.len_0x0006_0x00=2 +hwmon_in.int_extra1_0x0006_0x00=0x0005003c +hwmon_in.int_extra2_0x0006_0x00=2000 + +hwmon_in.mode_0x0006_0x01=str_constant +hwmon_in.str_cons_0x0006_0x01=MAC_QSFPDD_VDD3.3V_G + +hwmon_in.mode_0x0006_0x02=str_constant +hwmon_in.str_cons_0x0006_0x02=cpld + +hwmon_in.mode_0x0006_0x03=str_constant +hwmon_in.str_cons_0x0006_0x03=3.600 + +hwmon_in.mode_0x0006_0x05=str_constant +hwmon_in.str_cons_0x0006_0x05=3.200 + + +# in7 MAC_QSFPDD_VDD3.3V_H +hwmon_in.mode_0x0007_0x00=config +hwmon_in.int_cons_0x0007_0x00=3 +hwmon_in.src_0x0007_0x00=cpld +hwmon_in.frmt_0x0007_0x00=num_bytes +hwmon_in.addr_0x0007_0x00=0x0005003e +hwmon_in.len_0x0007_0x00=2 +hwmon_in.int_extra1_0x0007_0x00=0x0005003e +hwmon_in.int_extra2_0x0007_0x00=2000 + +hwmon_in.mode_0x0007_0x01=str_constant +hwmon_in.str_cons_0x0007_0x01=MAC_QSFPDD_VDD3.3V_H + +hwmon_in.mode_0x0007_0x02=str_constant +hwmon_in.str_cons_0x0007_0x02=cpld + +hwmon_in.mode_0x0007_0x03=str_constant +hwmon_in.str_cons_0x0007_0x03=3.600 + +hwmon_in.mode_0x0007_0x05=str_constant +hwmon_in.str_cons_0x0007_0x05=3.200 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SFF.cfg b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SFF.cfg new file mode 100755 index 000000000000..8bd43e161b06 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/TCS9400-SFF.cfg @@ -0,0 +1,1157 @@ +# sff number +dev_num_3_0=128 + +sff_dir_name_1 =sff1 +sff_dir_name_2 =sff2 +sff_dir_name_3 =sff3 +sff_dir_name_4 =sff4 +sff_dir_name_5 =sff5 +sff_dir_name_6 =sff6 +sff_dir_name_7 =sff7 +sff_dir_name_8 =sff8 +sff_dir_name_9 =sff9 +sff_dir_name_10 =sff10 +sff_dir_name_11 =sff11 +sff_dir_name_12 =sff12 +sff_dir_name_13 =sff13 +sff_dir_name_14 =sff14 +sff_dir_name_15 =sff15 +sff_dir_name_16 =sff16 +sff_dir_name_17 =sff17 +sff_dir_name_18 =sff18 +sff_dir_name_19 =sff19 +sff_dir_name_20 =sff20 +sff_dir_name_21 =sff21 +sff_dir_name_22 =sff22 +sff_dir_name_23 =sff23 +sff_dir_name_24 =sff24 +sff_dir_name_25 =sff25 +sff_dir_name_26 =sff26 +sff_dir_name_27 =sff27 +sff_dir_name_28 =sff28 +sff_dir_name_29 =sff29 +sff_dir_name_30 =sff30 +sff_dir_name_31 =sff31 +sff_dir_name_32 =sff32 +sff_dir_name_33 =sff33 +sff_dir_name_34 =sff34 +sff_dir_name_35 =sff35 +sff_dir_name_36 =sff36 +sff_dir_name_37 =sff37 +sff_dir_name_38 =sff38 +sff_dir_name_39 =sff39 +sff_dir_name_40 =sff40 +sff_dir_name_41 =sff41 +sff_dir_name_42 =sff42 +sff_dir_name_43 =sff43 +sff_dir_name_44 =sff44 +sff_dir_name_45 =sff45 +sff_dir_name_46 =sff46 +sff_dir_name_47 =sff47 +sff_dir_name_48 =sff48 +sff_dir_name_49 =sff49 +sff_dir_name_50 =sff50 +sff_dir_name_51 =sff51 +sff_dir_name_52 =sff52 +sff_dir_name_53 =sff53 +sff_dir_name_54 =sff54 +sff_dir_name_55 =sff55 +sff_dir_name_56 =sff56 +sff_dir_name_57 =sff57 +sff_dir_name_58 =sff58 +sff_dir_name_59 =sff59 +sff_dir_name_60 =sff60 +sff_dir_name_61 =sff61 +sff_dir_name_62 =sff62 +sff_dir_name_63 =sff63 +sff_dir_name_64 =sff64 +sff_dir_name_65 =sff65 +sff_dir_name_66 =sff66 +sff_dir_name_67 =sff67 +sff_dir_name_68 =sff68 +sff_dir_name_69 =sff69 +sff_dir_name_70 =sff70 +sff_dir_name_71 =sff71 +sff_dir_name_72 =sff72 +sff_dir_name_73 =sff73 +sff_dir_name_74 =sff74 +sff_dir_name_75 =sff75 +sff_dir_name_76 =sff76 +sff_dir_name_77 =sff77 +sff_dir_name_78 =sff78 +sff_dir_name_79 =sff79 +sff_dir_name_80 =sff80 +sff_dir_name_81 =sff81 +sff_dir_name_82 =sff82 +sff_dir_name_83 =sff83 +sff_dir_name_84 =sff84 +sff_dir_name_85 =sff85 +sff_dir_name_86 =sff86 +sff_dir_name_87 =sff87 +sff_dir_name_88 =sff88 +sff_dir_name_89 =sff89 +sff_dir_name_90 =sff90 +sff_dir_name_91 =sff91 +sff_dir_name_92 =sff92 +sff_dir_name_93 =sff93 +sff_dir_name_94 =sff94 +sff_dir_name_95 =sff95 +sff_dir_name_96 =sff96 +sff_dir_name_97 =sff97 +sff_dir_name_98 =sff98 +sff_dir_name_99 =sff99 +sff_dir_name_100 =sff100 +sff_dir_name_101 =sff101 +sff_dir_name_102 =sff102 +sff_dir_name_103 =sff103 +sff_dir_name_104 =sff104 +sff_dir_name_105 =sff105 +sff_dir_name_106 =sff106 +sff_dir_name_107 =sff107 +sff_dir_name_108 =sff108 +sff_dir_name_109 =sff109 +sff_dir_name_110 =sff110 +sff_dir_name_111 =sff111 +sff_dir_name_112 =sff112 +sff_dir_name_113 =sff113 +sff_dir_name_114 =sff114 +sff_dir_name_115 =sff115 +sff_dir_name_116 =sff116 +sff_dir_name_117 =sff117 +sff_dir_name_118 =sff118 +sff_dir_name_119 =sff119 +sff_dir_name_120 =sff120 +sff_dir_name_121 =sff121 +sff_dir_name_122 =sff122 +sff_dir_name_123 =sff123 +sff_dir_name_124 =sff124 +sff_dir_name_125 =sff125 +sff_dir_name_126 =sff126 +sff_dir_name_127 =sff127 +sff_dir_name_128 =sff128 + + +# sff present +sff_cpld_reg.mode_1_8=config +sff_cpld_reg.src_1_8=cpld +sff_cpld_reg.frmt_1_8=bit +sff_cpld_reg.pola_1_8=negative +sff_cpld_reg.addr_1_8=0x00020077 +sff_cpld_reg.len_1_8=1 +sff_cpld_reg.bit_offset_1_8=0 + +sff_cpld_reg.mode_2_8=config +sff_cpld_reg.src_2_8=cpld +sff_cpld_reg.frmt_2_8=bit +sff_cpld_reg.pola_2_8=negative +sff_cpld_reg.addr_2_8=0x00020077 +sff_cpld_reg.len_2_8=1 +sff_cpld_reg.bit_offset_2_8=1 + +sff_cpld_reg.mode_3_8=config +sff_cpld_reg.src_3_8=cpld +sff_cpld_reg.frmt_3_8=bit +sff_cpld_reg.pola_3_8=negative +sff_cpld_reg.addr_3_8=0x00020077 +sff_cpld_reg.len_3_8=1 +sff_cpld_reg.bit_offset_3_8=2 + +sff_cpld_reg.mode_4_8=config +sff_cpld_reg.src_4_8=cpld +sff_cpld_reg.frmt_4_8=bit +sff_cpld_reg.pola_4_8=negative +sff_cpld_reg.addr_4_8=0x00020077 +sff_cpld_reg.len_4_8=1 +sff_cpld_reg.bit_offset_4_8=3 + +sff_cpld_reg.mode_5_8=config +sff_cpld_reg.src_5_8=cpld +sff_cpld_reg.frmt_5_8=bit +sff_cpld_reg.pola_5_8=negative +sff_cpld_reg.addr_5_8=0x00020077 +sff_cpld_reg.len_5_8=1 +sff_cpld_reg.bit_offset_5_8=4 + +sff_cpld_reg.mode_6_8=config +sff_cpld_reg.src_6_8=cpld +sff_cpld_reg.frmt_6_8=bit +sff_cpld_reg.pola_6_8=negative +sff_cpld_reg.addr_6_8=0x00020077 +sff_cpld_reg.len_6_8=1 +sff_cpld_reg.bit_offset_6_8=5 + +sff_cpld_reg.mode_7_8=config +sff_cpld_reg.src_7_8=cpld +sff_cpld_reg.frmt_7_8=bit +sff_cpld_reg.pola_7_8=negative +sff_cpld_reg.addr_7_8=0x00020077 +sff_cpld_reg.len_7_8=1 +sff_cpld_reg.bit_offset_7_8=6 + +sff_cpld_reg.mode_8_8=config +sff_cpld_reg.src_8_8=cpld +sff_cpld_reg.frmt_8_8=bit +sff_cpld_reg.pola_8_8=negative +sff_cpld_reg.addr_8_8=0x00020077 +sff_cpld_reg.len_8_8=1 +sff_cpld_reg.bit_offset_8_8=7 + +sff_cpld_reg.mode_9_8=config +sff_cpld_reg.src_9_8=cpld +sff_cpld_reg.frmt_9_8=bit +sff_cpld_reg.pola_9_8=negative +sff_cpld_reg.addr_9_8=0x00020076 +sff_cpld_reg.len_9_8=1 +sff_cpld_reg.bit_offset_9_8=0 + +sff_cpld_reg.mode_10_8=config +sff_cpld_reg.src_10_8=cpld +sff_cpld_reg.frmt_10_8=bit +sff_cpld_reg.pola_10_8=negative +sff_cpld_reg.addr_10_8=0x00020076 +sff_cpld_reg.len_10_8=1 +sff_cpld_reg.bit_offset_10_8=1 + +sff_cpld_reg.mode_11_8=config +sff_cpld_reg.src_11_8=cpld +sff_cpld_reg.frmt_11_8=bit +sff_cpld_reg.pola_11_8=negative +sff_cpld_reg.addr_11_8=0x00020076 +sff_cpld_reg.len_11_8=1 +sff_cpld_reg.bit_offset_11_8=2 + +sff_cpld_reg.mode_12_8=config +sff_cpld_reg.src_12_8=cpld +sff_cpld_reg.frmt_12_8=bit +sff_cpld_reg.pola_12_8=negative +sff_cpld_reg.addr_12_8=0x00020076 +sff_cpld_reg.len_12_8=1 +sff_cpld_reg.bit_offset_12_8=3 + +sff_cpld_reg.mode_13_8=config +sff_cpld_reg.src_13_8=cpld +sff_cpld_reg.frmt_13_8=bit +sff_cpld_reg.pola_13_8=negative +sff_cpld_reg.addr_13_8=0x00020076 +sff_cpld_reg.len_13_8=1 +sff_cpld_reg.bit_offset_13_8=4 + +sff_cpld_reg.mode_14_8=config +sff_cpld_reg.src_14_8=cpld +sff_cpld_reg.frmt_14_8=bit +sff_cpld_reg.pola_14_8=negative +sff_cpld_reg.addr_14_8=0x00020076 +sff_cpld_reg.len_14_8=1 +sff_cpld_reg.bit_offset_14_8=5 + +sff_cpld_reg.mode_15_8=config +sff_cpld_reg.src_15_8=cpld +sff_cpld_reg.frmt_15_8=bit +sff_cpld_reg.pola_15_8=negative +sff_cpld_reg.addr_15_8=0x00020076 +sff_cpld_reg.len_15_8=1 +sff_cpld_reg.bit_offset_15_8=6 + +sff_cpld_reg.mode_16_8=config +sff_cpld_reg.src_16_8=cpld +sff_cpld_reg.frmt_16_8=bit +sff_cpld_reg.pola_16_8=negative +sff_cpld_reg.addr_16_8=0x00020076 +sff_cpld_reg.len_16_8=1 +sff_cpld_reg.bit_offset_16_8=7 + +sff_cpld_reg.mode_17_8=config +sff_cpld_reg.src_17_8=cpld +sff_cpld_reg.frmt_17_8=bit +sff_cpld_reg.pola_17_8=negative +sff_cpld_reg.addr_17_8=0x00020075 +sff_cpld_reg.len_17_8=1 +sff_cpld_reg.bit_offset_17_8=0 + +sff_cpld_reg.mode_18_8=config +sff_cpld_reg.src_18_8=cpld +sff_cpld_reg.frmt_18_8=bit +sff_cpld_reg.pola_18_8=negative +sff_cpld_reg.addr_18_8=0x00020075 +sff_cpld_reg.len_18_8=1 +sff_cpld_reg.bit_offset_18_8=1 + +sff_cpld_reg.mode_19_8=config +sff_cpld_reg.src_19_8=cpld +sff_cpld_reg.frmt_19_8=bit +sff_cpld_reg.pola_19_8=negative +sff_cpld_reg.addr_19_8=0x00020075 +sff_cpld_reg.len_19_8=1 +sff_cpld_reg.bit_offset_19_8=2 + +sff_cpld_reg.mode_20_8=config +sff_cpld_reg.src_20_8=cpld +sff_cpld_reg.frmt_20_8=bit +sff_cpld_reg.pola_20_8=negative +sff_cpld_reg.addr_20_8=0x00020075 +sff_cpld_reg.len_20_8=1 +sff_cpld_reg.bit_offset_20_8=3 + +sff_cpld_reg.mode_21_8=config +sff_cpld_reg.src_21_8=cpld +sff_cpld_reg.frmt_21_8=bit +sff_cpld_reg.pola_21_8=negative +sff_cpld_reg.addr_21_8=0x00020075 +sff_cpld_reg.len_21_8=1 +sff_cpld_reg.bit_offset_21_8=4 + +sff_cpld_reg.mode_22_8=config +sff_cpld_reg.src_22_8=cpld +sff_cpld_reg.frmt_22_8=bit +sff_cpld_reg.pola_22_8=negative +sff_cpld_reg.addr_22_8=0x00020075 +sff_cpld_reg.len_22_8=1 +sff_cpld_reg.bit_offset_22_8=5 + +sff_cpld_reg.mode_23_8=config +sff_cpld_reg.src_23_8=cpld +sff_cpld_reg.frmt_23_8=bit +sff_cpld_reg.pola_23_8=negative +sff_cpld_reg.addr_23_8=0x00020075 +sff_cpld_reg.len_23_8=1 +sff_cpld_reg.bit_offset_23_8=6 + +sff_cpld_reg.mode_24_8=config +sff_cpld_reg.src_24_8=cpld +sff_cpld_reg.frmt_24_8=bit +sff_cpld_reg.pola_24_8=negative +sff_cpld_reg.addr_24_8=0x00020075 +sff_cpld_reg.len_24_8=1 +sff_cpld_reg.bit_offset_24_8=7 + +sff_cpld_reg.mode_25_8=config +sff_cpld_reg.src_25_8=cpld +sff_cpld_reg.frmt_25_8=bit +sff_cpld_reg.pola_25_8=negative +sff_cpld_reg.addr_25_8=0x00020074 +sff_cpld_reg.len_25_8=1 +sff_cpld_reg.bit_offset_25_8=0 + +sff_cpld_reg.mode_26_8=config +sff_cpld_reg.src_26_8=cpld +sff_cpld_reg.frmt_26_8=bit +sff_cpld_reg.pola_26_8=negative +sff_cpld_reg.addr_26_8=0x00020074 +sff_cpld_reg.len_26_8=1 +sff_cpld_reg.bit_offset_26_8=1 + +sff_cpld_reg.mode_27_8=config +sff_cpld_reg.src_27_8=cpld +sff_cpld_reg.frmt_27_8=bit +sff_cpld_reg.pola_27_8=negative +sff_cpld_reg.addr_27_8=0x00020074 +sff_cpld_reg.len_27_8=1 +sff_cpld_reg.bit_offset_27_8=2 + +sff_cpld_reg.mode_28_8=config +sff_cpld_reg.src_28_8=cpld +sff_cpld_reg.frmt_28_8=bit +sff_cpld_reg.pola_28_8=negative +sff_cpld_reg.addr_28_8=0x00020074 +sff_cpld_reg.len_28_8=1 +sff_cpld_reg.bit_offset_28_8=3 + +sff_cpld_reg.mode_29_8=config +sff_cpld_reg.src_29_8=cpld +sff_cpld_reg.frmt_29_8=bit +sff_cpld_reg.pola_29_8=negative +sff_cpld_reg.addr_29_8=0x00020074 +sff_cpld_reg.len_29_8=1 +sff_cpld_reg.bit_offset_29_8=4 + +sff_cpld_reg.mode_30_8=config +sff_cpld_reg.src_30_8=cpld +sff_cpld_reg.frmt_30_8=bit +sff_cpld_reg.pola_30_8=negative +sff_cpld_reg.addr_30_8=0x00020074 +sff_cpld_reg.len_30_8=1 +sff_cpld_reg.bit_offset_30_8=5 + +sff_cpld_reg.mode_31_8=config +sff_cpld_reg.src_31_8=cpld +sff_cpld_reg.frmt_31_8=bit +sff_cpld_reg.pola_31_8=negative +sff_cpld_reg.addr_31_8=0x00020074 +sff_cpld_reg.len_31_8=1 +sff_cpld_reg.bit_offset_31_8=6 + +sff_cpld_reg.mode_32_8=config +sff_cpld_reg.src_32_8=cpld +sff_cpld_reg.frmt_32_8=bit +sff_cpld_reg.pola_32_8=negative +sff_cpld_reg.addr_32_8=0x00020074 +sff_cpld_reg.len_32_8=1 +sff_cpld_reg.bit_offset_32_8=7 + +sff_cpld_reg.mode_33_8=config +sff_cpld_reg.src_33_8=cpld +sff_cpld_reg.frmt_33_8=bit +sff_cpld_reg.pola_33_8=negative +sff_cpld_reg.addr_33_8=0x00050075 +sff_cpld_reg.len_33_8=1 +sff_cpld_reg.bit_offset_33_8=0 + +sff_cpld_reg.mode_34_8=config +sff_cpld_reg.src_34_8=cpld +sff_cpld_reg.frmt_34_8=bit +sff_cpld_reg.pola_34_8=negative +sff_cpld_reg.addr_34_8=0x00050075 +sff_cpld_reg.len_34_8=1 +sff_cpld_reg.bit_offset_34_8=1 + +sff_cpld_reg.mode_35_8=config +sff_cpld_reg.src_35_8=cpld +sff_cpld_reg.frmt_35_8=bit +sff_cpld_reg.pola_35_8=negative +sff_cpld_reg.addr_35_8=0x00050075 +sff_cpld_reg.len_35_8=1 +sff_cpld_reg.bit_offset_35_8=2 + +sff_cpld_reg.mode_36_8=config +sff_cpld_reg.src_36_8=cpld +sff_cpld_reg.frmt_36_8=bit +sff_cpld_reg.pola_36_8=negative +sff_cpld_reg.addr_36_8=0x00050075 +sff_cpld_reg.len_36_8=1 +sff_cpld_reg.bit_offset_36_8=3 + +sff_cpld_reg.mode_37_8=config +sff_cpld_reg.src_37_8=cpld +sff_cpld_reg.frmt_37_8=bit +sff_cpld_reg.pola_37_8=negative +sff_cpld_reg.addr_37_8=0x00050074 +sff_cpld_reg.len_37_8=1 +sff_cpld_reg.bit_offset_37_8=0 + +sff_cpld_reg.mode_38_8=config +sff_cpld_reg.src_38_8=cpld +sff_cpld_reg.frmt_38_8=bit +sff_cpld_reg.pola_38_8=negative +sff_cpld_reg.addr_38_8=0x00050074 +sff_cpld_reg.len_38_8=1 +sff_cpld_reg.bit_offset_38_8=1 + +sff_cpld_reg.mode_39_8=config +sff_cpld_reg.src_39_8=cpld +sff_cpld_reg.frmt_39_8=bit +sff_cpld_reg.pola_39_8=negative +sff_cpld_reg.addr_39_8=0x00050074 +sff_cpld_reg.len_39_8=1 +sff_cpld_reg.bit_offset_39_8=2 + +sff_cpld_reg.mode_40_8=config +sff_cpld_reg.src_40_8=cpld +sff_cpld_reg.frmt_40_8=bit +sff_cpld_reg.pola_40_8=negative +sff_cpld_reg.addr_40_8=0x00050074 +sff_cpld_reg.len_40_8=1 +sff_cpld_reg.bit_offset_40_8=3 + +sff_cpld_reg.mode_41_8=config +sff_cpld_reg.src_41_8=cpld +sff_cpld_reg.frmt_41_8=bit +sff_cpld_reg.pola_41_8=negative +sff_cpld_reg.addr_41_8=0x00050074 +sff_cpld_reg.len_41_8=1 +sff_cpld_reg.bit_offset_41_8=4 + +sff_cpld_reg.mode_42_8=config +sff_cpld_reg.src_42_8=cpld +sff_cpld_reg.frmt_42_8=bit +sff_cpld_reg.pola_42_8=negative +sff_cpld_reg.addr_42_8=0x00050074 +sff_cpld_reg.len_42_8=1 +sff_cpld_reg.bit_offset_42_8=5 + +sff_cpld_reg.mode_43_8=config +sff_cpld_reg.src_43_8=cpld +sff_cpld_reg.frmt_43_8=bit +sff_cpld_reg.pola_43_8=negative +sff_cpld_reg.addr_43_8=0x0006007b +sff_cpld_reg.len_43_8=1 +sff_cpld_reg.bit_offset_43_8=0 + +sff_cpld_reg.mode_44_8=config +sff_cpld_reg.src_44_8=cpld +sff_cpld_reg.frmt_44_8=bit +sff_cpld_reg.pola_44_8=negative +sff_cpld_reg.addr_44_8=0x0006007b +sff_cpld_reg.len_44_8=1 +sff_cpld_reg.bit_offset_44_8=1 + +sff_cpld_reg.mode_45_8=config +sff_cpld_reg.src_45_8=cpld +sff_cpld_reg.frmt_45_8=bit +sff_cpld_reg.pola_45_8=negative +sff_cpld_reg.addr_45_8=0x0006007b +sff_cpld_reg.len_45_8=1 +sff_cpld_reg.bit_offset_45_8=2 + +sff_cpld_reg.mode_46_8=config +sff_cpld_reg.src_46_8=cpld +sff_cpld_reg.frmt_46_8=bit +sff_cpld_reg.pola_46_8=negative +sff_cpld_reg.addr_46_8=0x0006007b +sff_cpld_reg.len_46_8=1 +sff_cpld_reg.bit_offset_46_8=3 + +sff_cpld_reg.mode_47_8=config +sff_cpld_reg.src_47_8=cpld +sff_cpld_reg.frmt_47_8=bit +sff_cpld_reg.pola_47_8=negative +sff_cpld_reg.addr_47_8=0x0006007b +sff_cpld_reg.len_47_8=1 +sff_cpld_reg.bit_offset_47_8=4 + +sff_cpld_reg.mode_48_8=config +sff_cpld_reg.src_48_8=cpld +sff_cpld_reg.frmt_48_8=bit +sff_cpld_reg.pola_48_8=negative +sff_cpld_reg.addr_48_8=0x0006007b +sff_cpld_reg.len_48_8=1 +sff_cpld_reg.bit_offset_48_8=5 + +sff_cpld_reg.mode_49_8=config +sff_cpld_reg.src_49_8=cpld +sff_cpld_reg.frmt_49_8=bit +sff_cpld_reg.pola_49_8=negative +sff_cpld_reg.addr_49_8=0x0006007a +sff_cpld_reg.len_49_8=1 +sff_cpld_reg.bit_offset_49_8=0 + +sff_cpld_reg.mode_50_8=config +sff_cpld_reg.src_50_8=cpld +sff_cpld_reg.frmt_50_8=bit +sff_cpld_reg.pola_50_8=negative +sff_cpld_reg.addr_50_8=0x0006007a +sff_cpld_reg.len_50_8=1 +sff_cpld_reg.bit_offset_50_8=1 + +sff_cpld_reg.mode_51_8=config +sff_cpld_reg.src_51_8=cpld +sff_cpld_reg.frmt_51_8=bit +sff_cpld_reg.pola_51_8=negative +sff_cpld_reg.addr_51_8=0x0006007a +sff_cpld_reg.len_51_8=1 +sff_cpld_reg.bit_offset_51_8=2 + +sff_cpld_reg.mode_52_8=config +sff_cpld_reg.src_52_8=cpld +sff_cpld_reg.frmt_52_8=bit +sff_cpld_reg.pola_52_8=negative +sff_cpld_reg.addr_52_8=0x0006007a +sff_cpld_reg.len_52_8=1 +sff_cpld_reg.bit_offset_52_8=3 + +sff_cpld_reg.mode_53_8=config +sff_cpld_reg.src_53_8=cpld +sff_cpld_reg.frmt_53_8=bit +sff_cpld_reg.pola_53_8=negative +sff_cpld_reg.addr_53_8=0x0006007a +sff_cpld_reg.len_53_8=1 +sff_cpld_reg.bit_offset_53_8=4 + +sff_cpld_reg.mode_54_8=config +sff_cpld_reg.src_54_8=cpld +sff_cpld_reg.frmt_54_8=bit +sff_cpld_reg.pola_54_8=negative +sff_cpld_reg.addr_54_8=0x0006007a +sff_cpld_reg.len_54_8=1 +sff_cpld_reg.bit_offset_54_8=5 + +sff_cpld_reg.mode_55_8=config +sff_cpld_reg.src_55_8=cpld +sff_cpld_reg.frmt_55_8=bit +sff_cpld_reg.pola_55_8=negative +sff_cpld_reg.addr_55_8=0x0006007a +sff_cpld_reg.len_55_8=1 +sff_cpld_reg.bit_offset_55_8=6 + +sff_cpld_reg.mode_56_8=config +sff_cpld_reg.src_56_8=cpld +sff_cpld_reg.frmt_56_8=bit +sff_cpld_reg.pola_56_8=negative +sff_cpld_reg.addr_56_8=0x0006007a +sff_cpld_reg.len_56_8=1 +sff_cpld_reg.bit_offset_56_8=7 + +sff_cpld_reg.mode_57_8=config +sff_cpld_reg.src_57_8=cpld +sff_cpld_reg.frmt_57_8=bit +sff_cpld_reg.pola_57_8=negative +sff_cpld_reg.addr_57_8=0x00060079 +sff_cpld_reg.len_57_8=1 +sff_cpld_reg.bit_offset_57_8=0 + +sff_cpld_reg.mode_58_8=config +sff_cpld_reg.src_58_8=cpld +sff_cpld_reg.frmt_58_8=bit +sff_cpld_reg.pola_58_8=negative +sff_cpld_reg.addr_58_8=0x00060079 +sff_cpld_reg.len_58_8=1 +sff_cpld_reg.bit_offset_58_8=1 + +sff_cpld_reg.mode_59_8=config +sff_cpld_reg.src_59_8=cpld +sff_cpld_reg.frmt_59_8=bit +sff_cpld_reg.pola_59_8=negative +sff_cpld_reg.addr_59_8=0x00060079 +sff_cpld_reg.len_59_8=1 +sff_cpld_reg.bit_offset_59_8=2 + +sff_cpld_reg.mode_60_8=config +sff_cpld_reg.src_60_8=cpld +sff_cpld_reg.frmt_60_8=bit +sff_cpld_reg.pola_60_8=negative +sff_cpld_reg.addr_60_8=0x00060079 +sff_cpld_reg.len_60_8=1 +sff_cpld_reg.bit_offset_60_8=3 + +sff_cpld_reg.mode_61_8=config +sff_cpld_reg.src_61_8=cpld +sff_cpld_reg.frmt_61_8=bit +sff_cpld_reg.pola_61_8=negative +sff_cpld_reg.addr_61_8=0x00060079 +sff_cpld_reg.len_61_8=1 +sff_cpld_reg.bit_offset_61_8=4 + +sff_cpld_reg.mode_62_8=config +sff_cpld_reg.src_62_8=cpld +sff_cpld_reg.frmt_62_8=bit +sff_cpld_reg.pola_62_8=negative +sff_cpld_reg.addr_62_8=0x00060079 +sff_cpld_reg.len_62_8=1 +sff_cpld_reg.bit_offset_62_8=5 + +sff_cpld_reg.mode_63_8=config +sff_cpld_reg.src_63_8=cpld +sff_cpld_reg.frmt_63_8=bit +sff_cpld_reg.pola_63_8=negative +sff_cpld_reg.addr_63_8=0x00060079 +sff_cpld_reg.len_63_8=1 +sff_cpld_reg.bit_offset_63_8=6 + +sff_cpld_reg.mode_64_8=config +sff_cpld_reg.src_64_8=cpld +sff_cpld_reg.frmt_64_8=bit +sff_cpld_reg.pola_64_8=negative +sff_cpld_reg.addr_64_8=0x00060079 +sff_cpld_reg.len_64_8=1 +sff_cpld_reg.bit_offset_64_8=7 + +sff_cpld_reg.mode_65_8=config +sff_cpld_reg.src_65_8=cpld +sff_cpld_reg.frmt_65_8=bit +sff_cpld_reg.pola_65_8=negative +sff_cpld_reg.addr_65_8=0x00050074 +sff_cpld_reg.len_65_8=1 +sff_cpld_reg.bit_offset_65_8=6 + +sff_cpld_reg.mode_66_8=config +sff_cpld_reg.src_66_8=cpld +sff_cpld_reg.frmt_66_8=bit +sff_cpld_reg.pola_66_8=negative +sff_cpld_reg.addr_66_8=0x00050074 +sff_cpld_reg.len_66_8=1 +sff_cpld_reg.bit_offset_66_8=7 + +sff_cpld_reg.mode_67_8=config +sff_cpld_reg.src_67_8=cpld +sff_cpld_reg.frmt_67_8=bit +sff_cpld_reg.pola_67_8=negative +sff_cpld_reg.addr_67_8=0x00050073 +sff_cpld_reg.len_67_8=1 +sff_cpld_reg.bit_offset_67_8=0 + +sff_cpld_reg.mode_68_8=config +sff_cpld_reg.src_68_8=cpld +sff_cpld_reg.frmt_68_8=bit +sff_cpld_reg.pola_68_8=negative +sff_cpld_reg.addr_68_8=0x00050073 +sff_cpld_reg.len_68_8=1 +sff_cpld_reg.bit_offset_68_8=1 + +sff_cpld_reg.mode_69_8=config +sff_cpld_reg.src_69_8=cpld +sff_cpld_reg.frmt_69_8=bit +sff_cpld_reg.pola_69_8=negative +sff_cpld_reg.addr_69_8=0x00050073 +sff_cpld_reg.len_69_8=1 +sff_cpld_reg.bit_offset_69_8=2 + +sff_cpld_reg.mode_70_8=config +sff_cpld_reg.src_70_8=cpld +sff_cpld_reg.frmt_70_8=bit +sff_cpld_reg.pola_70_8=negative +sff_cpld_reg.addr_70_8=0x00050073 +sff_cpld_reg.len_70_8=1 +sff_cpld_reg.bit_offset_70_8=3 + +sff_cpld_reg.mode_71_8=config +sff_cpld_reg.src_71_8=cpld +sff_cpld_reg.frmt_71_8=bit +sff_cpld_reg.pola_71_8=negative +sff_cpld_reg.addr_71_8=0x00050073 +sff_cpld_reg.len_71_8=1 +sff_cpld_reg.bit_offset_71_8=4 + +sff_cpld_reg.mode_72_8=config +sff_cpld_reg.src_72_8=cpld +sff_cpld_reg.frmt_72_8=bit +sff_cpld_reg.pola_72_8=negative +sff_cpld_reg.addr_72_8=0x00050073 +sff_cpld_reg.len_72_8=1 +sff_cpld_reg.bit_offset_72_8=5 + +sff_cpld_reg.mode_73_8=config +sff_cpld_reg.src_73_8=cpld +sff_cpld_reg.frmt_73_8=bit +sff_cpld_reg.pola_73_8=negative +sff_cpld_reg.addr_73_8=0x00050073 +sff_cpld_reg.len_73_8=1 +sff_cpld_reg.bit_offset_73_8=6 + +sff_cpld_reg.mode_74_8=config +sff_cpld_reg.src_74_8=cpld +sff_cpld_reg.frmt_74_8=bit +sff_cpld_reg.pola_74_8=negative +sff_cpld_reg.addr_74_8=0x00050073 +sff_cpld_reg.len_74_8=1 +sff_cpld_reg.bit_offset_74_8=7 + +sff_cpld_reg.mode_75_8=config +sff_cpld_reg.src_75_8=cpld +sff_cpld_reg.frmt_75_8=bit +sff_cpld_reg.pola_75_8=negative +sff_cpld_reg.addr_75_8=0x00060078 +sff_cpld_reg.len_75_8=1 +sff_cpld_reg.bit_offset_75_8=0 + +sff_cpld_reg.mode_76_8=config +sff_cpld_reg.src_76_8=cpld +sff_cpld_reg.frmt_76_8=bit +sff_cpld_reg.pola_76_8=negative +sff_cpld_reg.addr_76_8=0x00060078 +sff_cpld_reg.len_76_8=1 +sff_cpld_reg.bit_offset_76_8=1 + +sff_cpld_reg.mode_77_8=config +sff_cpld_reg.src_77_8=cpld +sff_cpld_reg.frmt_77_8=bit +sff_cpld_reg.pola_77_8=negative +sff_cpld_reg.addr_77_8=0x00060078 +sff_cpld_reg.len_77_8=1 +sff_cpld_reg.bit_offset_77_8=2 + +sff_cpld_reg.mode_78_8=config +sff_cpld_reg.src_78_8=cpld +sff_cpld_reg.frmt_78_8=bit +sff_cpld_reg.pola_78_8=negative +sff_cpld_reg.addr_78_8=0x00060078 +sff_cpld_reg.len_78_8=1 +sff_cpld_reg.bit_offset_78_8=3 + +sff_cpld_reg.mode_79_8=config +sff_cpld_reg.src_79_8=cpld +sff_cpld_reg.frmt_79_8=bit +sff_cpld_reg.pola_79_8=negative +sff_cpld_reg.addr_79_8=0x00060078 +sff_cpld_reg.len_79_8=1 +sff_cpld_reg.bit_offset_79_8=4 + +sff_cpld_reg.mode_80_8=config +sff_cpld_reg.src_80_8=cpld +sff_cpld_reg.frmt_80_8=bit +sff_cpld_reg.pola_80_8=negative +sff_cpld_reg.addr_80_8=0x00060078 +sff_cpld_reg.len_80_8=1 +sff_cpld_reg.bit_offset_80_8=5 + +sff_cpld_reg.mode_81_8=config +sff_cpld_reg.src_81_8=cpld +sff_cpld_reg.frmt_81_8=bit +sff_cpld_reg.pola_81_8=negative +sff_cpld_reg.addr_81_8=0x00060077 +sff_cpld_reg.len_81_8=1 +sff_cpld_reg.bit_offset_81_8=0 + +sff_cpld_reg.mode_82_8=config +sff_cpld_reg.src_82_8=cpld +sff_cpld_reg.frmt_82_8=bit +sff_cpld_reg.pola_82_8=negative +sff_cpld_reg.addr_82_8=0x00060077 +sff_cpld_reg.len_82_8=1 +sff_cpld_reg.bit_offset_82_8=1 + +sff_cpld_reg.mode_83_8=config +sff_cpld_reg.src_83_8=cpld +sff_cpld_reg.frmt_83_8=bit +sff_cpld_reg.pola_83_8=negative +sff_cpld_reg.addr_83_8=0x00060077 +sff_cpld_reg.len_83_8=1 +sff_cpld_reg.bit_offset_83_8=2 + +sff_cpld_reg.mode_84_8=config +sff_cpld_reg.src_84_8=cpld +sff_cpld_reg.frmt_84_8=bit +sff_cpld_reg.pola_84_8=negative +sff_cpld_reg.addr_84_8=0x00060077 +sff_cpld_reg.len_84_8=1 +sff_cpld_reg.bit_offset_84_8=3 + +sff_cpld_reg.mode_85_8=config +sff_cpld_reg.src_85_8=cpld +sff_cpld_reg.frmt_85_8=bit +sff_cpld_reg.pola_85_8=negative +sff_cpld_reg.addr_85_8=0x00060077 +sff_cpld_reg.len_85_8=1 +sff_cpld_reg.bit_offset_85_8=4 + +sff_cpld_reg.mode_86_8=config +sff_cpld_reg.src_86_8=cpld +sff_cpld_reg.frmt_86_8=bit +sff_cpld_reg.pola_86_8=negative +sff_cpld_reg.addr_86_8=0x00060077 +sff_cpld_reg.len_86_8=1 +sff_cpld_reg.bit_offset_86_8=5 + +sff_cpld_reg.mode_87_8=config +sff_cpld_reg.src_87_8=cpld +sff_cpld_reg.frmt_87_8=bit +sff_cpld_reg.pola_87_8=negative +sff_cpld_reg.addr_87_8=0x00060077 +sff_cpld_reg.len_87_8=1 +sff_cpld_reg.bit_offset_87_8=6 + +sff_cpld_reg.mode_88_8=config +sff_cpld_reg.src_88_8=cpld +sff_cpld_reg.frmt_88_8=bit +sff_cpld_reg.pola_88_8=negative +sff_cpld_reg.addr_88_8=0x00060077 +sff_cpld_reg.len_88_8=1 +sff_cpld_reg.bit_offset_88_8=7 + +sff_cpld_reg.mode_89_8=config +sff_cpld_reg.src_89_8=cpld +sff_cpld_reg.frmt_89_8=bit +sff_cpld_reg.pola_89_8=negative +sff_cpld_reg.addr_89_8=0x00060076 +sff_cpld_reg.len_89_8=1 +sff_cpld_reg.bit_offset_89_8=0 + +sff_cpld_reg.mode_90_8=config +sff_cpld_reg.src_90_8=cpld +sff_cpld_reg.frmt_90_8=bit +sff_cpld_reg.pola_90_8=negative +sff_cpld_reg.addr_90_8=0x00060076 +sff_cpld_reg.len_90_8=1 +sff_cpld_reg.bit_offset_90_8=1 + +sff_cpld_reg.mode_91_8=config +sff_cpld_reg.src_91_8=cpld +sff_cpld_reg.frmt_91_8=bit +sff_cpld_reg.pola_91_8=negative +sff_cpld_reg.addr_91_8=0x00060076 +sff_cpld_reg.len_91_8=1 +sff_cpld_reg.bit_offset_91_8=2 + +sff_cpld_reg.mode_92_8=config +sff_cpld_reg.src_92_8=cpld +sff_cpld_reg.frmt_92_8=bit +sff_cpld_reg.pola_92_8=negative +sff_cpld_reg.addr_92_8=0x00060076 +sff_cpld_reg.len_92_8=1 +sff_cpld_reg.bit_offset_92_8=3 + +sff_cpld_reg.mode_93_8=config +sff_cpld_reg.src_93_8=cpld +sff_cpld_reg.frmt_93_8=bit +sff_cpld_reg.pola_93_8=negative +sff_cpld_reg.addr_93_8=0x00060076 +sff_cpld_reg.len_93_8=1 +sff_cpld_reg.bit_offset_93_8=4 + +sff_cpld_reg.mode_94_8=config +sff_cpld_reg.src_94_8=cpld +sff_cpld_reg.frmt_94_8=bit +sff_cpld_reg.pola_94_8=negative +sff_cpld_reg.addr_94_8=0x00060076 +sff_cpld_reg.len_94_8=1 +sff_cpld_reg.bit_offset_94_8=5 + +sff_cpld_reg.mode_95_8=config +sff_cpld_reg.src_95_8=cpld +sff_cpld_reg.frmt_95_8=bit +sff_cpld_reg.pola_95_8=negative +sff_cpld_reg.addr_95_8=0x00060076 +sff_cpld_reg.len_95_8=1 +sff_cpld_reg.bit_offset_95_8=6 + +sff_cpld_reg.mode_96_8=config +sff_cpld_reg.src_96_8=cpld +sff_cpld_reg.frmt_96_8=bit +sff_cpld_reg.pola_96_8=negative +sff_cpld_reg.addr_96_8=0x00060076 +sff_cpld_reg.len_96_8=1 +sff_cpld_reg.bit_offset_96_8=7 + +sff_cpld_reg.mode_97_8=config +sff_cpld_reg.src_97_8=cpld +sff_cpld_reg.frmt_97_8=bit +sff_cpld_reg.pola_97_8=negative +sff_cpld_reg.addr_97_8=0x00070077 +sff_cpld_reg.len_97_8=1 +sff_cpld_reg.bit_offset_97_8=0 + +sff_cpld_reg.mode_98_8=config +sff_cpld_reg.src_98_8=cpld +sff_cpld_reg.frmt_98_8=bit +sff_cpld_reg.pola_98_8=negative +sff_cpld_reg.addr_98_8=0x00070077 +sff_cpld_reg.len_98_8=1 +sff_cpld_reg.bit_offset_98_8=1 + +sff_cpld_reg.mode_99_8=config +sff_cpld_reg.src_99_8=cpld +sff_cpld_reg.frmt_99_8=bit +sff_cpld_reg.pola_99_8=negative +sff_cpld_reg.addr_99_8=0x00070077 +sff_cpld_reg.len_99_8=1 +sff_cpld_reg.bit_offset_99_8=2 + +sff_cpld_reg.mode_100_8=config +sff_cpld_reg.src_100_8=cpld +sff_cpld_reg.frmt_100_8=bit +sff_cpld_reg.pola_100_8=negative +sff_cpld_reg.addr_100_8=0x00070077 +sff_cpld_reg.len_100_8=1 +sff_cpld_reg.bit_offset_100_8=3 + +sff_cpld_reg.mode_101_8=config +sff_cpld_reg.src_101_8=cpld +sff_cpld_reg.frmt_101_8=bit +sff_cpld_reg.pola_101_8=negative +sff_cpld_reg.addr_101_8=0x00070077 +sff_cpld_reg.len_101_8=1 +sff_cpld_reg.bit_offset_101_8=4 + +sff_cpld_reg.mode_102_8=config +sff_cpld_reg.src_102_8=cpld +sff_cpld_reg.frmt_102_8=bit +sff_cpld_reg.pola_102_8=negative +sff_cpld_reg.addr_102_8=0x00070077 +sff_cpld_reg.len_102_8=1 +sff_cpld_reg.bit_offset_102_8=5 + +sff_cpld_reg.mode_103_8=config +sff_cpld_reg.src_103_8=cpld +sff_cpld_reg.frmt_103_8=bit +sff_cpld_reg.pola_103_8=negative +sff_cpld_reg.addr_103_8=0x00070077 +sff_cpld_reg.len_103_8=1 +sff_cpld_reg.bit_offset_103_8=6 + +sff_cpld_reg.mode_104_8=config +sff_cpld_reg.src_104_8=cpld +sff_cpld_reg.frmt_104_8=bit +sff_cpld_reg.pola_104_8=negative +sff_cpld_reg.addr_104_8=0x00070077 +sff_cpld_reg.len_104_8=1 +sff_cpld_reg.bit_offset_104_8=7 + +sff_cpld_reg.mode_105_8=config +sff_cpld_reg.src_105_8=cpld +sff_cpld_reg.frmt_105_8=bit +sff_cpld_reg.pola_105_8=negative +sff_cpld_reg.addr_105_8=0x00070076 +sff_cpld_reg.len_105_8=1 +sff_cpld_reg.bit_offset_105_8=0 + +sff_cpld_reg.mode_106_8=config +sff_cpld_reg.src_106_8=cpld +sff_cpld_reg.frmt_106_8=bit +sff_cpld_reg.pola_106_8=negative +sff_cpld_reg.addr_106_8=0x00070076 +sff_cpld_reg.len_106_8=1 +sff_cpld_reg.bit_offset_106_8=1 + +sff_cpld_reg.mode_107_8=config +sff_cpld_reg.src_107_8=cpld +sff_cpld_reg.frmt_107_8=bit +sff_cpld_reg.pola_107_8=negative +sff_cpld_reg.addr_107_8=0x00070076 +sff_cpld_reg.len_107_8=1 +sff_cpld_reg.bit_offset_107_8=2 + +sff_cpld_reg.mode_108_8=config +sff_cpld_reg.src_108_8=cpld +sff_cpld_reg.frmt_108_8=bit +sff_cpld_reg.pola_108_8=negative +sff_cpld_reg.addr_108_8=0x00070076 +sff_cpld_reg.len_108_8=1 +sff_cpld_reg.bit_offset_108_8=3 + +sff_cpld_reg.mode_109_8=config +sff_cpld_reg.src_109_8=cpld +sff_cpld_reg.frmt_109_8=bit +sff_cpld_reg.pola_109_8=negative +sff_cpld_reg.addr_109_8=0x00070076 +sff_cpld_reg.len_109_8=1 +sff_cpld_reg.bit_offset_109_8=4 + +sff_cpld_reg.mode_110_8=config +sff_cpld_reg.src_110_8=cpld +sff_cpld_reg.frmt_110_8=bit +sff_cpld_reg.pola_110_8=negative +sff_cpld_reg.addr_110_8=0x00070076 +sff_cpld_reg.len_110_8=1 +sff_cpld_reg.bit_offset_110_8=5 + +sff_cpld_reg.mode_111_8=config +sff_cpld_reg.src_111_8=cpld +sff_cpld_reg.frmt_111_8=bit +sff_cpld_reg.pola_111_8=negative +sff_cpld_reg.addr_111_8=0x00070076 +sff_cpld_reg.len_111_8=1 +sff_cpld_reg.bit_offset_111_8=6 + +sff_cpld_reg.mode_112_8=config +sff_cpld_reg.src_112_8=cpld +sff_cpld_reg.frmt_112_8=bit +sff_cpld_reg.pola_112_8=negative +sff_cpld_reg.addr_112_8=0x00070076 +sff_cpld_reg.len_112_8=1 +sff_cpld_reg.bit_offset_112_8=7 + +sff_cpld_reg.mode_113_8=config +sff_cpld_reg.src_113_8=cpld +sff_cpld_reg.frmt_113_8=bit +sff_cpld_reg.pola_113_8=negative +sff_cpld_reg.addr_113_8=0x00070075 +sff_cpld_reg.len_113_8=1 +sff_cpld_reg.bit_offset_113_8=0 + +sff_cpld_reg.mode_114_8=config +sff_cpld_reg.src_114_8=cpld +sff_cpld_reg.frmt_114_8=bit +sff_cpld_reg.pola_114_8=negative +sff_cpld_reg.addr_114_8=0x00070075 +sff_cpld_reg.len_114_8=1 +sff_cpld_reg.bit_offset_114_8=1 + +sff_cpld_reg.mode_115_8=config +sff_cpld_reg.src_115_8=cpld +sff_cpld_reg.frmt_115_8=bit +sff_cpld_reg.pola_115_8=negative +sff_cpld_reg.addr_115_8=0x00070075 +sff_cpld_reg.len_115_8=1 +sff_cpld_reg.bit_offset_115_8=2 + +sff_cpld_reg.mode_116_8=config +sff_cpld_reg.src_116_8=cpld +sff_cpld_reg.frmt_116_8=bit +sff_cpld_reg.pola_116_8=negative +sff_cpld_reg.addr_116_8=0x00070075 +sff_cpld_reg.len_116_8=1 +sff_cpld_reg.bit_offset_116_8=3 + +sff_cpld_reg.mode_117_8=config +sff_cpld_reg.src_117_8=cpld +sff_cpld_reg.frmt_117_8=bit +sff_cpld_reg.pola_117_8=negative +sff_cpld_reg.addr_117_8=0x00070075 +sff_cpld_reg.len_117_8=1 +sff_cpld_reg.bit_offset_117_8=4 + +sff_cpld_reg.mode_118_8=config +sff_cpld_reg.src_118_8=cpld +sff_cpld_reg.frmt_118_8=bit +sff_cpld_reg.pola_118_8=negative +sff_cpld_reg.addr_118_8=0x00070075 +sff_cpld_reg.len_118_8=1 +sff_cpld_reg.bit_offset_118_8=5 + +sff_cpld_reg.mode_119_8=config +sff_cpld_reg.src_119_8=cpld +sff_cpld_reg.frmt_119_8=bit +sff_cpld_reg.pola_119_8=negative +sff_cpld_reg.addr_119_8=0x00070075 +sff_cpld_reg.len_119_8=1 +sff_cpld_reg.bit_offset_119_8=6 + +sff_cpld_reg.mode_120_8=config +sff_cpld_reg.src_120_8=cpld +sff_cpld_reg.frmt_120_8=bit +sff_cpld_reg.pola_120_8=negative +sff_cpld_reg.addr_120_8=0x00070075 +sff_cpld_reg.len_120_8=1 +sff_cpld_reg.bit_offset_120_8=7 + +sff_cpld_reg.mode_121_8=config +sff_cpld_reg.src_121_8=cpld +sff_cpld_reg.frmt_121_8=bit +sff_cpld_reg.pola_121_8=negative +sff_cpld_reg.addr_121_8=0x00070074 +sff_cpld_reg.len_121_8=1 +sff_cpld_reg.bit_offset_121_8=0 + +sff_cpld_reg.mode_122_8=config +sff_cpld_reg.src_122_8=cpld +sff_cpld_reg.frmt_122_8=bit +sff_cpld_reg.pola_122_8=negative +sff_cpld_reg.addr_122_8=0x00070074 +sff_cpld_reg.len_122_8=1 +sff_cpld_reg.bit_offset_122_8=1 + +sff_cpld_reg.mode_123_8=config +sff_cpld_reg.src_123_8=cpld +sff_cpld_reg.frmt_123_8=bit +sff_cpld_reg.pola_123_8=negative +sff_cpld_reg.addr_123_8=0x00070074 +sff_cpld_reg.len_123_8=1 +sff_cpld_reg.bit_offset_123_8=2 + +sff_cpld_reg.mode_124_8=config +sff_cpld_reg.src_124_8=cpld +sff_cpld_reg.frmt_124_8=bit +sff_cpld_reg.pola_124_8=negative +sff_cpld_reg.addr_124_8=0x00070074 +sff_cpld_reg.len_124_8=1 +sff_cpld_reg.bit_offset_124_8=3 + +sff_cpld_reg.mode_125_8=config +sff_cpld_reg.src_125_8=cpld +sff_cpld_reg.frmt_125_8=bit +sff_cpld_reg.pola_125_8=negative +sff_cpld_reg.addr_125_8=0x00070074 +sff_cpld_reg.len_125_8=1 +sff_cpld_reg.bit_offset_125_8=4 + +sff_cpld_reg.mode_126_8=config +sff_cpld_reg.src_126_8=cpld +sff_cpld_reg.frmt_126_8=bit +sff_cpld_reg.pola_126_8=negative +sff_cpld_reg.addr_126_8=0x00070074 +sff_cpld_reg.len_126_8=1 +sff_cpld_reg.bit_offset_126_8=5 + +sff_cpld_reg.mode_127_8=config +sff_cpld_reg.src_127_8=cpld +sff_cpld_reg.frmt_127_8=bit +sff_cpld_reg.pola_127_8=negative +sff_cpld_reg.addr_127_8=0x00070074 +sff_cpld_reg.len_127_8=1 +sff_cpld_reg.bit_offset_127_8=6 + +sff_cpld_reg.mode_128_8=config +sff_cpld_reg.src_128_8=cpld +sff_cpld_reg.frmt_128_8=bit +sff_cpld_reg.pola_128_8=negative +sff_cpld_reg.addr_128_8=0x00070074 +sff_cpld_reg.len_128_8=1 +sff_cpld_reg.bit_offset_128_8=7 \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/cfg_file_name b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/cfg_file_name new file mode 100755 index 000000000000..5f694169a546 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/plat_sysfs_cfg/cfg_file_name @@ -0,0 +1,5 @@ +TCS9400-CPLD +TCS9400-FAN +TCS9400-PSU +TCS9400-SFF +TCS9400-SENSOR \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/s3ip_config/customer_sysfs.json b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/s3ip_config/customer_sysfs.json new file mode 100755 index 000000000000..cc02b9e68b50 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/s3ip_config/customer_sysfs.json @@ -0,0 +1,70 @@ +{ + "s3ip_syfs_paths": [ + { + "path": "/sys_switch/temp_sensor", + "type" : "path", + "value" : "/sys/s3ip/temp_sensor", + "description": "temperature sensor information" + }, + { + "path": "/sys_switch/vol_sensor", + "type" : "path", + "value" : "/sys/s3ip/vol_sensor", + "description": "voltage sensor information" + }, + { + "path": "/sys_switch/curr_sensor", + "type" : "path", + "value" : "/sys/s3ip/curr_sensor", + "description": "current sensor information" + }, + { + "path": "/sys_switch/syseeprom", + "type" : "path", + "value" : "/sys/s3ip/syseeprom", + "description": "ONIE EEPROM" + }, + { + "path": "/sys_switch/fan", + "type" : "path", + "value" : "/sys/s3ip/fan", + "description": "fan information" + }, + { + "path": "/sys_switch/psu", + "type" : "path", + "value" : "/sys/s3ip/psu", + "description": "psu information" + }, + { + "path": "/sys_switch/transceiver", + "type" : "path", + "value" : "/sys/s3ip/transceiver", + "description": "transceiver information" + }, + { + "path": "/sys_switch/sysled", + "type" : "path", + "value" : "/sys/s3ip/sysled", + "description": "sysled information" + }, + { + "path": "/sys_switch/fpga", + "type" : "path", + "value" : "/sys/s3ip/fpga", + "description": "FPGA information" + }, + { + "path": "/sys_switch/cpld", + "type" : "path", + "value" : "/sys/s3ip/cpld", + "description": "CPLD information" + }, + { + "path": "/sys_switch/watchdog", + "type" : "path", + "value" : "/sys/s3ip/watchdog", + "description": "watchdog information" + } + ] +} diff --git a/platform/broadcom/sonic-platform-modules-tencent/tcs9400/setup.py b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/setup.py new file mode 100755 index 000000000000..74fa60395d9a --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-tencent/tcs9400/setup.py @@ -0,0 +1,40 @@ +from setuptools import setup + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Ruijie TCS9400 Platforms', + license='Apache 2.0', + author='SONiC Team', + author_email='sonic_rd@ruijie.com.cn', + url='', + maintainer='Ruijie TCS9400', + maintainer_email='', + packages=[ + 'sonic_platform', + 'plat_hal', + 'rjutil', + 'eepromutil', + 'hal-config', + 'config', + ], + py_modules=[ + 'hal_pltfm', + 'platform_util', + 'platform_intf', + ], + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Plugins', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3.9', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) +