From 461d546d9abb78cb2438f8e24436d20b57030991 Mon Sep 17 00:00:00 2001 From: nicwu-cel Date: Tue, 16 Nov 2021 12:00:55 +0000 Subject: [PATCH 01/16] add belgite platform support --- .../CELESTICA-BELGITE/belgite.config.bcm | 145 ++++ .../CELESTICA-BELGITE/port_config.ini | 57 ++ .../CELESTICA-BELGITE/sai.profile | 1 + .../x86_64-cel_belgite-r0/custom_led.bin | Bin 0 -> 216 bytes .../x86_64-cel_belgite-r0/default_sku | 1 + .../x86_64-cel_belgite-r0/installer.conf | 4 + .../led-source-code/cmicx/Makefile | 24 + .../led-source-code/cmicx/custom_led.c | 171 ++++ .../led-source-code/cmicx/custom_led.lds | 21 + .../x86_64-cel_belgite-r0/led_proc_init.soc | 3 + .../x86_64-cel_belgite-r0/media_settings.json | 49 ++ .../celestica/x86_64-cel_belgite-r0/pcie.yaml | 121 +++ .../x86_64-cel_belgite-r0/pddf/pd-plugin.json | 61 ++ .../pddf/pddf-device.json | 685 ++++++++++++++++ .../pddf/pddf-device.json.original | 686 ++++++++++++++++ .../x86_64-cel_belgite-r0/pddf_support | 0 .../x86_64-cel_belgite-r0/platform_asic | 1 + .../x86_64-cel_belgite-r0/plugins/eeprom.py | 14 + .../pmon_daemon_control.json | 4 + .../system_health_monitoring_config.json | 16 + platform/broadcom/one-image.mk | 1 + platform/broadcom/platform-modules-cel.mk | 5 + .../belgite/modules/Makefile | 1 + .../belgite/modules/mc24lc64t.c | 174 +++++ .../belgite/modules/pddf_custom_psu.c | 125 +++ .../belgite/modules/pddf_custom_wdt.c | 734 ++++++++++++++++++ .../belgite/pddf/sonic_platform/__init__.py | 3 + .../belgite/pddf/sonic_platform/chassis.py | 69 ++ .../belgite/pddf/sonic_platform/eeprom.py | 74 ++ .../belgite/pddf/sonic_platform/fan.py | 64 ++ .../belgite/pddf/sonic_platform/fan_drawer.py | 94 +++ .../belgite/pddf/sonic_platform/platform.py | 45 ++ .../belgite/pddf/sonic_platform/psu.py | 36 + .../belgite/pddf/sonic_platform/sfp.py | 15 + .../belgite/pddf/sonic_platform/thermal.py | 14 + .../belgite/pddf/sonic_platform/watchdog.py | 233 ++++++ .../belgite/pddf/sonic_platform_setup.py | 28 + .../scripts/pddf_post_device_create.sh | 9 + .../scripts/pddf_pre_driver_install.sh | 3 + .../belgite-pddf-platform-monitor.service | 16 + .../systemd/pddf-platform-init.service | 15 + .../belgite/utils/belgite_pddf_monitor.py | 271 +++++++ .../sonic-platform-modules-cel/debian/control | 5 + .../debian/platform-modules-belgite.install | 7 + .../debian/platform-modules-belgite.postinst | 6 + .../sonic-platform-modules-cel/debian/rules | 23 +- 46 files changed, 4129 insertions(+), 5 deletions(-) create mode 100644 device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/belgite.config.bcm create mode 100644 device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/port_config.ini create mode 100644 device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/sai.profile create mode 100644 device/celestica/x86_64-cel_belgite-r0/custom_led.bin create mode 100644 device/celestica/x86_64-cel_belgite-r0/default_sku create mode 100644 device/celestica/x86_64-cel_belgite-r0/installer.conf create mode 100755 device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/Makefile create mode 100755 device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.c create mode 100755 device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.lds create mode 100644 device/celestica/x86_64-cel_belgite-r0/led_proc_init.soc create mode 100644 device/celestica/x86_64-cel_belgite-r0/media_settings.json create mode 100644 device/celestica/x86_64-cel_belgite-r0/pcie.yaml create mode 100644 device/celestica/x86_64-cel_belgite-r0/pddf/pd-plugin.json create mode 100644 device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json create mode 100644 device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json.original create mode 100644 device/celestica/x86_64-cel_belgite-r0/pddf_support create mode 100644 device/celestica/x86_64-cel_belgite-r0/platform_asic create mode 100644 device/celestica/x86_64-cel_belgite-r0/plugins/eeprom.py create mode 100644 device/celestica/x86_64-cel_belgite-r0/pmon_daemon_control.json create mode 100644 device/celestica/x86_64-cel_belgite-r0/system_health_monitoring_config.json create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/modules/mc24lc64t.c create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_psu.c create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/__init__.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/sfp.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform_setup.py create mode 100755 platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh create mode 100755 platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_pre_driver_install.sh create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/service/belgite-pddf-platform-monitor.service create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/systemd/pddf-platform-init.service create mode 100755 platform/broadcom/sonic-platform-modules-cel/belgite/utils/belgite_pddf_monitor.py create mode 100644 platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-belgite.install create mode 100644 platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-belgite.postinst diff --git a/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/belgite.config.bcm b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/belgite.config.bcm new file mode 100644 index 000000000000..0e451d472108 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/belgite.config.bcm @@ -0,0 +1,145 @@ +#GPORT0 +portmap_25.0=2:1 +phy_port_primary_and_offset_25=0x0100 +portmap_26.0=1:1 +phy_port_primary_and_offset_26=0x0101 +portmap_27.0=4:1 +phy_port_primary_and_offset_27=0x0102 +portmap_28.0=3:1 +phy_port_primary_and_offset_28=0x0103 +portmap_29.0=6:1 +phy_port_primary_and_offset_29=0x0500 +portmap_30.0=5:1 +phy_port_primary_and_offset_30=0x0501 +portmap_31.0=8:1 +phy_port_primary_and_offset_31=0x0502 +portmap_32.0=7:1 +phy_port_primary_and_offset_32=0x0503 + +#GPORT1 +portmap_33.0=10:1 +phy_port_primary_and_offset_33=0x0900 +portmap_34.0=9:1 +phy_port_primary_and_offset_34=0x0901 +portmap_35.0=12:1 +phy_port_primary_and_offset_35=0x0902 +portmap_36.0=11:1 +phy_port_primary_and_offset_36=0x0903 +portmap_37.0=14:1 +phy_port_primary_and_offset_37=0x0d00 +portmap_38.0=13:1 +phy_port_primary_and_offset_38=0x0d01 +portmap_39.0=16:1 +phy_port_primary_and_offset_39=0x0d02 +portmap_40.0=15:1 +phy_port_primary_and_offset_40=0x0d03 + +#GPORT2 +portmap_41.0=18:1 +phy_port_primary_and_offset_41=0x1101 +portmap_42.0=17:1 +phy_port_primary_and_offset_42=0x1100 +portmap_43.0=20:1 +phy_port_primary_and_offset_43=0x1103 +portmap_44.0=19:1 +phy_port_primary_and_offset_44=0x1102 +portmap_45.0=22:1 +phy_port_primary_and_offset_45=0x1501 +portmap_46.0=21:1 +phy_port_primary_and_offset_46=0x1500 +portmap_47.0=24:1 +phy_port_primary_and_offset_47=0x1503 +portmap_48.0=23:1 +phy_port_primary_and_offset_48=0x1502 + +#PM4x10Q0 +portmap_1.0=26:1 +portmap_2.0=25:1 +portmap_3.0=28:1 +portmap_4.0=27:1 +portmap_5.0=30:1 +portmap_6.0=29:1 +portmap_7.0=32:1 +portmap_8.0=31:1 +phy_port_primary_and_offset_2=0x1900 +phy_port_primary_and_offset_1=0x1901 +phy_port_primary_and_offset_4=0x1902 +phy_port_primary_and_offset_3=0x1903 +phy_port_primary_and_offset_6=0x1904 +phy_port_primary_and_offset_5=0x1905 +phy_port_primary_and_offset_8=0x1906 +phy_port_primary_and_offset_7=0x1907 +port_phy_addr_2=0x01 +port_phy_addr_1=0x02 +port_phy_addr_4=0x03 +port_phy_addr_3=0x04 +port_phy_addr_6=0x05 +port_phy_addr_5=0x06 +port_phy_addr_8=0x07 +port_phy_addr_7=0x08 + +portmap_9.0=34:1 +portmap_10.0=33:1 +portmap_11.0=36:1 +portmap_12.0=35:1 +portmap_13.0=38:1 +portmap_14.0=37:1 +portmap_15.0=40:1 +portmap_16.0=39:1 + +phy_port_primary_and_offset_10=0x2100 +phy_port_primary_and_offset_9=0x2101 +phy_port_primary_and_offset_12=0x2102 +phy_port_primary_and_offset_11=0x2103 +phy_port_primary_and_offset_14=0x2104 +phy_port_primary_and_offset_13=0x2105 +phy_port_primary_and_offset_16=0x2106 +phy_port_primary_and_offset_15=0x2107 +port_phy_addr_10=0x2a +port_phy_addr_9=0x2b +port_phy_addr_12=0x2c +port_phy_addr_11=0x2d +port_phy_addr_14=0x2e +port_phy_addr_13=0x2f +port_phy_addr_16=0x30 +port_phy_addr_15=0x31 + +#PM4x10Q1 +portmap_17.0=42:1 +portmap_18.0=41:1 +portmap_19.0=44:1 +portmap_20.0=43:1 +portmap_21.0=50:1 +portmap_22.0=49:1 +portmap_23.0=52:1 +portmap_24.0=51:1 + +phy_port_primary_and_offset_18=0x2900 +phy_port_primary_and_offset_17=0x2901 +phy_port_primary_and_offset_20=0x2902 +phy_port_primary_and_offset_19=0x2903 +phy_port_primary_and_offset_22=0x2904 +phy_port_primary_and_offset_21=0x2905 +phy_port_primary_and_offset_24=0x2906 +phy_port_primary_and_offset_23=0x2907 +port_phy_addr_18=0x53 +port_phy_addr_17=0x54 +port_phy_addr_20=0x55 +port_phy_addr_19=0x56 +port_phy_addr_22=0x57 +port_phy_addr_21=0x58 +port_phy_addr_24=0x59 +port_phy_addr_23=0x5a + +#PM4x25 +portmap_49.0=60:10 +portmap_50.0=58:10 +portmap_51.0=59:10 +portmap_52.0=57:10 + +##PM4x10HG +portmap_53.0=62:10 +portmap_54.0=64:10 +portmap_55.0=61:10 +portmap_56.0=63:10 + diff --git a/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/port_config.ini b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/port_config.ini new file mode 100644 index 000000000000..90ecfa4859ad --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/port_config.ini @@ -0,0 +1,57 @@ +# name lanes alias index speed autoneg +Ethernet0 26 Ethernet1/0/1 1 1000 1 +Ethernet1 25 Ethernet1/0/2 2 1000 1 +Ethernet2 28 Ethernet1/0/3 3 1000 1 +Ethernet3 27 Ethernet1/0/4 4 1000 1 +Ethernet4 30 Ethernet1/0/5 5 1000 1 +Ethernet5 29 Ethernet1/0/6 6 1000 1 +Ethernet6 32 Ethernet1/0/7 7 1000 1 +Ethernet7 31 Ethernet1/0/8 8 1000 1 +Ethernet8 34 Ethernet1/0/9 9 1000 1 +Ethernet9 33 Ethernet1/0/10 10 1000 1 +Ethernet10 36 Ethernet1/0/11 11 1000 1 +Ethernet11 35 Ethernet1/0/12 12 1000 1 +Ethernet12 38 Ethernet1/0/13 13 1000 1 +Ethernet13 37 Ethernet1/0/14 14 1000 1 +Ethernet14 40 Ethernet1/0/15 15 1000 1 +Ethernet15 39 Ethernet1/0/16 16 1000 1 +Ethernet16 42 Ethernet1/0/17 17 1000 1 +Ethernet17 41 Ethernet1/0/18 18 1000 1 +Ethernet18 44 Ethernet1/0/19 19 1000 1 +Ethernet19 43 Ethernet1/0/20 20 1000 1 +Ethernet20 50 Ethernet1/0/21 21 1000 1 +Ethernet21 49 Ethernet1/0/22 22 1000 1 +Ethernet22 52 Ethernet1/0/23 23 1000 1 +Ethernet23 51 Ethernet1/0/24 24 1000 1 +Ethernet24 2 Ethernet1/0/25 25 1000 1 +Ethernet25 1 Ethernet1/0/26 26 1000 1 +Ethernet26 4 Ethernet1/0/27 27 1000 1 +Ethernet27 3 Ethernet1/0/28 28 1000 1 +Ethernet28 6 Ethernet1/0/29 29 1000 1 +Ethernet29 5 Ethernet1/0/30 30 1000 1 +Ethernet30 8 Ethernet1/0/31 31 1000 1 +Ethernet31 7 Ethernet1/0/32 32 1000 1 +Ethernet32 10 Ethernet1/0/33 33 1000 1 +Ethernet33 9 Ethernet1/0/34 34 1000 1 +Ethernet34 12 Ethernet1/0/35 35 1000 1 +Ethernet35 11 Ethernet1/0/36 36 1000 1 +Ethernet36 14 Ethernet1/0/37 37 1000 1 +Ethernet37 13 Ethernet1/0/38 38 1000 1 +Ethernet38 16 Ethernet1/0/39 39 1000 1 +Ethernet39 15 Ethernet1/0/40 40 1000 1 +Ethernet40 18 Ethernet1/0/41 41 1000 1 +Ethernet41 17 Ethernet1/0/42 42 1000 1 +Ethernet42 20 Ethernet1/0/43 43 1000 1 +Ethernet43 19 Ethernet1/0/44 44 1000 1 +Ethernet44 22 Ethernet1/0/45 45 1000 1 +Ethernet45 21 Ethernet1/0/46 46 1000 1 +Ethernet46 24 Ethernet1/0/47 47 1000 1 +Ethernet47 23 Ethernet1/0/48 48 1000 1 +Ethernet48 60 Ethernet1/0/49 49 10000 0 +Ethernet49 58 Ethernet1/0/50 50 10000 0 +Ethernet50 59 Ethernet1/0/51 51 10000 0 +Ethernet51 57 Ethernet1/0/52 52 10000 0 +Ethernet52 62 Ethernet1/0/53 53 10000 0 +Ethernet53 64 Ethernet1/0/54 54 10000 0 +Ethernet54 61 Ethernet1/0/55 55 10000 0 +Ethernet55 63 Ethernet1/0/56 56 10000 0 diff --git a/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/sai.profile b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/sai.profile new file mode 100644 index 000000000000..2e5979fd112c --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/belgite.config.bcm diff --git a/device/celestica/x86_64-cel_belgite-r0/custom_led.bin b/device/celestica/x86_64-cel_belgite-r0/custom_led.bin new file mode 100644 index 0000000000000000000000000000000000000000..6973a4c9a73a6d0ee9eaac6150be92d1933ddf5b GIT binary patch literal 216 zcmV~$J5B;o06@_@A5t83?KOo>M$ga#MTOJbTnZ~R$z#gB_)Zh!bk_z z+kh;CjwN``X5JU$-{?bxQJt)o8=F({VHx&JguWE(8^wEmN;=wKk)hyPUv-6H51c_) zE%&_Gqgv5xKhAoknDP}q3<8`GCBiXbLL70(0YUcJqfLhv7B+X>bIU&z Cd?#W6 literal 0 HcmV?d00001 diff --git a/device/celestica/x86_64-cel_belgite-r0/default_sku b/device/celestica/x86_64-cel_belgite-r0/default_sku new file mode 100644 index 000000000000..3eeb370889f9 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/default_sku @@ -0,0 +1 @@ +CELESTICA-BELGITE t1 diff --git a/device/celestica/x86_64-cel_belgite-r0/installer.conf b/device/celestica/x86_64-cel_belgite-r0/installer.conf new file mode 100644 index 000000000000..9ec2292df5ef --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/installer.conf @@ -0,0 +1,4 @@ +CONSOLE_PORT=0x3f8 +CONSOLE_DEV=0 +CONSOLE_SPEED=115200 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog" diff --git a/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/Makefile b/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/Makefile new file mode 100755 index 000000000000..ddc700bfb87e --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/Makefile @@ -0,0 +1,24 @@ +# +# Copyright: (c) 2012 Broadcom Corp. +# All Rights Reserved. +# + +SDK = ../../../../sdk-all-6.5.16/ +export SDK + +ifeq (${SDK},) +# { +$(error environment variable SDK not set) +# } +endif + +INCDIR = -I${SDK}/include + +all: + arm-linux-gcc -O1 -g ${INCDIR} -mthumb -mcpu=cortex-m0 -c -o custom_led.o custom_led.c + arm-linux-ld -T custom_led.lds -Bstatic -nostdlib --entry 0 -EL -Map custom_led.map -o custom_led.elf custom_led.o + arm-linux-objcopy -O binary custom_led.elf custom_led.bin + +clean: + rm -rf *.elf *.o *.map *.bin + diff --git a/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.c b/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.c new file mode 100755 index 000000000000..92fe25f5b898 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.c @@ -0,0 +1,171 @@ +/* + * $Id: custom_led.c$ + * $Copyright: (c) 2019 Broadcom + * Broadcom Proprietary and Confidential. All rights reserved.$ + */ + +/****************************************************************************** +CMICX LED Interface has two RAM Banks, as shown below, Bank0(ACCUMULATION RAM) +for accumulation of status from ports and Bank1(PATTERN RAM) for writing +LED pattern. Both Bank0 and Bank1 are of 1024x16-bit, each row representing +one port. + + ACCUMULATION RAM (Bank 0) Pattern RAM (Bank1) + 15 0 15 0 + ------------------------------ ----------------------------- +Row 0 | Port1 status | | Port1 LED Pattern | + ------------------------------ ----------------------------- +Row 1 | Port2 status | | Port2 LED Pattern | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- +Row 127 | Port128 status | | Port128 LED Pattern | + ------------------------------ ----------------------------- +Row 128 | | | | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- +Row x | Port(x+1) status | | Port(x+1) LED Pattern | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- + | | | | + ------------------------------ ----------------------------- +Row 1022| Port1023 status | | Port1023 LED Pattern | + ------------------------------ ----------------------------- +Row 1023| Port1024 status | | Port1024 LED Pattern | + ------------------------------ ----------------------------- + +Format of Accumulation RAM: + + +Bits 15:9 8 7 6 5 4:3 2 1 0 + ------------------------------------------------------------------------ + | Reserved | Link | Link Up | Flow | Duplex | Speed | Col | Tx | Rx | + | | Enable| Status | Control| | | | | | + ------------------------------------------------------------------------ + +The custom handler in this file should read port status, for each port used, +from accumulation ram, and form required LED bit pattern in the Bank1 RAM +(pattern RAM) location corresponding to the port of interest. Note that +physical port numbers may differ from row number of LED RAM Banks. For +Trident3, Physical port numbers spread from 1 to 128 in 128x25G configuration + and corresponding LED rows spread from Row 0 to Row 127. + +There are five LED interfaces in CMICX based devices. Although single +interface can be used to output LED pattern for all ports, it is possible +that more than one interface can be used in the end system, e.g., LEDs for +some ports are connected to one LED interface-0 (i.e LED_CLK and LED_DATA), +while the rest of the ports are connected to LED interface-1. Accordingly, +custom handler MUST fill in start port, end port and width of pattern in the +soc_led_custom_handler_ctrl_t structure passsed to custom handler. The +example custom handler provided in this file has reference code for forming +two different LED patterns. Please refer to these patterns before writing your +own custom handler code. + +The soc_led_custom_handler_ctrl_t structure definition is available in +$SDK/include/shared/cmicfw/cmicx_led_public.h + +soc_led_custom_handler_ctrl_t structure also carries a point to array +port_speed[] of size equal to maximum ports in the system, e.g 128 in Trident3. +This array would have port speed for each port, as per bit mapping defined in +"soc_led_speed_t" in $SDK/include/shared/cmicfw/cmicx_led_public.h file. + +Here is an exception, please keep in mind: +1. For TH3, port status/speed of xe1 (physical port 258) is located in the + accumulation entry/speed array of physical port 259. + +******************************************************************************/ +#include + +#define ACTIVITY_TICKS 2 +#define READ_LED_ACCU_DATA(base, port) (*((uint16 *)(base + ((port - 1) * sizeof(uint32))))) +#define WRITE_LED_SEND_DATA(base, port, val) (*((uint16 *)(base + ((port - 1) * sizeof(uint32)))) = val) + +#define PORT_NUM_TOTAL 56 + +#define LED_GREEN_BICOLOR 0x2 //bit : 10 +#define LED_AMBER_BICOLOR 0x1 //bit : 01 +#define LED_OFF_BICOLOR 0x3 //bit : 11 + +unsigned short portmap[] = { + 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 49, 50, 51, 52, + 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 24, 23, 22, 21, + 20, 19, 18, 17, 16, 15, 14, 13, + 58, 60, 57, 59, 64, 62, 63, 61 +}; + + +/* + * Function: + * custom_led_handler + * Purpose: + * Timer event handler to accumulate, process and transmit led status + * Parameters: + * param - parameter added while registering the timer event. + * Returns: + * 0 on success + * Error code on failure + */ +void custom_led_handler(soc_led_custom_handler_ctrl_t *ctrl, + uint32 activity_count) +{ + unsigned short accu_val = 0, send_val = 0; + unsigned short port, physical_port; + + /* Physical port numbers to be used */ + for(port = 1; port <= PORT_NUM_TOTAL; port++) { + + physical_port = portmap[port-1]; + + /* Read value from led_ram bank0 */ + accu_val = READ_LED_ACCU_DATA(ctrl->accu_ram_base, physical_port); + + send_val = 0xff; + + if (((accu_val & LED_OUTPUT_RX) || (accu_val & LED_OUTPUT_TX)) && (activity_count & ACTIVITY_TICKS)) + { + send_val = LED_OFF_BICOLOR; + } + else if ( accu_val & LED_OUTPUT_LINK_UP) + { + send_val = LED_GREEN_BICOLOR; + } + else + { + send_val = LED_OFF_BICOLOR; + } + + /* Write value to led_ram bank1 */ + WRITE_LED_SEND_DATA(ctrl->pat_ram_base, port, send_val); + } /* for */ + + /* Send the pattern over LED interface 1 for ports 1 - 56*/ + ctrl->intf_ctrl[1].valid = 1; + ctrl->intf_ctrl[1].start_row = 0; + ctrl->intf_ctrl[1].end_row = 55; + ctrl->intf_ctrl[1].pat_width = 2; + + /* Invalidate rest of the interfaces */ + ctrl->intf_ctrl[0].valid = 0; + ctrl->intf_ctrl[2].valid = 0; + ctrl->intf_ctrl[3].valid = 0; + ctrl->intf_ctrl[4].valid = 0; + + return; + +} + diff --git a/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.lds b/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.lds new file mode 100755 index 000000000000..8f585404e6b5 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/led-source-code/cmicx/custom_led.lds @@ -0,0 +1,21 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(custom_led_handler) +SECTIONS +{ + . = 0x3800; + + . = ALIGN(4); + .text : + { + *(.text) + *(.data) + *(.bss) + } + + /DISCARD/ : { *(.dynstr*) } + /DISCARD/ : { *(.dynamic*) } + /DISCARD/ : { *(.plt*) } + /DISCARD/ : { *(.interp*) } + /DISCARD/ : { *(.gnu*) } +} diff --git a/device/celestica/x86_64-cel_belgite-r0/led_proc_init.soc b/device/celestica/x86_64-cel_belgite-r0/led_proc_init.soc new file mode 100644 index 000000000000..f7192c5b081c --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/led_proc_init.soc @@ -0,0 +1,3 @@ +m0 load 0 0x3800 /usr/share/sonic/platform/custom_led.bin +led start + diff --git a/device/celestica/x86_64-cel_belgite-r0/media_settings.json b/device/celestica/x86_64-cel_belgite-r0/media_settings.json new file mode 100644 index 000000000000..50f7c545f09e --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/media_settings.json @@ -0,0 +1,49 @@ +{ + "GLOBAL_MEDIA_SETTINGS": { + "49-52": { + "Default": { + "preemphasis": { + "lane0": "0x14410a" + } + }, + "TERALUX-ABS022,SFP+-CR-1.0,TERALUX-ABS023,SFP+-CR-3.0,TERALUX-ABS074,SFP+-CR-5.0": { + "preemphasis": { + "lane0": "0x14410a" + } + }, + "TERALUX-ABS661,SFP+-CR-7.0": { + "preemphasis": { + "lane0": "0x14410a" + } + }, + "FINISAR CORP.-FTLX8571D3BCV,SFP+-SR": { + "preemphasis": { + "lane0": "0x0c4104" + } + } + }, + "53-56": { + "Default": { + "preemphasis": { + "lane0": "0x0a3200" + } + }, + "TERALUX-ABS022,SFP+-CR-1.0,TERALUX-ABS023,SFP+-CR-3.0,TERALUX-ABS074,SFP+-CR-5.0": { + "preemphasis": { + "lane0": "0x0a280a" + } + }, + "TERALUX-ABS661,SFP+-CR-7.0": { + "preemphasis": { + "lane0": "0x0f2805" + } + }, + "FINISAR CORP.-FTLX8571D3BCV,SFP+-SR": { + "preemphasis": { + "lane0": "0x0a3200" + } + } + } + } +} + diff --git a/device/celestica/x86_64-cel_belgite-r0/pcie.yaml b/device/celestica/x86_64-cel_belgite-r0/pcie.yaml new file mode 100644 index 000000000000..46e202526716 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/pcie.yaml @@ -0,0 +1,121 @@ +- bus: '00' + dev: '00' + fn: '0' + id: 1980 + name: 'Host bridge: Intel Corporation Atom Processor C3000 Series System Agent' +- bus: '00' + dev: '04' + fn: '0' + id: 19a1 + name: 'Host bridge: Intel Corporation Atom Processor C3000 Series Error Registers' +- bus: '00' + dev: '05' + fn: '0' + id: 19a2 + name: 'Generic system peripheral [0807]: Intel Corporation Atom Processor C3000 Series Root Complex Event Collector' +- bus: '00' + dev: '06' + fn: '0' + id: 19e2 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated QAT Root Port' +- bus: '00' + dev: '09' + fn: '0' + id: b277 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root Port' +- bus: '00' + dev: '0b' + fn: '0' + id: 1533 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root Port' +- bus: '00' + dev: '0e' + fn: '0' + id: 19a8 + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series PCI Express Root Port' +- bus: '00' + dev: '12' + fn: '0' + id: 19ac + name: 'System peripheral: Intel Corporation DNV SMBus Contoller - Host' +- bus: '00' + dev: '14' + fn: '0' + id: 19c2 + name: 'SATA controller: Intel Corporation DNV SATA Controller 1' +- bus: '00' + dev: '15' + fn: '0' + id: 19d0 + name: 'USB controller: Intel Corporation Atom Processor C3000 Series USB 3.0 xHCI Controller' +- bus: '00' + dev: '16' + fn: '0' + id: 15ce + name: 'PCI bridge: Intel Corporation Atom Processor C3000 Series Integrated LAN Root Port' +- bus: '00' + dev: '18' + fn: '0' + id: 19d3 + name: 'Communication controller: Intel Corporation Atom Processor C3000 Series ME HECI 1' +- bus: '00' + dev: '1a' + fn: '0' + id: 19d8 + name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller' +- bus: '00' + dev: '1a' + fn: '1' + id: 19d8 + name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller' +- bus: '00' + dev: '1a' + fn: '2' + id: 19d8 + name: 'Serial controller: Intel Corporation Atom Processor C3000 Series HSUART Controller' +- bus: '00' + dev: '1f' + fn: '0' + id: 19dc + name: 'ISA bridge: Intel Corporation DNV LPC or eSPI' +- bus: '00' + dev: '1f' + fn: '2' + id: 19de + name: 'Memory controller: Intel Corporation Atom Processor C3000 Series Power Management Controller' +- bus: '00' + dev: '1f' + fn: '4' + id: 19df + name: 'SMBus: Intel Corporation DNV SMBus controller' +- bus: '00' + dev: '1f' + fn: '5' + id: 19e0 + name: 'Serial bus controller [0c80]: Intel Corporation DNV SPI Controller' +- bus: '01' + dev: '00' + fn: '0' + id: 19e2 + name: 'Co-processor: Intel Corporation Atom Processor C3000 Series QuickAssist Technology' +- bus: '02' + dev: '00' + fn: '0' + id: b277 + name: 'Ethernet controller: Broadcom Limited Device b277' +- bus: '03' + dev: '00' + fn: '0' + id: 1533 + name: 'Ethernet controller: Intel Corporation I210 Gigabit Network Connection' +- bus: '05' + dev: '00' + fn: '0' + id: 15ce + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 10 GbE SFP+' +- bus: '05' + dev: '00' + fn: '1' + id: 15ce + name: 'Ethernet controller: Intel Corporation Ethernet Connection X553 10 GbE SFP+' + diff --git a/device/celestica/x86_64-cel_belgite-r0/pddf/pd-plugin.json b/device/celestica/x86_64-cel_belgite-r0/pddf/pd-plugin.json new file mode 100644 index 000000000000..05d724f3622b --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/pddf/pd-plugin.json @@ -0,0 +1,61 @@ +{ + "XCVR": + { + "xcvr_present": + { + "i2c": + { + "valmap-SFP28": {"1":false, "0":true } + } + } + }, + "PSU": + { + "psu_present": + { + "i2c": + { + "valmap": { "1":true, "0":false } + } + }, + "psu_power_good": + { + "i2c": + { + "valmap": { "0": true, "1":false } + } + }, + "psu_fan_dir": + { + "i2c": + { + "valmap": { "F2B":"INTAKE", "B2F":"EXHAUST" } + } + }, + "PSU_FAN_MAX_SPEED":"18000" + }, + "FAN": + { + "direction": + { + "i2c": + { + "valmap": {"1":"EXHAUST", "0":"INTAKE"} + } + }, + "present": + { + "i2c": + { + "valmap": {"1":false, "0":true} + } + }, + "fan_master_led_color": + { + "colmap": {"green":"green", "red":"amber"} + }, + "duty_cycle_to_pwm": "lambda dc: dc*255/100", + + "pwm_to_duty_cycle": "lambda pwm: pwm/255*100" + } +} diff --git a/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json b/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json new file mode 100644 index 000000000000..7ccbd41fffea --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json @@ -0,0 +1,685 @@ +{ + "PLATFORM": + { + "num_psus":2, + "num_fantrays":3, + "num_fans_pertray":1, + "num_ports":56, + "num_temps":4, + "pddf_dev_types": + { + "description":"Belgite - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", + "CPLD": + [ + "i2c_cpld" + ], + "PSU": + [ + "psu_eeprom", + "psu_pmbus" + ], + "FAN": + [ + "fan_ctrl", + "fan_eeprom", + "fan_cpld" + ], + "PORT_MODULE": + [ + "pddf_xcvr" + ] + }, + "std_perm_kos": + [ + "i2c-ismt", + "i2c-i801" + ], + "std_kos": + [ + "i2c_dev", + "i2c_mux_pca954x force_deselect_on_exit=1", + "gpio_pca953x", + "mc24lc64t", + "optoe" + ], + "pddf_kos": + [ + "pddf_client_module", + "pddf_mux_module", + "pddf_psu_driver_module", + "pddf_psu_module", + "pddf_gpio_module", + "pddf_xcvr_module", + "pddf_xcvr_driver_module", + "pddf_led_module", + "pddf_fan_driver_module", + "pddf_fan_module", + "pddf_led_module" + ], + "custom_kos": + [ + "pddf_custom_psu", + "pddf_custom_wdt" + ] + }, + "SYSTEM": + { + "dev_info": {"device_type":"CPU", "device_name":"ROOT_COMPLEX", "device_parent":null}, + "i2c": + { + "CONTROLLERS": + [ + { "dev_name":"i2c-0", "dev":"SMBUS0" } + ] + } + }, + "SMBUS0": + { + "dev_info": {"device_type": "SMBUS", "device_name": "SMBUS0", "device_parent": "SYSTEM"}, + "i2c": + { + "topo_info": {"dev_addr": "0x0"}, + "DEVICES": + [ + {"dev": "EEPROM1"}, + {"dev": "MUX1"} + ] + } + }, + "EEPROM1": + { + "dev_info": {"device_type": "EEPROM", "device_name": "EEPROM1", "device_parent": "SMBUS0"}, + "i2c": + { + "topo_info": {"parent_bus": "0x0", "dev_addr": "0x52", "dev_type": "24lc64t"}, + "dev_attr": {"access_mode": "BLOCK"}, + "attr_list": + [ + {"attr_name": "eeprom"} + ] + } + }, + "MUX1": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX1", "device_parent":"SMBUS0"}, + "i2c": + { + "topo_info": { "parent_bus":"0x0", "dev_addr":"0x70", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x2"}, + "channel": + [ + {"chn":"0", "dev":"CPLD1" }, + {"chn":"0", "dev":"FAN-CTRL" }, + {"chn":"2", "dev":"PSU1" }, + {"chn":"2", "dev":"PSU2" }, + {"chn":"3", "dev":"TEMP1"}, + {"chn":"3", "dev":"TEMP2"}, + {"chn":"4", "dev":"TEMP3"}, + {"chn":"4", "dev":"TEMP4"}, + {"chn":"7", "dev":"MUX2"} + ] + } + }, + "MUX2": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX2", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x9", "dev_addr":"0x71", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0xA"}, + "channel": + [ + {"chn":"0", "dev":"PORT49"}, + {"chn":"1", "dev":"PORT50"}, + {"chn":"2", "dev":"PORT51"}, + {"chn":"3", "dev":"PORT52"}, + {"chn":"4", "dev":"PORT53"}, + {"chn":"5", "dev":"PORT54"}, + {"chn":"6", "dev":"PORT55"}, + {"chn":"7", "dev":"PORT56"} + ] + } + }, + "CPLD1": + { + "dev_info": {"device_type": "CPLD", "device_name": "CPLD1", "device_parent": "MUX1"}, + "i2c": + { + "topo_info": {"parent_bus": "0x2", "dev_addr": "0x32", "dev_type": "i2c_cpld"}, + "dev_attr": {} + } + }, + "PSU1": + { + "dev_info": { "device_type":"PSU", "device_name":"PSU1", "device_parent":"MUX1"}, + "dev_attr": { "dev_idx":"1", "num_psu_fans": "1"}, + "i2c": + { + "interface": + [ + { "itf":"pmbus", "dev":"PSU1-PMBUS" } + ] + } + }, + "PSU1-PMBUS": + { + "dev_info": { "device_type":"PSU-PMBUS", "device_name":"PSU1-PMBUS", "device_parent":"MUX1", "virt_parent":"PSU1"}, + "i2c": + { + "topo_info":{ "parent_bus":"0x4", "dev_addr":"0x58", "dev_type":"psu_pmbus"}, + "attr_list": + [ + { "attr_name":"psu_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x41", "attr_mask":"0x10", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_power_good", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x41", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_model_name", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x9a", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"13" }, + { "attr_name":"psu_mfr_id", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"11" }, + { "attr_name":"psu_serial_num", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x9e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"14" }, + { "attr_name":"psu_v_in", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x88", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_in", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x89", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xc5", "attr_mask":"0x18", "attr_cmpval":"0x08", "attr_len":"1"}, + { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + ] + } + }, + "PSU2": + { + "dev_info": { "device_type":"PSU", "device_name":"PSU2", "device_parent":"MUX1" }, + "dev_attr": { "dev_idx":"2", "num_psu_fans":"1"}, + "i2c": + { + "interface": + [ + { "itf":"pmbus", "dev":"PSU2-PMBUS"} + ] + } + }, + "PSU2-PMBUS": + { + "dev_info": {"device_type":"PSU-PMBUS", "device_name":"PSU2-PMBUS", "device_parent":"MUX1", "virt_parent":"PSU2"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4", "dev_addr":"0x59", "dev_type":"psu_pmbus"}, + "attr_list": + [ + { "attr_name":"psu_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x41", "attr_mask":"0x20", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_power_good", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x41", "attr_mask":"0x8", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_model_name", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x9a", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"13" }, + { "attr_name":"psu_mfr_id", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"11" }, + { "attr_name":"psu_serial_num", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x9e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"14" }, + { "attr_name":"psu_v_in", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x88", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_in", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x89", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xc5", "attr_mask":"0x18", "attr_cmpval":"0x08", "attr_len":"1"}, + { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + ] + } + }, + "TEMP1": + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP1", "device_parent":"MUX1"}, + "dev_attr": { "display_name":"LM75_U10"}, + "i2c": + { + "topo_info": { "parent_bus":"0x5", "dev_addr":"0x48", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP2": + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP2", "device_parent":"MUX1"}, + "dev_attr": { "display_name":"LM75_U4"}, + "i2c": + { + "topo_info": { "parent_bus":"0x5", "dev_addr":"0x49", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP3": + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP3", "device_parent":"MUX1"}, + "dev_attr": { "display_name":"LM75_U7"}, + "i2c": + { + "topo_info": { "parent_bus":"0x6", "dev_addr":"0x4a", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP4": + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP4", "device_parent":"MUX1"}, + "dev_attr": { "display_name":"LM75_U60"}, + "i2c": + { + "topo_info": { "parent_bus":"0x6", "dev_addr":"0x49", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "PORT49": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT49", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"49"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT49-EEPROM" }, + { "itf":"control", "dev":"PORT49-CTRL" } + ] + } + }, + "PORT49-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT49-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT49"}, + "i2c": + { + "topo_info": { "parent_bus":"0xA", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT49-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT49-CTRL", "device_parent":"MUX2", "virt_parent":"PORT49"}, + "i2c": + { + "topo_info": { "parent_bus":"0xA", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + "PORT50": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT50", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"50"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT50-EEPROM" }, + { "itf":"control", "dev":"PORT50-CTRL" } + ] + } + }, + "PORT50-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT50-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT50"}, + "i2c": + { + "topo_info": { "parent_bus":"0xB", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT50-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT50-CTRL", "device_parent":"MUX2", "virt_parent":"PORT50"}, + "i2c": + { + "topo_info": { "parent_bus":"0xB", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + + ] + } + }, + "PORT51": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT51", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"51"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT51-EEPROM" }, + { "itf":"control", "dev":"PORT51-CTRL" } + ] + } + }, + "PORT51-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT51-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT51"}, + "i2c": + { + "topo_info": { "parent_bus":"0xC", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT51-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT51-CTRL", "device_parent":"MUX2", "virt_parent":"PORT51"}, + "i2c": + { + "topo_info": { "parent_bus":"0xC", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + "PORT52": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT52", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"52"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT52-EEPROM" }, + { "itf":"control", "dev":"PORT52-CTRL" } + ] + } + }, + "PORT52-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT52-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT52"}, + "i2c": + { + "topo_info": { "parent_bus":"0xD", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT52-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT52-CTRL", "device_parent":"MUX2", "virt_parent":"PORT52"}, + "i2c": + { + "topo_info": { "parent_bus":"0xD", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + + ] + } + }, + "PORT53": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT53", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"53"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT53-EEPROM" }, + { "itf":"control", "dev":"PORT53-CTRL" } + ] + } + }, + "PORT53-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT53-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT53"}, + "i2c": + { + "topo_info": { "parent_bus":"0xE", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT53-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT53-CTRL", "device_parent":"MUX2", "virt_parent":"PORT53"}, + "i2c": + { + "topo_info": { "parent_bus":"0xE", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + + ] + } + }, + "PORT54": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT54", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"54"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT54-EEPROM" }, + { "itf":"control", "dev":"PORT54-CTRL" } + ] + } + }, + "PORT54-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT54-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT54"}, + "i2c": + { + "topo_info": { "parent_bus":"0xF", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT54-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT54-CTRL", "device_parent":"MUX2", "virt_parent":"PORT54"}, + "i2c": + { + "topo_info": { "parent_bus":"0xF", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + "PORT55": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT55", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"55"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT55-EEPROM" }, + { "itf":"control", "dev":"PORT55-CTRL" } + ] + } + }, + "PORT55-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT55-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT55"}, + "i2c": + { + "topo_info": { "parent_bus":"0x10", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT55-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT55-CTRL", "device_parent":"MUX2", "virt_parent":"PORT55"}, + "i2c": + { + "topo_info": { "parent_bus":"0x10", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"} + ] + } + }, + "PORT56": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT56", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"56"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT56-EEPROM" }, + { "itf":"control", "dev":"PORT56-CTRL" } + ] + } + }, + "PORT56-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT56-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT56"}, + "i2c": + { + "topo_info": { "parent_bus":"0x11", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT56-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT56-CTRL", "device_parent":"MUX2", "virt_parent":"PORT56"}, + "i2c": + { + "topo_info": { "parent_bus":"0x11", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"} + ] + } + }, + "FAN-CTRL": + { + "dev_info": { "device_type":"FAN", "device_name":"FAN-CTRL", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2", "dev_addr":"0x66", "dev_type":"fan_cpld"}, + "dev_attr": { "num_fantrays":"3"}, + "attr_list": + [ + { "attr_name":"fan1_pwm", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x32", "attr_mask":"0xff", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan2_pwm", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x36", "attr_mask":"0xff", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan3_pwm", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x3a", "attr_mask":"0xff", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan1_direction", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x88", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan2_direction", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x88", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan3_direction", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x88", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan1_input", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x31", "attr_mask":"0xff", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0}, + { "attr_name":"fan2_input", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x35", "attr_mask":"0xff", "attr_len":"1", "attr_mult":"150" , "attr_is_divisor":0}, + { "attr_name":"fan3_input", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x39", "attr_mask":"0xff", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0} + ] + } + }, + "SYS_LED": + { + "dev_info": { "device_type":"LED", "device_name":"SYS_LED"}, + "dev_attr": { "index":"0"}, + "i2c" : { + "attr_list": + [ + {"attr_name":"STATUS_LED_COLOR_AMBER","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x1","swpld_addr_offset":"0x43"}, + {"attr_name":"STATUS_LED_COLOR_GREEN","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x2","swpld_addr_offset":"0x43"}, + {"attr_name":"STATUS_LED_COLOR_OFF","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x0","swpld_addr_offset":"0x43"} + ] + } + }, + "FANTRAY1_LED": + { + "dev_info": { "device_type":"LED", "device_name":"FANTRAY_LED"}, + "dev_attr": { "index":"0"}, + "i2c" : { + "attr_list": + [ + {"attr_name":"STATUS_LED_COLOR_GREEN","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x1","swpld_addr":"0x32","swpld_addr_offset":"0x33"}, + {"attr_name":"STATUS_LED_COLOR_AMBER","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x2","swpld_addr":"0x32","swpld_addr_offset":"0x33"} + ] + } + }, + "FANTRAY2_LED": + { + "dev_info": { "device_type":"LED", "device_name":"FANTRAY_LED"}, + "dev_attr": { "index":"1"}, + "i2c" : { + "attr_list": + [ + {"attr_name":"STATUS_LED_COLOR_GREEN","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x1","swpld_addr":"0x32","swpld_addr_offset":"0x37"}, + {"attr_name":"STATUS_LED_COLOR_AMBER","attr_devtype":"cpld","attr_devname":"CPLD1B","bits":"1:0","descr":"","value":"0x2","swpld_addr":"0x32","swpld_addr_offset":"0x37"} + ] + } + }, + "FANTRAY3_LED": + { + "dev_info": { "device_type":"LED", "device_name":"FANTRAY_LED"}, + "dev_attr": { "index":"2"}, + "i2c" : { + "attr_list": + [ + {"attr_name":"STATUS_LED_COLOR_GREEN","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x1","swpld_addr":"0x32","swpld_addr_offset":"0x3b"}, + {"attr_name":"STATUS_LED_COLOR_AMBER","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x2","swpld_addr":"0x32","swpld_addr_offset":"0x3b"} + ] + } + } +} diff --git a/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json.original b/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json.original new file mode 100644 index 000000000000..8f43a3f6090d --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/pddf/pddf-device.json.original @@ -0,0 +1,686 @@ +{ + "PLATFORM": + { + "num_psus":2, + "num_fantrays":3, + "num_fans_pertray":1, + "num_ports":56, + "num_temps":4, + "pddf_dev_types": + { + "description":"Belgite - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", + "CPLD": + [ + "i2c_cpld" + ], + "PSU": + [ + "psu_eeprom", + "psu_pmbus" + ], + "FAN": + [ + "fan_ctrl", + "fan_eeprom", + "fan_cpld" + ], + "PORT_MODULE": + [ + "pddf_xcvr" + ] + }, + "std_perm_kos": + [ + "i2c-ismt", + "i2c-i801" + ], + "std_kos": + [ + "i2c_dev", + "i2c_mux_pca954x", + "gpio_pca953x", + "mc24lc64t", + "optoe" + ], + "pddf_kos": + [ + "pddf_client_module", + "pddf_mux_module", + "pddf_psu_driver_module", + "pddf_psu_module", + "pddf_gpio_module", + "pddf_xcvr_module", + "pddf_xcvr_driver_module", + "pddf_led_module", + "pddf_fan_driver_module", + "pddf_fan_module", + "pddf_led_module" + ], + "custom_kos": + [ + "pddf_custom_psu" + ] + }, + "SYSTEM": + { + "dev_info": {"device_type":"CPU", "device_name":"ROOT_COMPLEX", "device_parent":null}, + "i2c": + { + "CONTROLLERS": + [ + { "dev_name":"i2c-0", "dev":"SMBUS0" } + ] + } + }, + "SMBUS0": + { + "dev_info": {"device_type": "SMBUS", "device_name": "SMBUS0", "device_parent": "SYSTEM"}, + "i2c": + { + "topo_info": {"dev_addr": "0x0"}, + "DEVICES": + [ + {"dev": "EEPROM1"}, + {"dev": "MUX1"} + ] + } + }, + "EEPROM1": + { + "dev_info": {"device_type": "EEPROM", "device_name": "EEPROM1", "device_parent": "SMBUS0"}, + "i2c": + { + "topo_info": {"parent_bus": "0x0", "dev_addr": "0x52", "dev_type": "24lc64t"}, + "dev_attr": {"access_mode": "BLOCK"}, + "attr_list": + [ + {"attr_name": "eeprom"} + ] + } + }, + "MUX1": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX1", "device_parent":"SMBUS0"}, + "i2c": + { + "topo_info": { "parent_bus":"0x0", "dev_addr":"0x70", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x2"}, + "channel": + [ + {"chn":"0", "dev":"CPLD1" }, + {"chn":"0", "dev":"FAN-CTRL1" }, + {"chn":"2", "dev":"PSU1" }, + {"chn":"2", "dev":"PSU2" }, + {"chn":"3", "dev":"TEMP1"}, + {"chn":"3", "dev":"TEMP2"}, + {"chn":"4", "dev":"TEMP3"}, + {"chn":"4", "dev":"TEMP4"}, + {"chn":"7", "dev":"MUX2"} + ] + } + }, + "MUX2": + { + "dev_info": { "device_type":"MUX", "device_name":"MUX2", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x9", "dev_addr":"0x71", "dev_type":"pca9548"}, + "dev_attr": { "virt_bus":"0x10"}, + "channel": + [ + {"chn":"0", "dev":"PORT49"}, + {"chn":"1", "dev":"PORT50"}, + {"chn":"2", "dev":"PORT51"}, + {"chn":"3", "dev":"PORT52"}, + {"chn":"4", "dev":"PORT53"}, + {"chn":"5", "dev":"PORT54"}, + {"chn":"6", "dev":"PORT55"}, + {"chn":"7", "dev":"PORT56"} + ] + } + }, + "CPLD1": + { + "dev_info": {"device_type": "CPLD", "device_name": "CPLD1", "device_parent": "MUX1"}, + "i2c": + { + "topo_info": {"parent_bus": "0x2", "dev_addr": "0x32", "dev_type": "i2c_cpld"}, + "dev_attr": {} + } + }, + "PSU1": + { + "dev_info": { "device_type":"PSU", "device_name":"PSU1", "device_parent":"MUX1"}, + "dev_attr": { "dev_idx":"1", "num_psu_fans": "1"}, + "i2c": + { + "interface": + [ + { "itf":"pmbus", "dev":"PSU1-PMBUS" } + ] + } + }, + "PSU1-PMBUS": + { + "dev_info": { "device_type":"PSU-PMBUS", "device_name":"PSU1-PMBUS", "device_parent":"MUX1", "virt_parent":"PSU1"}, + "i2c": + { + "topo_info":{ "parent_bus":"0x4", "dev_addr":"0x58", "dev_type":"psu_pmbus"}, + "attr_list": + [ + { "attr_name":"psu_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x41", "attr_mask":"0x10", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_power_good", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x41", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_model_name", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x9a", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"16" }, + { "attr_name":"psu_mfr_id", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"7" }, + { "attr_name":"psu_serial_num", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x9e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"16" }, + { "attr_name":"psu_v_in", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x88", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_in", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x89", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_in", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xa7", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0xc5", "attr_mask":"0x18", "attr_cmpval":"0x08", "attr_len":"1"}, + { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x58", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + ] + } + }, + "PSU2": + { + "dev_info": { "device_type":"PSU", "device_name":"PSU2", "device_parent":"MUX1" }, + "dev_attr": { "dev_idx":"2", "num_psu_fans":"1"}, + "i2c": + { + "interface": + [ + { "itf":"pmbus", "dev":"PSU2-PMBUS"} + ] + } + }, + "PSU2-PMBUS": + { + "dev_info": {"device_type":"PSU-PMBUS", "device_name":"PSU2-PMBUS", "device_parent":"MUX1", "virt_parent":"PSU2"}, + "i2c": + { + "topo_info": { "parent_bus":"0x4", "dev_addr":"0x59", "dev_type":"psu_pmbus"}, + "attr_list": + [ + { "attr_name":"psu_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x41", "attr_mask":"0x20", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_power_good", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x41", "attr_mask":"0x8", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"psu_model_name", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x9a", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"16" }, + { "attr_name":"psu_mfr_id", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"7" }, + { "attr_name":"psu_serial_num", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x9e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"16" }, + { "attr_name":"psu_v_in", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x88", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_in", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x89", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_in", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa7", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_i_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xc5", "attr_mask":"0x18", "attr_cmpval":"0x08", "attr_len":"1"}, + { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + ] + } + }, + "TEMP1": + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP1", "device_parent":"MUX1"}, + "dev_attr": { "display_name":"LM75_U10"}, + "i2c": + { + "topo_info": { "parent_bus":"0x5", "dev_addr":"0x48", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP2": + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP2", "device_parent":"MUX1"}, + "dev_attr": { "display_name":"LM75_U4"}, + "i2c": + { + "topo_info": { "parent_bus":"0x5", "dev_addr":"0x49", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP3": + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP3", "device_parent":"MUX1"}, + "dev_attr": { "display_name":"LM75_U7"}, + "i2c": + { + "topo_info": { "parent_bus":"0x6", "dev_addr":"0x4a", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "TEMP4": + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP4", "device_parent":"MUX1"}, + "dev_attr": { "display_name":"LM75_U60"}, + "i2c": + { + "topo_info": { "parent_bus":"0x6", "dev_addr":"0x49", "dev_type":"lm75"}, + "attr_list": + [ + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_max_hyst"}, + { "attr_name": "temp1_input"} + ] + } + }, + "PORT49": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT49", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"49"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT49-EEPROM" }, + { "itf":"control", "dev":"PORT49-CTRL" } + ] + } + }, + "PORT49-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT49-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT49"}, + "i2c": + { + "topo_info": { "parent_bus":"0x10", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT49-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT49-CTRL", "device_parent":"MUX2", "virt_parent":"PORT49"}, + "i2c": + { + "topo_info": { "parent_bus":"0x10", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x0", "attr_cmpval":"0x1", "attr_len":"1"} + ] + } + }, + "PORT50": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT50", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"50"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT50-EEPROM" }, + { "itf":"control", "dev":"PORT50-CTRL" } + ] + } + }, + "PORT50-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT50-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT50"}, + "i2c": + { + "topo_info": { "parent_bus":"0x11", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT50-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT50-CTRL", "device_parent":"MUX2", "virt_parent":"PORT50"}, + "i2c": + { + "topo_info": { "parent_bus":"0x11", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x1", "attr_cmpval":"0x2", "attr_len":"1"} + + ] + } + }, + "PORT51": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT51", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"51"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT51-EEPROM" }, + { "itf":"control", "dev":"PORT51-CTRL" } + ] + } + }, + "PORT51-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT51-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT51"}, + "i2c": + { + "topo_info": { "parent_bus":"0x12", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT51-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT51-CTRL", "device_parent":"MUX2", "virt_parent":"PORT51"}, + "i2c": + { + "topo_info": { "parent_bus":"0x12", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x2", "attr_cmpval":"0x4", "attr_len":"1"} + ] + } + }, + "PORT52": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT52", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"52"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT52-EEPROM" }, + { "itf":"control", "dev":"PORT52-CTRL" } + ] + } + }, + "PORT52-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT52-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT52"}, + "i2c": + { + "topo_info": { "parent_bus":"0x13", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT52-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT52-CTRL", "device_parent":"MUX2", "virt_parent":"PORT52"}, + "i2c": + { + "topo_info": { "parent_bus":"0x13", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x3", "attr_cmpval":"0x8", "attr_len":"1"} + + ] + } + }, + "PORT53": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT53", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"53"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT53-EEPROM" }, + { "itf":"control", "dev":"PORT53-CTRL" } + ] + } + }, + "PORT53-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT53-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT53"}, + "i2c": + { + "topo_info": { "parent_bus":"0x14", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT53-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT53-CTRL", "device_parent":"MUX2", "virt_parent":"PORT53"}, + "i2c": + { + "topo_info": { "parent_bus":"0x14", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x4", "attr_cmpval":"0x10", "attr_len":"1"} + + ] + } + }, + "PORT54": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT54", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"54"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT54-EEPROM" }, + { "itf":"control", "dev":"PORT54-CTRL" } + ] + } + }, + "PORT54-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT54-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT54"}, + "i2c": + { + "topo_info": { "parent_bus":"0x15", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT54-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT54-CTRL", "device_parent":"MUX2", "virt_parent":"PORT54"}, + "i2c": + { + "topo_info": { "parent_bus":"0x15", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x5", "attr_cmpval":"0x20", "attr_len":"1"} + ] + } + }, + "PORT55": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT55", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"55"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT55-EEPROM" }, + { "itf":"control", "dev":"PORT55-CTRL" } + ] + } + }, + "PORT55-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT55-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT55"}, + "i2c": + { + "topo_info": { "parent_bus":"0x16", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT55-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT55-CTRL", "device_parent":"MUX2", "virt_parent":"PORT55"}, + "i2c": + { + "topo_info": { "parent_bus":"0x16", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x6", "attr_cmpval":"0x40", "attr_len":"1"} + ] + } + }, + "PORT56": + { + "dev_info": { "device_type":"SFP28", "device_name":"PORT56", "device_parent":"MUX2"}, + "dev_attr": { "dev_idx":"56"}, + "i2c": + { + "interface": + [ + { "itf":"eeprom", "dev":"PORT56-EEPROM" }, + { "itf":"control", "dev":"PORT56-CTRL" } + ] + } + }, + "PORT56-EEPROM": + { + "dev_info": { "device_type":"", "device_name":"PORT56-EEPROM", "device_parent":"MUX2", "virt_parent":"PORT56"}, + "i2c": + { + "topo_info": { "parent_bus":"0x17", "dev_addr":"0x50", "dev_type":"optoe2"}, + "attr_list": + [ + { "attr_name":"eeprom"} + ] + } + }, + "PORT56-CTRL": + { + "dev_info": { "device_type":"", "device_name":"PORT56-CTRL", "device_parent":"MUX2", "virt_parent":"PORT56"}, + "i2c": + { + "topo_info": { "parent_bus":"0x17", "dev_addr":"0x66", "dev_type":"pddf_xcvr"}, + "attr_list": + [ + { "attr_name":"xcvr_txfault", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x47", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_txdisable", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_lpmode", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x4a", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_present", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x49", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"}, + { "attr_name":"xcvr_rxlos", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x48", "attr_mask":"0x7", "attr_cmpval":"0x80", "attr_len":"1"} + ] + } + }, + "FAN-CTRL1": + { + "dev_info": { "device_type":"FAN", "device_name":"FAN-CTRL1", "device_parent":"MUX1"}, + "i2c": + { + "topo_info": { "parent_bus":"0x2", "dev_addr":"0x66", "dev_type":"fan_cpld"}, + "dev_attr": { "num_fantrays":"3"}, + "attr_list": + [ + { "attr_name":"fan1_pwm", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x32", "attr_mask":"0xff", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan2_pwm", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x36", "attr_mask":"0xff", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan3_pwm", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x3a", "attr_mask":"0xff", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan1_direction", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x88", "attr_mask":"0x4", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan2_direction", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x88", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan3_direction", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x88", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, + { "attr_name":"fan1_input", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x31", "attr_mask":"0xff", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0}, + { "attr_name":"fan2_input", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x35", "attr_mask":"0xff", "attr_len":"1", "attr_mult":"150" , "attr_is_divisor":0}, + { "attr_name":"fan3_input", "attr_devaddr":"0x32", "attr_devtype":"cpld", "attr_devname":"CPLD1", "attr_offset":"0x39", "attr_mask":"0xff", "attr_len":"1", "attr_mult":"150", "attr_is_divisor":0} + ] + } + }, + "SYS_LED": + { + "dev_info": { "device_type":"LED", "device_name":"SYS_LED"}, + "dev_attr": { "index":"0", "flag": "rw"}, + "i2c" : { + "attr_list": + [ + {"attr_name":"amber","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x1","swpld_addr_offset":"0x43"}, + {"attr_name":"green","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x2","swpld_addr_offset":"0x43"}, + {"attr_name":"off","swpld_addr":"0x32","attr_devtype":"cpld","attr_devname":"CPLD1", "bits":"5:4","descr":"","value":"0x0","swpld_addr_offset":"0x43"} + ] + } + }, + "FANTRAY1_LED": + { + "dev_info": { "device_type":"LED", "device_name":"FANTRAY_LED"}, + "dev_attr": { "index":"0", "flag": "rw"}, + "i2c" : { + "attr_list": + [ + {"attr_name":"green","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x1","swpld_addr":"0x32","swpld_addr_offset":"0x33"}, + {"attr_name":"red","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x2","swpld_addr":"0x32","swpld_addr_offset":"0x33"} + ] + } + }, + "FANTRAY2_LED": + { + "dev_info": { "device_type":"LED", "device_name":"FANTRAY_LED"}, + "dev_attr": { "index":"1", "flag": "rw"}, + "i2c" : { + "attr_list": + [ + {"attr_name":"green","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x1","swpld_addr":"0x32","swpld_addr_offset":"0x37"}, + {"attr_name":"red","attr_devtype":"cpld","attr_devname":"CPLD1B","bits":"1:0","descr":"","value":"0x2","swpld_addr":"0x32","swpld_addr_offset":"0x37"} + ] + } + }, + "FANTRAY3_LED": + { + "dev_info": { "device_type":"LED", "device_name":"FANTRAY_LED"}, + "dev_attr": { "index":"2", "flag": "rw"}, + "i2c" : { + "attr_list": + [ + {"attr_name":"green","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x1","swpld_addr":"0x32","swpld_addr_offset":"0x3b"}, + {"attr_name":"red","attr_devtype":"cpld","attr_devname":"CPLD1","bits":"1:0","descr":"","value":"0x2","swpld_addr":"0x32","swpld_addr_offset":"0x3b"} + ] + } + } +} diff --git a/device/celestica/x86_64-cel_belgite-r0/pddf_support b/device/celestica/x86_64-cel_belgite-r0/pddf_support new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/device/celestica/x86_64-cel_belgite-r0/platform_asic b/device/celestica/x86_64-cel_belgite-r0/platform_asic new file mode 100644 index 000000000000..960467652765 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/platform_asic @@ -0,0 +1 @@ +broadcom diff --git a/device/celestica/x86_64-cel_belgite-r0/plugins/eeprom.py b/device/celestica/x86_64-cel_belgite-r0/plugins/eeprom.py new file mode 100644 index 000000000000..d28ff1d0cddb --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/plugins/eeprom.py @@ -0,0 +1,14 @@ +try: + import os + from sonic_eeprom import eeprom_tlvinfo +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +class board(eeprom_tlvinfo.TlvInfoDecoder): + _TLV_INFO_MAX_LEN = 256 + def __init__(self, name, path, cpld_root, ro): + self.eeprom_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/0-0052/eeprom" + #Two i2c buses might get flipped order, check them both. + if not os.path.exists(self.eeprom_path): + self.eeprom_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-1/1-0052/eeprom" + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/celestica/x86_64-cel_belgite-r0/pmon_daemon_control.json b/device/celestica/x86_64-cel_belgite-r0/pmon_daemon_control.json new file mode 100644 index 000000000000..689def2c1e25 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/pmon_daemon_control.json @@ -0,0 +1,4 @@ +{ + "skip_ledd": true, + "skip_pcied": true +} diff --git a/device/celestica/x86_64-cel_belgite-r0/system_health_monitoring_config.json b/device/celestica/x86_64-cel_belgite-r0/system_health_monitoring_config.json new file mode 100644 index 000000000000..4dc38d035ab4 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/system_health_monitoring_config.json @@ -0,0 +1,16 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [ + "asic", + "psu.temperature", + "PSU2 Fan", + "PSU1 Fan" + ], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "orange", + "normal": "green", + "booting": "orange_blink" + } +} \ No newline at end of file diff --git a/platform/broadcom/one-image.mk b/platform/broadcom/one-image.mk index debd52495512..0e794c86cb4a 100644 --- a/platform/broadcom/one-image.mk +++ b/platform/broadcom/one-image.mk @@ -52,6 +52,7 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ $(CEL_DX010_PLATFORM_MODULE) \ $(CEL_HALIBURTON_PLATFORM_MODULE) \ $(CEL_SEASTONE2_PLATFORM_MODULE) \ + $(CEL_BELGITE_PLATFORM_MODULE) \ $(DELTA_AG9032V1_PLATFORM_MODULE) \ $(DELTA_AG9064_PLATFORM_MODULE) \ $(DELTA_AG5648_PLATFORM_MODULE) \ diff --git a/platform/broadcom/platform-modules-cel.mk b/platform/broadcom/platform-modules-cel.mk index de021df7e4db..d485f128c6c2 100644 --- a/platform/broadcom/platform-modules-cel.mk +++ b/platform/broadcom/platform-modules-cel.mk @@ -4,11 +4,13 @@ CEL_DX010_PLATFORM_MODULE_VERSION = 0.9 CEL_HALIBURTON_PLATFORM_MODULE_VERSION = 0.9 CEL_SEASTONE2_PLATFORM_MODULE_VERSION = 0.9 CEL_SILVERSTONE_PLATFORM_MODULE_VERSION = 0.9 +CEL_BELGITE_PLATFORM_MODULE_VERSION = 0.9 export CEL_DX010_PLATFORM_MODULE_VERSION export CEL_HALIBURTON_PLATFORM_MODULE_VERSION export CEL_SEASTONE2_PLATFORM_MODULE_VERSION export CEL_SILVERSTONE_PLATFORM_MODULE_VERSION +export CEL_BELGITE_PLATFORM_MODULE_VERSION CEL_DX010_PLATFORM_MODULE = platform-modules-dx010_$(CEL_DX010_PLATFORM_MODULE_VERSION)_amd64.deb $(CEL_DX010_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-cel @@ -28,3 +30,6 @@ CEL_SILVERSTONE_PLATFORM_MODULE = platform-modules-silverstone_$(CEL_SILVERSTONE $(CEL_SILVERSTONE_PLATFORM_MODULE)_PLATFORM = x86_64-cel_silverstone-r0 $(eval $(call add_extra_package,$(CEL_DX010_PLATFORM_MODULE),$(CEL_SILVERSTONE_PLATFORM_MODULE))) +CEL_BELGITE_PLATFORM_MODULE = platform-modules-belgite_$(CEL_BELGITE_PLATFORM_MODULE_VERSION)_amd64.deb +$(CEL_BELGITE_PLATFORM_MODULE)_PLATFORM = x86_64-cel_belgite-r0 +$(eval $(call add_extra_package,$(CEL_DX010_PLATFORM_MODULE),$(CEL_BELGITE_PLATFORM_MODULE))) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile new file mode 100644 index 000000000000..a08f42daa95e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile @@ -0,0 +1 @@ +obj-m:= mc24lc64t.o pddf_custom_psu.o pddf_custom_wdt.o diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/mc24lc64t.c b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/mc24lc64t.c new file mode 100644 index 000000000000..49e9d8b21f8f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/mc24lc64t.c @@ -0,0 +1,174 @@ +/* + * mc24lc64t.c - driver for Microchip 24LC64T(TLV Eeprom) + * + * Copyright (C) 2017 Celestica Corp. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define EEPROM_SIZE 8192 //mc24lt64t eeprom size in bytes. + +struct mc24lc64t_data { + struct mutex update_lock; +}; + +static ssize_t mc24lc64t_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + struct i2c_client *client = kobj_to_i2c_client(kobj); + struct mc24lc64t_data *drvdata = i2c_get_clientdata(client); + unsigned long timeout, read_time, i = 0; + int status; + + mutex_lock(&drvdata->update_lock); + + if (i2c_smbus_write_byte_data(client, off>>8, off)) + { + status = -EIO; + goto exit; + } + + msleep(1); + +begin: + + if (i < count) + { + timeout = jiffies + msecs_to_jiffies(25); /* 25 mS timeout*/ + do { + read_time = jiffies; + + status = i2c_smbus_read_byte(client); + if (status >= 0) + { + buf[i++] = status; + goto begin; + } + } while (time_before(read_time, timeout)); + + status = -ETIMEDOUT; + goto exit; + } + + status = count; + +exit: + mutex_unlock(&drvdata->update_lock); + + return status; +} + +static ssize_t mc24lc64t_write (struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count){ + + struct i2c_client *client = kobj_to_i2c_client(kobj); + struct mc24lc64t_data *drvdata = i2c_get_clientdata(client); + unsigned long timeout, write_time, i = 0; + int status; + u16 value; + + mutex_lock(&drvdata->update_lock); + +begin: + if (i < count){ + timeout = jiffies + msecs_to_jiffies(25); /* 25 mS timeout*/ + value = (buf[i] << 8 | ( off &0xff)); + do { + write_time = jiffies; + status = i2c_smbus_write_word_data(client, off>>8, value); + if (status >= 0) + { + // increase offset + off++; + // increase buffer index + i++; + goto begin; + } + } while (time_before(write_time, timeout)); + status = -ETIMEDOUT; + goto exit; + } + status = count; + +exit: + mutex_unlock(&drvdata->update_lock); + return status; +} + + +static struct bin_attribute mc24lc64t_bit_attr = { + .attr = { + .name = "eeprom", + .mode = S_IRUGO | S_IWUGO, + }, + .size = EEPROM_SIZE, + .read = mc24lc64t_read, + .write = mc24lc64t_write, +}; + +static int mc24lc64t_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adapter = client->adapter; + struct mc24lc64t_data *drvdata; + int err; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA + | I2C_FUNC_SMBUS_READ_BYTE)) + return -EPFNOSUPPORT; + + if (!(drvdata = devm_kzalloc(&client->dev, + sizeof(struct mc24lc64t_data), GFP_KERNEL))) + return -ENOMEM; + + i2c_set_clientdata(client, drvdata); + mutex_init(&drvdata->update_lock); + + err = sysfs_create_bin_file(&client->dev.kobj, &mc24lc64t_bit_attr); + return err; +} + +static int mc24lc64t_remove(struct i2c_client *client) +{ + struct mc24lc64t_data *drvdata = i2c_get_clientdata(client); + sysfs_remove_bin_file(&client->dev.kobj, &mc24lc64t_bit_attr); + + return 0; +} + +static const struct i2c_device_id mc24lc64t_id[] = { + { "24lc64t", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, mc24lc64t_id); + +static struct i2c_driver mc24lc64t_driver = { + .driver = { + .name = "mc24lc64t", + .owner = THIS_MODULE, + }, + .probe = mc24lc64t_probe, + .remove = mc24lc64t_remove, + .id_table = mc24lc64t_id, +}; + +module_i2c_driver(mc24lc64t_driver); + +MODULE_AUTHOR("Abhisit Sangjan "); +MODULE_DESCRIPTION("Microchip 24LC64T Driver"); +MODULE_LICENSE("GPL"); + diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_psu.c b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_psu.c new file mode 100644 index 000000000000..3c5e5872aa2e --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_psu.c @@ -0,0 +1,125 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../../../pddf/i2c/modules/include/pddf_psu_defs.h" + +#define PSU_REG_VOUT_MODE 0x20 +#define PSU_REG_READ_VOUT 0x8b + +ssize_t pddf_show_custom_psu_v_out(struct device *dev, struct device_attribute *da, char *buf); +extern PSU_SYSFS_ATTR_DATA access_psu_v_out; + +static int two_complement_to_int(u16 data, u8 valid_bit, int mask) +{ + u16 valid_data = data & mask; + bool is_negative = valid_data >> (valid_bit - 1); + + return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data; +} + +static u8 psu_get_vout_mode(struct i2c_client *client) +{ + u8 status = 0, retry = 10; + uint8_t offset = PSU_REG_VOUT_MODE; + + while (retry) { + status = i2c_smbus_read_byte_data((struct i2c_client *)client, offset); + if (unlikely(status < 0)) { + msleep(60); + retry--; + continue; + } + break; + } + + if (status < 0) + { + printk(KERN_ERR "%s: Get PSU Vout mode failed\n", __func__); + return 0; + } + else + { + /*printk(KERN_ERR "%s: vout_mode reg value 0x%x\n", __func__, status);*/ + return status; + } +} + +static u16 psu_get_v_out(struct i2c_client *client) +{ + u16 status = 0, retry = 10; + uint8_t offset = PSU_REG_READ_VOUT; + + while (retry) { + status = i2c_smbus_read_word_data((struct i2c_client *)client, offset); + if (unlikely(status < 0)) { + msleep(60); + retry--; + continue; + } + break; + } + + if (status < 0) + { + printk(KERN_ERR "%s: Get PSU Vout failed\n", __func__); + return 0; + } + else + { + /*printk(KERN_ERR "%s: vout reg value 0x%x\n", __func__, status);*/ + return status; + } +} + +ssize_t pddf_show_custom_psu_v_out(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + int exponent, mantissa; + int multiplier = 1000; + + u16 value = psu_get_v_out(client); + u8 vout_mode = psu_get_vout_mode(client); + + if ((vout_mode >> 5) == 0) + exponent = two_complement_to_int(vout_mode & 0x1f, 5, 0x1f); + else + { + /*printk(KERN_ERR "%s: Only support linear mode for vout mode\n", __func__);*/ + exponent = 0; + } + mantissa = value; + if (exponent >= 0) + return sprintf(buf, "%d\n", (mantissa << exponent) * multiplier); + else + return sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); +} + + + +static int __init pddf_custom_psu_init(void) +{ + access_psu_v_out.show = pddf_show_custom_psu_v_out; + access_psu_v_out.do_get = NULL; + return 0; +} + +static void __exit pddf_custom_psu_exit(void) +{ + return; +} + +MODULE_AUTHOR("Broadcom"); +MODULE_DESCRIPTION("pddf custom psu api"); +MODULE_LICENSE("GPL"); + +module_init(pddf_custom_psu_init); +module_exit(pddf_custom_psu_exit); diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c new file mode 100644 index 000000000000..a60f92031a0c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c @@ -0,0 +1,734 @@ +/*************************************************************************** + * Copyright (C) 2021 Celestica Corp * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WDT_CONTROL_BASE 0xA100 +#define TEST_SCRATCH_REG 0xA101 +#define REBOOT_CAUSE_REG 0xA105 +#define WDT_SET_TIMER_H_BIT_REG 0xA161 +#define WDT_SET_TIMER_M_BIT_REG 0xA162 +#define WDT_SET_TIMER_L_BIT_REG 0xA163 +#define WDT_TIMER_H_BIT_REG 0xA164 +#define WDT_TIMER_M_BIT_REG 0xA165 +#define WDT_TIMER_L_BIT_REG 0xA166 +#define WDT_ENABLE_REG 0xA167 +#define WDT_FEED_REG 0xA168 +#define WDT_PUNCH_REG 0xA169 +#define WDT_START_FEED 0x01 +#define WDT_STOP_FEED 0x00 + +#define POWER_CYCLE_RESET 0x00 +#define POWER_ON_RESET 0x11 +#define SOFT_SET_WARM_RESET 0x22 +#define SOFT_SET_COLD_RESET 0x33 +#define CPU_WARM_RESET 0x44 +#define CPU_COLD_RESET 0x55 +#define CPU_GPIO_WARM_RESET 0x66 +#define WDT_RESET 0x77 +#define CPU_OVERLOAD_RESET 0x88 +#define INSUFFICIENT_FAN_SPEED_RESET 0xAA + + +#define MAX_TIMER_VALUE 0xffffff +#define DEFUALT_TIMER_VALUE 180000 /* 180s */ +#define WDT_ENABLE 0x01 +#define WDT_DISABLE 0x00 +#define WDT_RESTART 0x00 +#define DRV_NAME "cpld_wdt" +#define DRV_VERSION "1.0.0" +#define DEV_NAME "cpld_wdt" + +struct wdt_data { + unsigned long opened; + struct mutex lock; + char expect_close; + struct watchdog_info ident; + int timeout; + int timer_val; + char caused_reboot; /* last reboot was by the watchdog */ + struct resource *res; +}; + +struct cpld_wdt_private { + struct platform_device *pdev; + struct watchdog_device wddev; + struct cdev cdev; + bool suspended; + struct wdt_data wdat; +}; + +//struct class *cpld_wdt; +static const int max_timeout = MAX_TIMER_VALUE; + +static int timeout = DEFUALT_TIMER_VALUE; /* default 180s */ +module_param(timeout, int, 0); +MODULE_PARM_DESC(timeout, "Start watchdog timer on module load with" + " given initial timeout(unit: ms)." + " Zero (default) disables this feature."); + +static bool nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, bool, 0444); +MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); + +static unsigned int watchdog_get_timeleft(struct cpld_wdt_private *wdt) +{ + int time = 0; + + mutex_lock(&wdt->wdat.lock); + + time = inb(WDT_TIMER_H_BIT_REG); + time = time << 8 | inb(WDT_TIMER_M_BIT_REG); + time = time << 8 | inb(WDT_TIMER_L_BIT_REG); + time = time/1000; + mutex_unlock(&wdt->wdat.lock); + + return time; +} +static int watchdog_get_timeout(struct cpld_wdt_private *wdt) +{ + int timeout = 0; + if(!wdt) + return -EINVAL; + + mutex_lock(&wdt->wdat.lock); + timeout = inb(WDT_SET_TIMER_H_BIT_REG); + timeout = timeout << 8 | inb(WDT_SET_TIMER_M_BIT_REG); + timeout = timeout << 8 | inb(WDT_SET_TIMER_L_BIT_REG); + timeout=timeout/1000; + mutex_unlock(&wdt->wdat.lock); + + return timeout; +} +static int watchdog_set_timeout(struct cpld_wdt_private *wdt, unsigned int timeout) +{ + unsigned char val = 0; + if(!wdt) + return -EINVAL; + + if (timeout <= 0 + || timeout > max_timeout) { + pr_err("watchdog timeout out of range\n"); + return -EINVAL; + } + + mutex_lock(&wdt->wdat.lock); + + wdt->wdat.timeout = timeout; + if (timeout > MAX_TIMER_VALUE) { + wdt->wdat.timer_val = MAX_TIMER_VALUE; + } else { + wdt->wdat.timer_val = timeout; + } + /* Set timer value */ + pr_crit("Watchdog Timeout:0x%06x\n", wdt->wdat.timer_val); + + outb((wdt->wdat.timer_val >> 16) & 0xff, WDT_SET_TIMER_H_BIT_REG); + outb((wdt->wdat.timer_val >> 8) & 0xff, WDT_SET_TIMER_M_BIT_REG); + outb(wdt->wdat.timer_val & 0xff, WDT_SET_TIMER_L_BIT_REG); + + mutex_unlock(&wdt->wdat.lock); + + return 0; +} + +static int watchdog_ping(struct cpld_wdt_private *wdt) +{ + if(!wdt) + return -EINVAL; + + mutex_lock(&wdt->wdat.lock); + + /* start feed watchdog */ + outb(WDT_START_FEED, WDT_FEED_REG); + /* stop feed watchdog */ + outb(WDT_STOP_FEED, WDT_FEED_REG); + + mutex_unlock(&wdt->wdat.lock); + + return 0; +} + +static void watchdog_keepalive(struct cpld_wdt_private *wdt) +{ + if(!wdt) + return; + + mutex_lock(&wdt->wdat.lock); + + /* start feed watchdog */ + outb(WDT_START_FEED, WDT_FEED_REG); + /* stop feed watchdog */ + outb(WDT_STOP_FEED, WDT_FEED_REG); + + mutex_unlock(&wdt->wdat.lock); + return; +} + +static int watchdog_start(struct cpld_wdt_private *wdt) +{ + if(!wdt) + return -EINVAL; + + /* Make sure we don't die as soon as the watchdog is enabled below */ + //watchdog_keepalive(); + mutex_lock(&wdt->wdat.lock); + outb(WDT_ENABLE, WDT_ENABLE_REG); + outb(WDT_RESTART, WDT_PUNCH_REG); + mutex_unlock(&wdt->wdat.lock); + + return 0; +} + +static int watchdog_stop(struct cpld_wdt_private *wdt) +{ + if(!wdt) + return -EINVAL; + + mutex_lock(&wdt->wdat.lock); + outb(WDT_DISABLE, WDT_ENABLE_REG); + mutex_unlock(&wdt->wdat.lock); + return 0; +} + +static char watchdog_get_reason(struct cpld_wdt_private *p) +{ + char status = 0; + + if (!p) + return -1; + mutex_lock(&p->wdat.lock); + status = inb(REBOOT_CAUSE_REG); + mutex_unlock(&p->wdat.lock); + + return status; +} + +static bool watchdog_is_running(struct cpld_wdt_private *wdt) +{ + /* + * if we fail to determine the watchdog's status assume it to be + * running to be on the safe side + */ + + bool is_running = true; + + mutex_lock(&wdt->wdat.lock); + is_running = inb(WDT_ENABLE_REG); + mutex_unlock(&wdt->wdat.lock); + + return is_running; +} + +static const struct watchdog_info ident = { + .options = WDIOF_SETTIMEOUT | + WDIOF_KEEPALIVEPING | + WDIOF_MAGICCLOSE, + .firmware_version = 0, + .identity = DRV_NAME, +}; + +static ssize_t identity_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct cpld_wdt_private *wdt = dev_get_drvdata(dev); + if(!wdt) + return -EINVAL; + return sprintf(buf, "%s\n", wdt->wdat.ident.identity); +} + +static DEVICE_ATTR_RO(identity); + + +static ssize_t state_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct cpld_wdt_private *wdt = dev_get_drvdata(dev); + bool state = watchdog_is_running(wdt); + if(true == state) + return sprintf(buf, "active\n"); + else + return sprintf(buf, "inactive\n"); +} + +static DEVICE_ATTR_RO(state); + +static ssize_t status_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + unsigned int status; + struct cpld_wdt_private *wdt = dev_get_drvdata(dev); + if(!wdt) + return -EINVAL; + + return sprintf(buf, "0x%x\n", status); +} + +static DEVICE_ATTR_RO(status); + +static ssize_t reason_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + char bootstatus; + struct cpld_wdt_private *wdt = dev_get_drvdata(dev); + if(!wdt) + return -EINVAL; + + bootstatus = watchdog_get_reason(wdt); + + return sprintf(buf, "0x%02\n", bootstatus); +} + +static DEVICE_ATTR_RO(reason); + +static ssize_t timeleft_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + unsigned int timeleft; + struct cpld_wdt_private *wdt = dev_get_drvdata(dev); + if(!wdt) + return -EINVAL; + + timeleft = watchdog_get_timeleft(wdt); + + return sprintf(buf, "%u\n", timeleft); + +} + +static DEVICE_ATTR_RO(timeleft); + + +static ssize_t timeout_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + unsigned int timeout; + struct cpld_wdt_private *wdt = dev_get_drvdata(dev); + if(!wdt) + return -EINVAL; + + timeout = watchdog_get_timeout(wdt); + + return sprintf(buf, "%u\n", timeout); +} +static DEVICE_ATTR_RO(timeout); + + +static struct attribute *wdt_attrs[] = { + &dev_attr_state.attr, + &dev_attr_identity.attr, + &dev_attr_status.attr, + &dev_attr_reason.attr, + &dev_attr_timeleft.attr, + &dev_attr_timeout.attr, + NULL, +}; + +static const struct attribute_group wdt_group = { + .attrs = wdt_attrs, +}; + +static int watchdog_open(struct inode *inode, struct file *file) +{ + struct cpld_wdt_private *wdt; + + wdt = container_of(inode->i_cdev, struct cpld_wdt_private, cdev); + + /* If the watchdog is alive we don't need to start it again */ + + if (test_and_set_bit(0, &wdt->wdat.opened)) + return -EBUSY; + + //watchdog_start(wdt); + + if (nowayout) + __module_get(THIS_MODULE); + + wdt->wdat.expect_close = 0; + + file->private_data = wdt; + return nonseekable_open(inode, file); +} + +static int watchdog_release(struct inode *inode, struct file *file) +{ + struct cpld_wdt_private *p; + p = (struct cpld_wdt_private *)file->private_data; + + if(!p) + return -EINVAL; + + clear_bit(0, &p->wdat.opened); + + if (!p->wdat.expect_close) { + watchdog_keepalive(p); + //pr_crit("Unexpected close, Not stopping watchdog!\n"); + } else if (!nowayout) { + //pr_crit("Cpld Watchdog Stopped!\n"); + watchdog_stop(p); + } + return 0; +} + +/* + * watchdog_write: + * @file: file handle to the watchdog + * @buf: buffer to write + * @count: count of bytes + * @ppos: pointer to the position to write. No seeks allowed + * + * A write to a watchdog device is defined as a keepalive signal. Any + * write of data will do, as we we don't define content meaning. + */ + +static ssize_t watchdog_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct cpld_wdt_private *p; + p = (struct cpld_wdt_private *)file->private_data; + + if(!p) + return -EINVAL; + + + if (count) { + if (!nowayout) { + size_t i; + + /* In case it was set long ago */ + bool expect_close = false; + + for (i = 0; i != count; i++) { + char c; + if (get_user(c, buf + i)) + return -EFAULT; + expect_close = (c == 'V'); + } + + /* Properly order writes across fork()ed processes */ + mutex_lock(&p->wdat.lock); + p->wdat.expect_close = expect_close; + mutex_unlock(&p->wdat.lock); + } + + /* someone wrote to us, we should restart timer */ + watchdog_keepalive(p); + } + return count; +} + +/* + * watchdog_ioctl: + * @inode: inode of the device + * @file: file handle to the device + * @cmd: watchdog command + * @arg: argument pointer + * + * The watchdog API defines a common set of functions for all watchdogs + * according to their available features. + */ +static long watchdog_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + int status; + int new_options; + int new_timeout; + unsigned int val; + union { + struct watchdog_info __user *ident; + int __user *i; + } uarg; + + uarg.i = (int __user *)arg; + + struct cpld_wdt_private *p; + p = (struct cpld_wdt_private *)file->private_data; + if(!p) + return -EINVAL; + + switch (cmd) { + case WDIOC_GETSUPPORT: + return copy_to_user(uarg.ident, &p->wdat.ident, + sizeof(p->wdat.ident)) ? -EFAULT : 0; + + case WDIOC_GETSTATUS: + status = watchdog_is_running(p); + return put_user(status, uarg.i); + + case WDIOC_GETBOOTSTATUS: + //status = watchdog_get_bootstatus(p); + return put_user(status, uarg.i); + + case WDIOC_SETOPTIONS: + if (get_user(new_options, uarg.i)){ + return -EFAULT; + } + + if (new_options & WDIOS_DISABLECARD){ + return watchdog_stop(p); + } + + if (new_options & WDIOS_ENABLECARD){ + return watchdog_start(p); + } + + return 0; + + case WDIOC_KEEPALIVE: + watchdog_keepalive(p); + return 0; + + case WDIOC_SETTIMEOUT: + if (get_user(new_timeout, uarg.i)) + return -EFAULT; + new_timeout = new_timeout*1000; + if (watchdog_set_timeout(p, new_timeout)) + return -EINVAL; + watchdog_keepalive(p); + /* Fall */ + return 0; + case WDIOC_GETTIMEOUT: + val = watchdog_get_timeout(p); + return put_user(val, uarg.i); + + case WDIOC_GETTIMELEFT: + val = watchdog_get_timeleft(p); + return put_user(val, uarg.i); + default: + return -ENOTTY; + + } +} + +static int watchdog_notify_sys(struct notifier_block *this, unsigned long code, + void *unused) +{ + if (code == SYS_DOWN || code == SYS_HALT) + //watchdog_stop(p); + + pr_err("CPLD Watchdog did not Stop!\n"); + return NOTIFY_DONE; +} + +static const struct file_operations watchdog_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .open = watchdog_open, + .release = watchdog_release, + .write = watchdog_write, + .unlocked_ioctl = watchdog_ioctl, +}; + +static struct miscdevice watchdog_miscdev = { + //.minor = WATCHDOG_MINOR, + .name = DEV_NAME, + .fops = &watchdog_fops, +}; + +static struct notifier_block watchdog_notifier = { + .notifier_call = watchdog_notify_sys, +}; + +static int cpld_wdt_probe(struct platform_device *pdev) +{ + int wdt_reboot_cause, err = 0; + unsigned char ver = 0; + struct device *dev = &pdev->dev; + + struct cpld_wdt_private *p; + + p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL); + if (!p) + return -ENOMEM; + + + mutex_init(&(p->wdat.lock)); + + p->wdat.ident.options = WDIOC_SETTIMEOUT + | WDIOF_MAGICCLOSE + | WDIOF_KEEPALIVEPING + | WDIOC_GETTIMELEFT; + + snprintf(p->wdat.ident.identity, + sizeof(p->wdat.ident.identity), "%s", DRV_NAME); + + wdt_reboot_cause = inb(REBOOT_CAUSE_REG); // REBOOT_CAUSE + p->wdat.caused_reboot = wdt_reboot_cause; + ver = inb(WDT_CONTROL_BASE); + pr_info("Watchdog CPLD Version:0x%02x\n", + ver); + + if (timeout) { + if (timeout <= 0 + || timeout > max_timeout) { + pr_err("starting timeout out of range\n"); + err = -EINVAL; + return err; + } + + //watchdog_start(p); + + + if (timeout > MAX_TIMER_VALUE) { + watchdog_set_timeout(p, MAX_TIMER_VALUE); + } else { + watchdog_set_timeout(p, timeout); + } + + if (nowayout) + __module_get(THIS_MODULE); + + pr_info("watchdog started with initial timeout of %u Second(s)\n", + timeout/1000); + } + + err = watchdog_set_timeout(p, timeout); + if (err) + return err; + + err = register_reboot_notifier(&watchdog_notifier); + if (err) + return err; + + err = misc_register(&watchdog_miscdev); + if (err) { + pr_err("cannot register miscdev on minor=%d\n", + watchdog_miscdev.minor); + return err;; + } + + /*p->wdat.res = platform_get_resource(pdev, IORESOURCE_IO, WDT_CONTROL_BASE); + if (!p->wdat.res) + return -ENODEV; + + if (!devm_request_region(dev, p->wdat.res->start, + resource_size(p->wdat.res), + pdev->name)) { + return -EBUSY; + } + */ + err = sysfs_create_group(&pdev->dev.kobj, &wdt_group); + if (err) { + printk(KERN_ERR "Cannot create sysfs for cpld_wdt.\n"); + return err; + } + + platform_set_drvdata(pdev, p); + dev_set_drvdata(dev, p); + + pr_info("initialized. sec (nowayout=%d)\n", + nowayout); + + return 0; +} + +static int cpld_wdt_remove(struct platform_device *pdev) +{ + struct cpld_wdt_private *p = platform_get_drvdata(pdev); + /* + if (!nowayout) + watchdog_stop(&p->wddev); + */ + if(!p) + return 0; + + sysfs_remove_group(&pdev->dev.kobj, &wdt_group); + + misc_deregister(&watchdog_miscdev); + + unregister_reboot_notifier(&watchdog_notifier); + + return 0; + +} + +static struct platform_driver cpld_wdt_driver = { + .probe = cpld_wdt_probe, + .remove = cpld_wdt_remove, + .driver = { + .name = DRV_NAME, + }, +}; + +static struct resource cpld_wdt_resources[] = { + { + .start = 0xA100, + .end = 0xA1F2, + .flags = IORESOURCE_IO, + }, +}; + +static void wdt_dev_release( struct device * dev) +{ + return; +} + +static struct platform_device cpld_wdt_dev = { + .name = DRV_NAME, + .id = -1, + .num_resources = ARRAY_SIZE(cpld_wdt_resources), + .resource = cpld_wdt_resources, + .dev = { + .release = wdt_dev_release, + } +}; + +static int __init cpld_wdt_init_module(void) +{ + int err = 0; + + err = platform_device_register(&cpld_wdt_dev); + err += platform_driver_register(&cpld_wdt_driver); + if(err < 0) + pr_info("Platform Device/Driver Register Failed. err:%d\n", err); + + pr_info("CPLD WatchDog Timer Driver v%s\n", DRV_VERSION); + return err; +} + +static void __exit cpld_wdt_cleanup_module(void) +{ + platform_driver_unregister(&cpld_wdt_driver); + platform_device_unregister(&cpld_wdt_dev); + pr_info("Watchdog Module Unloaded\n"); +} + +module_init(cpld_wdt_init_module); +module_exit(cpld_wdt_cleanup_module); + + +MODULE_DESCRIPTION("Cpld Watchdog Driver"); +MODULE_VERSION(DRV_VERSION); +MODULE_AUTHOR("Nicholas "); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/__init__.py new file mode 100644 index 000000000000..2dc71f83c00d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/__init__.py @@ -0,0 +1,3 @@ +# All the derived classes for PDDF +__all__ = ["platform", "chassis", "sfp", "psu", "thermal"] +from sonic_platform import * diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py new file mode 100644 index 000000000000..d8a7fb91f517 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py @@ -0,0 +1,69 @@ +############################################################################# +# PDDF +# Module contains an implementation of SONiC Chassis API +# +############################################################################# + +try: + from sonic_platform_pddf_base.pddf_chassis import PddfChassis + from sonic_platform.fan_drawer import FanDrawer + from sonic_platform.watchdog import Watchdog +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +FAN_DIRECTION_FILE_PATH = "/var/fan_direction" + + +class Chassis(PddfChassis): + """ + PDDF Platform-specific Chassis class + """ + + def __init__(self, pddf_data=None, pddf_plugin_data=None): + PddfChassis.__init__(self, pddf_data, pddf_plugin_data) + vendor_ext = self.sys_eeprom.vendor_ext_str() + with open(FAN_DIRECTION_FILE_PATH, "w+") as f: + f.write(vendor_ext) + for i in range(self.platform_inventory['num_fantrays']): + fandrawer = FanDrawer(i, self.pddf_obj, self.plugin_data) + self._fan_drawer_list.append(fandrawer) + self._fan_list.extend(fandrawer._fan_list) + + # Provide the functions/variables below for which implementation is to be overwritten + + def initizalize_system_led(self): + return True + + def get_sfp(self, index): + """ + Retrieves sfp represented by (1-based) index + For Quanta the index in sfputil.py starts from 1, so override + Args: + index: An integer, the index (1-based) of the sfp to retrieve. + The index should be the sequence of a physical port in a chassis, + starting from 1. + Returns: + An object dervied from SfpBase representing the specified sfp + """ + sfp = None + + try: + if index == 0: + raise IndexError + sfp = self._sfp_list[index - 1] + except IndexError: + sys.stderr.write("override: SFP index {} out of range (1-{})\n".format( + index, len(self._sfp_list))) + + return sfp + + def get_watchdog(self): + """ + Retreives hardware watchdog device on this chassis + Returns: + An object derived from WatchdogBase representing the hardware + watchdog device + """ + self._watchdog = Watchdog() + + return self._watchdog diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py new file mode 100644 index 000000000000..8309e759fca6 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py @@ -0,0 +1,74 @@ +try: + from sonic_platform_pddf_base.pddf_eeprom import PddfEeprom +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Eeprom(PddfEeprom): + + _TLV_DISPLAY_VENDOR_EXT = True + _TLV_INFO_MAX_LEN = 256 + pddf_obj = {} + plugin_data = {} + + def __init__(self, pddf_data=None, pddf_plugin_data=None): + if not pddf_data or not pddf_plugin_data: + raise ValueError('PDDF JSON data error') + + self.pddf_obj = pddf_data + self.plugin_data = pddf_plugin_data + + # system EEPROM always has device name EEPROM1 + self.eeprom_path = self.pddf_obj.get_path("EEPROM1", "eeprom") + if self.eeprom_path is None: + return + + super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) + self.eeprom_tlv_dict = dict() + try: + self.eeprom_data = self.read_eeprom() + except Exception as e: + self.eeprom_data = "N/A" + raise RuntimeError("PddfEeprom is not Programmed - Error: {}".format(str(e))) + else: + eeprom = self.eeprom_data + + if not self.is_valid_tlvinfo_header(eeprom): + return + + total_length = ((eeprom[9]) << 8) | (eeprom[10]) + tlv_index = self._TLV_INFO_HDR_LEN + tlv_end = self._TLV_INFO_HDR_LEN + total_length + + while (tlv_index + 2) < self._TLV_INFO_MAX_LEN and tlv_index < tlv_end: + if not self.is_valid_tlv(eeprom[tlv_index:]): + break + + tlv = eeprom[tlv_index:tlv_index + 2 + + (eeprom[tlv_index + 1])] + code = "0x%02X" % ((tlv[0])) + + if (tlv[0]) == self._TLV_CODE_VENDOR_EXT: + name = "Vendor Extension" + value = "" + if self._TLV_DISPLAY_VENDOR_EXT: + for c in tlv[2:2 + tlv[1]]: + value += "0x%02X " % c + else: + name, value = self.decoder(None, tlv) + + self.eeprom_tlv_dict[code] = value + if (eeprom[tlv_index]) == self._TLV_CODE_CRC_32: + break + + tlv_index += (eeprom[tlv_index+1]) + 2 + + def vendor_ext_str(self): + """ + :return: the direction of fan(FB or BF, string) + """ + (is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_VENDOR_EXT) + if not is_valid: + return "N/A" + return str(hex(int(results[2][2]))).replace("0x", "").upper() + # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py new file mode 100644 index 000000000000..8b39b847258d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py @@ -0,0 +1,64 @@ +try: + from sonic_platform_pddf_base.pddf_fan import PddfFan + import os +except ImportError as e: + raise ImportError(str(e) + "- required module not found") +FAN_DIRECTION_FILE_PATH = "/var/fan_direction" + + +class Fan(PddfFan): + """PDDF Platform-Specific Fan class""" + + def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0): + # idx is 0-based + PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index) + + + 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 + """ + # Fix the speed vairance to 10 percent. If it changes based on platforms, overwrite + # this value in derived pddf fan class + return 20 + + + def get_presence(self): + #Overwirte the PDDF Common since the FANs on Belgite are all Fixed and present + return True + + def get_direction(self): + """ + Retrieves the direction of fan + + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + """ + if self.is_psu_fan: + cmd_num = "58" if self.fans_psu_index == 1 else "59" + cmd = "i2cget -y -f 4 0x%s 0x80" % cmd_num + res = os.popen(cmd).read() + # F2B + if res.strip() == "0x01": + direction = "EXHAUST" + else: + direction = "INTAKE" + else: + direction = "INTAKE" + with open(FAN_DIRECTION_FILE_PATH, "r") as f: + fan_direction = f.read() + if fan_direction.strip() == "FB": + direction = "EXHAUST" + return direction + + + def get_status(self): + speed = self.get_speed_rpm() + status = True if (speed != 0) else False + return status + diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py new file mode 100644 index 000000000000..de08675c067f --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py @@ -0,0 +1,94 @@ +############################################################################# +# PDDF +# +# PDDF fan_drawer base class inherited from the common base class fan_drawer.py +# +############################################################################# + +try: + from sonic_platform_base.fan_drawer_base import FanDrawerBase + from sonic_platform.fan import Fan +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class PddfFanDrawer(FanDrawerBase): + """PDDF generic Fan Drawer class""" + + pddf_obj = {} + plugin_data = {} + + def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): + FanDrawerBase.__init__(self) + if not pddf_data or not pddf_plugin_data: + raise ValueError('PDDF JSON data error') + + self.pddf_obj = pddf_data + self.plugin_data = pddf_plugin_data + self.platform = self.pddf_obj.get_platform() + + if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']: + print("Invalid fantray index %d\n" % tray_idx) + return + + self.fantray_index = tray_idx+1 + for j in range(self.platform['num_fans_pertray']): + # Fan index is 0-based for the init call + self._fan_list.append(Fan(tray_idx, j, self.pddf_obj, self.plugin_data)) + + def get_name(self): + """ + Retrieves the fan drawer name + Returns: String containing fan-drawer name + """ + return "Fantray{0}".format(self.fantray_index) + + def get_presence(self): + status = False + # Usually if a tray is removed, all the fans inside it are absent + if self._fan_list: + status = self._fan_list[0].get_presence() + + return status + + def get_status(self): + status = False + # if all the fans are working fine, then tray status should be okay + if self._fan_list: + status = all(fan.get_status() == True for fan in self._fan_list) + + return status + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + # Usually Fantrays are replaceable + return False + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + Returns: + integer: The 1-based relative physical position in parent + device or -1 if cannot determine the position + """ + return self.fantray_index + + + +class FanDrawer(PddfFanDrawer): + """PDDF Platform-Specific Fan-Drawer class""" + + def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): + # idx is 0-based + PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) + + + def set_status_led(self, color): + return self._fan_list[0].set_status_led(color) + + def get_status_led(self, color=None): + return self._fan_list[0].get_status_led() diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py new file mode 100644 index 000000000000..aa11b0a52bf3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py @@ -0,0 +1,45 @@ +############################################################################# +# PDDF +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +try: + import json + from sonic_platform_pddf_base.pddfparse import PddfParse + 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 PddfPlatform(PlatformBase): + """ + PDDF Generic Platform class + """ + pddf_data = {} + pddf_plugin_data = {} + + def __init__(self): + # Initialize the JSON data + self.pddf_data = PddfParse() + with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd: + self.pddf_plugin_data = json.load(pd) + + if not self.pddf_data or not self.pddf_plugin_data: + print("Error: PDDF JSON data is not loaded properly ... Exiting") + raise ValueError + + PlatformBase.__init__(self) + self._chassis = Chassis(self.pddf_data, self.pddf_plugin_data) + +class Platform(PddfPlatform): + """ + PDDF Platform-Specific Platform Class + """ + + def __init__(self): + PddfPlatform.__init__(self) + + # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py new file mode 100644 index 000000000000..2ba3f2e152ad --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py @@ -0,0 +1,36 @@ +try: + from sonic_platform_pddf_base.pddf_psu import PddfPsu +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + + +class Psu(PddfPsu): + """PDDF Platform-Specific PSU class""" + + PLATFORM_PSU_CAPACITY = 550 + + def __init__(self, index, pddf_data=None, pddf_plugin_data=None): + PddfPsu.__init__(self, index, pddf_data, pddf_plugin_data) + + # Provide the functions/variables below for which implementation is to be overwritten + def get_capacity(self): + """ + Gets the capacity (maximum output power) of the PSU in watts + + Returns: + An integer, the capacity of PSU + """ + return (self.PLATFORM_PSU_CAPACITY) + + def get_type(self): + """ + Gets the type of the PSU + + Returns: + A string, the type of PSU (AC/DC) + """ + ptype = "AC" + + # This platform supports AC PSU + return ptype + diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/sfp.py new file mode 100644 index 000000000000..a216a37afcf8 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/sfp.py @@ -0,0 +1,15 @@ +try: + from sonic_platform_pddf_base.pddf_sfp import PddfSfp +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + + +class Sfp(PddfSfp): + """ + PDDF Platform-Specific Sfp class + """ + + def __init__(self, index, pddf_data=None, pddf_plugin_data=None): + PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) + + # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py new file mode 100644 index 000000000000..99b743c6d343 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py @@ -0,0 +1,14 @@ +try: + from sonic_platform_pddf_base.pddf_thermal import PddfThermal +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + + +class Thermal(PddfThermal): + """PDDF Platform-Specific Thermal class""" + + def __init__(self, index, pddf_data=None, pddf_plugin_data=None): + PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data) + + # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py new file mode 100644 index 000000000000..7aa635cbe790 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py @@ -0,0 +1,233 @@ +#!/usr/bin/env python + +############################################################################# +# +# Watchdog contains an implementation of SONiC Platform Base Watchdog API +# +############################################################################# +import ctypes +import fcntl +import os +import subprocess +import time +import array +import syslog + +try: + from sonic_platform_base.watchdog_base import WatchdogBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +""" ioctl constants """ +IO_WRITE = 0x40000000 +IO_READ = 0x80000000 +IO_READ_WRITE = 0xC0000000 +IO_SIZE_INT = 0x00040000 +IO_SIZE_40 = 0x00280000 +IO_TYPE_WATCHDOG = ord('W') << 8 + +WDR_INT = IO_READ | IO_SIZE_INT | IO_TYPE_WATCHDOG +WDR_40 = IO_READ | IO_SIZE_40 | IO_TYPE_WATCHDOG +WDWR_INT = IO_READ_WRITE | IO_SIZE_INT | IO_TYPE_WATCHDOG + +""" Watchdog ioctl commands """ +WDIOC_GETSUPPORT = 0 | WDR_40 +WDIOC_GETSTATUS = 1 | WDR_INT +WDIOC_GETBOOTSTATUS = 2 | WDR_INT +WDIOC_GETTEMP = 3 | WDR_INT +WDIOC_SETOPTIONS = 4 | WDR_INT +WDIOC_KEEPALIVE = 5 | WDR_INT +WDIOC_SETTIMEOUT = 6 | WDWR_INT +WDIOC_GETTIMEOUT = 7 | WDR_INT +WDIOC_SETPRETIMEOUT = 8 | WDWR_INT +WDIOC_GETPRETIMEOUT = 9 | WDR_INT +WDIOC_GETTIMELEFT = 10 | WDR_INT + +""" Watchdog status constants """ +WDIOS_DISABLECARD = 0x0001 +WDIOS_ENABLECARD = 0x0002 + +WDT_COMMON_ERROR = -1 +WD_MAIN_IDENTITY = "cpld_wdt" +WDT_SYSFS_PATH = "/sys/class/watchdog/" + +DEFAULT_TIMEOUT=180 +watchdog = 0 + +class CpldWatchdog(WatchdogBase): + + watchdog = None + def __init__(self): + global watchdog + self.status_path = "/sys/devices/platform/cpld_wdt/status" + self.state_path = "/sys/devices/platform/cpld_wdt/state" + self.timeout_path = "/sys/devices/platform/cpld_wdt/timeout" + # Set default value + with open("/sys/devices/platform/cpld_wdt/state", "r") as fd: + txt = fd.read() + state = txt.strip() + self.armed = True if state == "active" else False + self.timeout = DEFAULT_TIMEOUT + if not watchdog: + watchdog = os.open("/dev/cpld_wdt", os.O_RDWR) + + self.watchdog = watchdog + #self._disable() + + + def _read_file(self, file_path): + """ + Read text file + """ + try: + with open(file_path, "r") as fd: + txt = fd.read() + except IOError: + return WDT_COMMON_ERROR + return txt.strip() + + def _enable(self): + """ + Turn on the watchdog timer + """ + req = array.array('h', [WDIOS_ENABLECARD]) + fcntl.ioctl(self.watchdog, WDIOC_SETOPTIONS, req, False) + + def _disable(self): + """ + Turn off the watchdog timer + """ + req = array.array('h', [WDIOS_DISABLECARD]) + fcntl.ioctl(self.watchdog, WDIOC_SETOPTIONS, req, False) + + def _keepalive(self): + """ + Keep alive watchdog timer + """ + fcntl.ioctl(self.watchdog, WDIOC_KEEPALIVE) + + def _settimeout(self, seconds): + """ + Set watchdog timer timeout + @param seconds - timeout in seconds + @return is the actual set timeout + """ + req = array.array('I', [seconds]) + fcntl.ioctl(self.watchdog, WDIOC_SETTIMEOUT, req, True) + return int(req[0]) + + def _gettimeout(self, timeout_path): + """ + Get watchdog timeout + @return watchdog timeout + """ + req = array.array('I', [0]) + fcntl.ioctl(self.watchdog, WDIOC_GETTIMEOUT, req, True) + + return int(req[0]) + + def _gettimeleft(self): + """ + Get time left before watchdog timer expires + @return time left in seconds + """ + req = array.array('I', [0]) + fcntl.ioctl(self.watchdog, WDIOC_GETTIMELEFT, req, True) + + return int(req[0]) + + ################################################################# + + 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. + """ + + ret = WDT_COMMON_ERROR + if seconds < 0: + return ret + + try: + if self.timeout != seconds: + self.timeout = self._settimeout(seconds) + if self.armed: + self._keepalive() + else: + self._settimeout(seconds) + self._enable() + self.armed = True + ret = self.timeout + except IOError as e: + pass + + return ret + + def disarm(self): + """ + Disarm the hardware watchdog + Returns: + A boolean, True if watchdog is disarmed successfully, False if not + """ + disarmed = False + if self.is_armed(): + try: + self._disable() + self.armed = False + disarmed = True + except IOError: + pass + + return disarmed + + def is_armed(self): + """ + Retrieves the armed state of the hardware watchdog. + Returns: + A boolean, True if watchdog is armed, False if not + """ + + return self.armed + + 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. + """ + + timeleft = WDT_COMMON_ERROR + + if self.armed: + try: + timeleft = self._gettimeleft() + except IOError: + pass + + return timeleft + + def __del__(self): + """ + Close watchdog + """ + + if self.watchdog is not None : + os.close(self.watchdog) + +class Watchdog(CpldWatchdog): + """PDDF Platform-Specific Watchdog Class""" + + def __init__(self): + CpldWatchdog.__init__(self) + + # Provide the functions/variables below for which implementation is to be overwritten + diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform_setup.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform_setup.py new file mode 100644 index 000000000000..a1535165bb66 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform_setup.py @@ -0,0 +1,28 @@ +import os +import sys +from setuptools import setup +os.listdir + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Celestica Platforms based on PDDF', + license='Apache 2.0', + author='SONiC Team', + author_email='linuxnetdev@microsoft.com', + url='https://github.com/Azure/sonic-buildimage', + packages=['sonic_platform'], + 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.7', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh new file mode 100755 index 000000000000..8dd9ac8a8486 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Set U60 shutdown threhold 80 +sudo i2cset -y -f 6 0x49 0x3 0x4e 0x00 i +sleep 0.1 +sudo i2cset -y -f 6 0x49 0x1 0x2 +sleep 0.1 +#Set LM75 shutdown enable +sudo i2cset -y -f 2 0x32 0x45 0x1 + diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_pre_driver_install.sh b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_pre_driver_install.sh new file mode 100755 index 000000000000..a25c39df41a1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_pre_driver_install.sh @@ -0,0 +1,3 @@ +#!/bin/bash +modprobe -r i2c_ismt +modprobe -r i2c-i801 diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/service/belgite-pddf-platform-monitor.service b/platform/broadcom/sonic-platform-modules-cel/belgite/service/belgite-pddf-platform-monitor.service new file mode 100644 index 000000000000..233971ae784d --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/service/belgite-pddf-platform-monitor.service @@ -0,0 +1,16 @@ +[Unit] +Description=Belgite Platform Monitoring service +Before=pmon.service +After=pddf-platform-init.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/belgite_pddf_monitor.py +KillSignal=SIGKILL +SuccessExitStatus=SIGKILL + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/systemd/pddf-platform-init.service b/platform/broadcom/sonic-platform-modules-cel/belgite/systemd/pddf-platform-init.service new file mode 100644 index 000000000000..249fa2e89764 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/systemd/pddf-platform-init.service @@ -0,0 +1,15 @@ +[Unit] +Description=PDDF module and device initialization service +Before=pmon.service watchdog-control.service +Before=opennsl-modules.service +DefaultDependencies=no + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/pddf_util.py install +ExecStop=/usr/local/bin/pddf_util.py clean +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +WantedBy=opennsl-modules.service diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/utils/belgite_pddf_monitor.py b/platform/broadcom/sonic-platform-modules-cel/belgite/utils/belgite_pddf_monitor.py new file mode 100755 index 000000000000..b676c856592b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/utils/belgite_pddf_monitor.py @@ -0,0 +1,271 @@ +#!/usr/bin/env python3 +# +# Copyright (C) Celestica Technology 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 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 . + +# ------------------------------------------------------------------ +# HISTORY: +# 9/16/2021 (A.D.) +# ------------------------------------------------------------------ + +try: + import sys + import getopt + import subprocess + import logging + import logging.config + import time # this is only being used as part of the example + import signal + from sonic_platform import platform +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + +# Deafults +FUNCTION_NAME = 'cel_belgite_monitor' +DUTY_MAX = 100 +FAN_NUMBER = 3 +SENSOR_NUMBER = 4 +CPU_CORE_TEMP = r"/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input" + + +class cel_belgite_monitor(object): + """ + Make a class we can use to capture stdout and sterr in the log + """ + # static temp var + _ori_temp = 0 + _new_perc = DUTY_MAX / 2 + syslog = logging.getLogger("[" + FUNCTION_NAME + "]") + init_fan_temperature = [0, 0, 0, 0] + + def __init__(self, log_file, log_level): + """Needs a logger and a logger level.""" + formatter = logging.Formatter('%(name)s %(message)s') + sys_handler = logging.handlers.SysLogHandler(address='/dev/log') + sys_handler.setFormatter(formatter) + sys_handler.ident = 'common' + self.syslog.setLevel(logging.WARNING) + self.syslog.addHandler(sys_handler) + self.platform_chassis_obj = platform.Platform().get_chassis() + # set up logging to file + logging.basicConfig( + filename=log_file, + filemode='w', + level=log_level, + format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', + datefmt='%H:%M:%S' + ) + + # set up logging to console + if log_level == logging.DEBUG: + console = logging.StreamHandler() + console.setLevel(log_level) + formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + logging.debug('SET. logfile:%s / loglevel:%d' % (log_file, log_level)) + + def get_all_temperature(self): + """ + return: all temperature + """ + all_temperature_list = list() + for sensor_index in range(SENSOR_NUMBER): + temp = self.platform_chassis_obj.get_thermal(sensor_index).get_temperature() + if temp is None or str(temp).strip() == "": + return False + temp = temp*1000 + all_temperature_list.append(temp) + u4_temperature = all_temperature_list[0] + u7_temperature = all_temperature_list[1] + # default CPU temperature 70 + cpu_temperature = 70000 + try: + with open(CPU_CORE_TEMP, "r") as f: + cpu_temperature = float(f.read().strip()) + except Exception as E: + logging.debug('Error: %s' % E) + u60_temperature = all_temperature_list[3] + return [u4_temperature, u7_temperature, cpu_temperature, u60_temperature] + + def get_fan_speed_by_temperature(self, temp_list): + fan1_direction = self.platform_chassis_obj.get_fan(0).get_direction() + logging.debug('INFO: fan direction: %s' % str(fan1_direction)) + all_temp = self.get_all_temperature() + logging.debug('INFO: all_temp: %s' % str(all_temp)) + # B2F=intake: U7 temperature, F2B-EXHAUST: U4 temperature + a = 1 if fan1_direction.lower() == "intake" else 0 + sensor_temp = all_temp[a] + cup_temp = all_temp[2] + u60_temp = all_temp[3] + logging.debug('sensor_temp:%d cup_temp:%d u60_temp:%d' % (sensor_temp, cup_temp, u60_temp)) + update_temp_sensor, update_temp_cpu, update_temp_u60 = True, True, True + if all_temp[a] - temp_list[a] < 0: + update_temp_sensor = False + if cup_temp - temp_list[2] < 0: + update_temp_cpu = False + if u60_temp - temp_list[3] < 0: + update_temp_u60 = False + + # U4 U7 + if not update_temp_sensor: # temperature down + b = 1400/13 + if sensor_temp <= 32000: + sensor_temp_speed = 40 + elif sensor_temp >= 45000: + sensor_temp_speed = 100 + else: + sensor_temp_speed = int((60 / 13) * int(sensor_temp / 1000) - b) + else: # temperature up + b = 1580 / 13 + if sensor_temp <= 35000: + sensor_temp_speed = 40 + elif sensor_temp >= 48000: + sensor_temp_speed = 100 + else: + sensor_temp_speed = int((60/13) * int(sensor_temp/1000) - b) + + # CPU + if not update_temp_cpu: # temperature down + b = 228 + if cup_temp <= 67000: + cpu_temp_speed = 40 + elif cup_temp >= 82000: + cpu_temp_speed = 100 + else: + cpu_temp_speed = int(4 * (cup_temp / 1000) - b) + else: # temperature up + b = 240 + if cup_temp <= 70000: + cpu_temp_speed = 40 + elif cup_temp >= 85000: + cpu_temp_speed = 100 + else: + cpu_temp_speed = int(4 * (cup_temp / 1000) - b) + + # U60 + if not update_temp_u60: # temperature down + b = 168 + if u60_temp <= 52000: + u60_temp_speed = 40 + elif u60_temp >= 67000: + u60_temp_speed = 100 + else: + u60_temp_speed = int(4 * (u60_temp / 1000) - b) + else: # temperature up + b = 180 + if u60_temp <= 55000: + u60_temp_speed = 40 + elif u60_temp >= 70000: + u60_temp_speed = 100 + else: + u60_temp_speed = int(4 * (u60_temp / 1000) - b) + return max([sensor_temp_speed, cpu_temp_speed, u60_temp_speed]) + + def manage_fans(self): + fan_presence_list = [True, True, True] # whether fan is absent or not + for fan_index in range(FAN_NUMBER): + if not self.platform_chassis_obj.get_fan(fan_index).get_presence() or not \ + self.platform_chassis_obj.get_fan(fan_index).get_status(): + fan_presence_list[fan_index] = False + logging.debug('self.platform_chassis_obj.get_fan(fan_index).get_presence():%s' + % str(self.platform_chassis_obj.get_fan(fan_index).get_presence())) + logging.debug('self.platform_chassis_obj.get_fan(fan_index).get_status():%s' + % str(self.platform_chassis_obj.get_fan(fan_index).get_status())) + else: + fan_presence_list[fan_index] = True + + fans_inserted_num = FAN_NUMBER - fan_presence_list.count(False) + if fans_inserted_num == 0: # all fans broken, power off + self.syslog.critical("No fans inserted. Severe overheating hazard. " + "Please insert Fans immediately or power off the device\n") + + # power off + elif fans_inserted_num in [1, 2]: # 1 or 2 present, full speed + self._new_perc = DUTY_MAX + else: # 3 fans normal, manage the fans follow thermal policy + self._new_perc = self.get_fan_speed_by_temperature(self.init_fan_temperature) + logging.debug('INFO: 3 fans inserted: self._new_perc: %s' % str(self._new_perc)) + self.init_fan_temperature = self.get_all_temperature() + + for i in range(FAN_NUMBER): + aa = self.platform_chassis_obj.get_fan(i).get_speed() + logging.debug("INFO: Get before setting fan speed: %s" % aa) + if self._new_perc < 40: + self._new_perc = 40 + if self._new_perc > 100: + self._new_perc = 100 + set_stat = self.platform_chassis_obj.get_fan(i).set_speed(self._new_perc) + if set_stat is True: + logging.debug('INFO: PASS. set_fan%d_duty_cycle (%d)' % (i, self._new_perc)) + else: + logging.debug('INFO: FAIL. set_fan%d_duty_cycle (%d)' % (i, self._new_perc)) + + +def handler(signum, frame): + platform_chassis = platform.Platform().get_chassis() + for _ in range(FAN_NUMBER): + set_stat = platform_chassis.get_fan(_).set_speed(DUTY_MAX) + if set_stat is True: + logging.debug('INFO:Cause signal %d, set fan speed max.' % signum) + else: + logging.debug('INFO: FAIL. set_fan_duty_cycle (%d)' % DUTY_MAX) + # Enable the CPLD Heartbeat back + status, output = subprocess.getstatusoutput('i2cset -f -y 75 0x40 0x22 0x00') + if status == 0: + logging.debug('INFO: CPLD Heartbeat check is enabled back') + sys.exit(0) + + +def main(argv): + global test_temp + + log_file = '/home/admin/%s.log' % FUNCTION_NAME + log_level = logging.INFO + if len(sys.argv) != 1: + try: + opts, args = getopt.getopt(argv, 'hdlt:', ['lfile=']) + except getopt.GetoptError: + print('Usage: %s [-d] [-l ]' % sys.argv[0]) + return 0 + for opt, arg in opts: + if opt == '-h': + print('Usage: %s [-d] [-l ]' % sys.argv[0]) + return 0 + elif opt in ('-d', '--debug'): + log_level = logging.DEBUG + elif opt in ('-l', '--lfile'): + log_file = arg + + if sys.argv[1] == '-t': + if len(sys.argv) != 6: + print("temp test, need input 4 temp") + return 0 + + signal.signal(signal.SIGINT, handler) + signal.signal(signal.SIGTERM, handler) + # Disaable the CPLD Heartbeat check to control Fan speed from CPU via ADT7470 + subprocess.getstatusoutput('i2cset -f -y 2 0x32 0x30 0x01') + + monitor = cel_belgite_monitor(log_file, log_level) + + # Loop forever, doing something useful hopefully: + while True: + monitor.manage_fans() + time.sleep(10) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/control b/platform/broadcom/sonic-platform-modules-cel/debian/control index 48ae0ed83735..74cbeb904c10 100644 --- a/platform/broadcom/sonic-platform-modules-cel/debian/control +++ b/platform/broadcom/sonic-platform-modules-cel/debian/control @@ -25,3 +25,8 @@ Package: platform-modules-silverstone Architecture: amd64 Depends: linux-image-5.10.0-8-2-amd64-unsigned Description: kernel modules for platform devices such as led, sfp. + +Package: platform-modules-belgite +Architecture: amd64 +Depends: linux-image-5.10.0-8-2-amd64-unsigned +Description: kernel modules for platform devices such as led, sfp diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-belgite.install b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-belgite.install new file mode 100644 index 000000000000..6f9f8f267ed9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-belgite.install @@ -0,0 +1,7 @@ +belgite/systemd/pddf-platform-init.service etc/systemd/system +belgite/service/belgite-pddf-platform-monitor.service lib/systemd/system +belgite/scripts/pddf_pre_driver_install.sh usr/local/bin +belgite/scripts/pddf_post_device_create.sh usr/local/bin +belgite/utils/belgite_pddf_monitor.py usr/local/bin +belgite/pddf/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-cel_belgite-r0/pddf +services/platform_api/platform_api_mgnt.sh usr/local/bin diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-belgite.postinst b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-belgite.postinst new file mode 100644 index 000000000000..4abd671baec9 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-belgite.postinst @@ -0,0 +1,6 @@ +depmod -a +/usr/local/bin/platform_api_mgnt.sh install +systemctl enable pddf-platform-init.service +systemctl start pddf-platform-init.service +systemctl enable belgite-pddf-platform-monitor.service +systemctl start belgite-pddf-platform-monitor.service diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/rules b/platform/broadcom/sonic-platform-modules-cel/debian/rules index 3a6ef1bfdbef..629034f8cfda 100755 --- a/platform/broadcom/sonic-platform-modules-cel/debian/rules +++ b/platform/broadcom/sonic-platform-modules-cel/debian/rules @@ -5,7 +5,7 @@ export INSTALL_MOD_DIR:=extra KVERSION ?= $(shell uname -r) KERNEL_SRC := /lib/modules/$(KVERSION) MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= dx010 haliburton silverstone seastone2 +MODULE_DIRS:= dx010 haliburton silverstone seastone2 belgite %: dh $@ @@ -13,13 +13,22 @@ MODULE_DIRS:= dx010 haliburton silverstone seastone2 override_dh_auto_build: (for mod in $(MODULE_DIRS); do \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ + cd $(MOD_SRC_DIR)/$${mod}; \ + python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + cd $(MOD_SRC_DIR); \ + if [ -d $(MOD_SRC_DIR)/$${mod}/pddf ]; then \ + cd $(MOD_SRC_DIR)/$${mod}/pddf; \ + if [ -f sonic_platform_setup.py ]; then \ + python3 sonic_platform_setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/pddf; \ + echo "Finished makig pddf whl package for $$mod"; \ + fi; \ + fi; \ if [ $$mod = "seastone2" ]; then \ cd services/platform_api; \ + python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ - continue; \ - fi; \ - cd $(MOD_SRC_DIR)/$${mod}; \ - python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + fi \ done) override_dh_auto_install: @@ -36,4 +45,8 @@ override_dh_clean: dh_clean (for mod in $(MODULE_DIRS); do \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ + if [ -f $(MOD_SRC_DIR)/$${mod}/pddf/*.whl ]; then \ + rm -f $(MOD_SRC_DIR)/$${mod}/pddf/*.whl; \ + fi; \ done) + From e423015d70be53bcd93be7534f9be881b631a3d3 Mon Sep 17 00:00:00 2001 From: jerseyang Date: Wed, 17 Nov 2021 11:14:18 +0800 Subject: [PATCH 02/16] update the cel rules --- .../sonic-platform-modules-cel/debian/rules | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/rules b/platform/broadcom/sonic-platform-modules-cel/debian/rules index 629034f8cfda..b79621ba7e54 100755 --- a/platform/broadcom/sonic-platform-modules-cel/debian/rules +++ b/platform/broadcom/sonic-platform-modules-cel/debian/rules @@ -5,7 +5,7 @@ export INSTALL_MOD_DIR:=extra KVERSION ?= $(shell uname -r) KERNEL_SRC := /lib/modules/$(KVERSION) MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= dx010 haliburton silverstone seastone2 belgite +MODULE_DIRS:= dx010 haliburton silverstone seastone2 %: dh $@ @@ -13,22 +13,24 @@ MODULE_DIRS:= dx010 haliburton silverstone seastone2 belgite override_dh_auto_build: (for mod in $(MODULE_DIRS); do \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ - cd $(MOD_SRC_DIR)/$${mod}; \ - python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ - python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ - cd $(MOD_SRC_DIR); \ - if [ -d $(MOD_SRC_DIR)/$${mod}/pddf ]; then \ - cd $(MOD_SRC_DIR)/$${mod}/pddf; \ - if [ -f sonic_platform_setup.py ]; then \ - python3 sonic_platform_setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/pddf; \ - echo "Finished makig pddf whl package for $$mod"; \ - fi; \ - fi; \ if [ $$mod = "seastone2" ]; then \ cd services/platform_api; \ - python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ - fi \ + continue; \ + fi; \ + if [ $$mod = "belgite" ]; then \ + cd $(MOD_SRC_DIR); \ + if [ -d $(MOD_SRC_DIR)/$${mod}/pddf ]; then \ + cd $(MOD_SRC_DIR)/$${mod}/pddf; \ + if [ -f sonic_platform_setup.py ]; then \ + python3 sonic_platform_setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/pddf; \ + echo "Finished makig pddf whl package for $$mod"; \ + fi; \ + fi; \ + continue; \ + fi; \ + cd $(MOD_SRC_DIR)/$${mod}; \ + python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ done) override_dh_auto_install: @@ -45,8 +47,4 @@ override_dh_clean: dh_clean (for mod in $(MODULE_DIRS); do \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ - if [ -f $(MOD_SRC_DIR)/$${mod}/pddf/*.whl ]; then \ - rm -f $(MOD_SRC_DIR)/$${mod}/pddf/*.whl; \ - fi; \ done) - From a1c7da5abdc85e52c9b1085d5e04bc6f591a7505 Mon Sep 17 00:00:00 2001 From: jerseyang Date: Mon, 22 Nov 2021 15:19:37 +0800 Subject: [PATCH 03/16] [Author] jersey yang [Jira ID]: NA [Description]: fix the compiling error --- platform/broadcom/sonic-platform-modules-cel/debian/rules | 5 ++++- .../services/platform_api/platform_api_mgnt.sh | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/rules b/platform/broadcom/sonic-platform-modules-cel/debian/rules index b79621ba7e54..b6a8fa7187f1 100755 --- a/platform/broadcom/sonic-platform-modules-cel/debian/rules +++ b/platform/broadcom/sonic-platform-modules-cel/debian/rules @@ -5,7 +5,7 @@ export INSTALL_MOD_DIR:=extra KVERSION ?= $(shell uname -r) KERNEL_SRC := /lib/modules/$(KVERSION) MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= dx010 haliburton silverstone seastone2 +MODULE_DIRS:= dx010 haliburton silverstone seastone2 belgite %: dh $@ @@ -47,4 +47,7 @@ override_dh_clean: dh_clean (for mod in $(MODULE_DIRS); do \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ + if [ -f $(MOD_SRC_DIR)/$${mod}/pddf/*.whl ]; then \ + rm -f $(MOD_SRC_DIR)/$${mod}/pddf/*.whl; \ + fi; \ done) diff --git a/platform/broadcom/sonic-platform-modules-cel/services/platform_api/platform_api_mgnt.sh b/platform/broadcom/sonic-platform-modules-cel/services/platform_api/platform_api_mgnt.sh index 7515b81784b4..0f648246ad33 100755 --- a/platform/broadcom/sonic-platform-modules-cel/services/platform_api/platform_api_mgnt.sh +++ b/platform/broadcom/sonic-platform-modules-cel/services/platform_api/platform_api_mgnt.sh @@ -11,6 +11,11 @@ install() { if [ -e $PY3_PACK ]; then pip3 install $PY3_PACK fi + + if [ -e $DEVICE/$PLATFORM/pddf/sonic_platform-1.0-py3-none-any.whl ]; then + PY3_PACK=$DEVICE/$PLATFORM/pddf/sonic_platform-1.0-py3-none-any.whl + pip3 install $PY3_PACK + fi } init() { From ac3a2fe03b5e1e71e5887bfa7884ee83e1bb8be3 Mon Sep 17 00:00:00 2001 From: anjian Date: Sat, 11 Dec 2021 06:42:39 +0000 Subject: [PATCH 04/16] fix the pddf_custom_psu module compiling issue --- .../sonic-platform-modules-cel/belgite/modules/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile index a08f42daa95e..901200ebc9ec 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile @@ -1 +1 @@ -obj-m:= mc24lc64t.o pddf_custom_psu.o pddf_custom_wdt.o +obj-m:= mc24lc64t.o pddf_custom_wdt.o From 7c3a57daaed78485d2ca886d9a71439a883e8e87 Mon Sep 17 00:00:00 2001 From: nicwu Date: Wed, 16 Feb 2022 11:18:18 +0000 Subject: [PATCH 05/16] [Author]:jersyang@celestica.com [Description]:support PDDF customized module --- .../sonic-platform-modules-cel/belgite/modules/Makefile | 2 +- platform/broadcom/sonic-platform-modules-cel/debian/rules | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile index 901200ebc9ec..0e3d1284778d 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/Makefile @@ -1 +1 @@ -obj-m:= mc24lc64t.o pddf_custom_wdt.o +obj-m:= mc24lc64t.o pddf_custom_wdt.o pddf_custom_psu.o diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/rules b/platform/broadcom/sonic-platform-modules-cel/debian/rules index 0948949cccd1..29b2b7913ade 100755 --- a/platform/broadcom/sonic-platform-modules-cel/debian/rules +++ b/platform/broadcom/sonic-platform-modules-cel/debian/rules @@ -1,6 +1,7 @@ #!/usr/bin/make -f export INSTALL_MOD_DIR:=extra +export KBUILD_EXTRA_SYMBOLS := /sonic/platform/pddf/i2c/Module.symvers.PDDF KVERSION ?= $(shell uname -r) KERNEL_SRC := /lib/modules/$(KVERSION) From a20602a489c4ede9d317f942bc137cf6fc39c163 Mon Sep 17 00:00:00 2001 From: nicwu Date: Fri, 18 Feb 2022 05:37:17 +0000 Subject: [PATCH 06/16] [Author]:jersyang@celestica.com [JIRA ID]:NA [Description]:1. change the baud rate to 9600 2. optimize the alert in Azure community --- device/celestica/x86_64-cel_belgite-r0/installer.conf | 2 +- .../belgite/modules/pddf_custom_wdt.c | 2 +- .../belgite/pddf/sonic_platform/__init__.py | 3 ++- .../belgite/pddf/sonic_platform/chassis.py | 2 +- .../belgite/pddf/sonic_platform/eeprom.py | 5 +++-- .../belgite/pddf/sonic_platform/fan_drawer.py | 2 +- .../belgite/pddf/sonic_platform/watchdog.py | 4 ---- .../belgite/pddf/sonic_platform_setup.py | 1 - .../belgite/utils/belgite_pddf_monitor.py | 9 +++++---- 9 files changed, 14 insertions(+), 16 deletions(-) diff --git a/device/celestica/x86_64-cel_belgite-r0/installer.conf b/device/celestica/x86_64-cel_belgite-r0/installer.conf index 9ec2292df5ef..332ea6217a1e 100644 --- a/device/celestica/x86_64-cel_belgite-r0/installer.conf +++ b/device/celestica/x86_64-cel_belgite-r0/installer.conf @@ -1,4 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 -CONSOLE_SPEED=115200 +CONSOLE_SPEED=9600 ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog" diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c index a60f92031a0c..93998b718539 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c @@ -308,7 +308,7 @@ static ssize_t reason_show(struct device *dev, bootstatus = watchdog_get_reason(wdt); - return sprintf(buf, "0x%02\n", bootstatus); + return sprintf(buf, "0x%02x\n", bootstatus); } static DEVICE_ATTR_RO(reason); diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/__init__.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/__init__.py index 2dc71f83c00d..0533d11584e1 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/__init__.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/__init__.py @@ -1,3 +1,4 @@ # All the derived classes for PDDF __all__ = ["platform", "chassis", "sfp", "psu", "thermal"] -from sonic_platform import * +from sonic_platform import * #[py/polluting-import] + diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py index d8a7fb91f517..6d36345fbe8b 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py @@ -25,7 +25,7 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): with open(FAN_DIRECTION_FILE_PATH, "w+") as f: f.write(vendor_ext) for i in range(self.platform_inventory['num_fantrays']): - fandrawer = FanDrawer(i, self.pddf_obj, self.plugin_data) + fandrawer = FanDrawer(i, self.pddf_obj, self.plugin_data) #lgtm [py/call/wrong-number-class-arguments] self._fan_drawer_list.append(fandrawer) self._fan_list.extend(fandrawer._fan_list) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py index 8309e759fca6..b79af685ff22 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py @@ -23,7 +23,8 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): if self.eeprom_path is None: return - super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) + #super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) + super().__init__(self.eeprom_path, 0, '', True) self.eeprom_tlv_dict = dict() try: self.eeprom_data = self.read_eeprom() @@ -49,7 +50,7 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): code = "0x%02X" % ((tlv[0])) if (tlv[0]) == self._TLV_CODE_VENDOR_EXT: - name = "Vendor Extension" + name = "Vendor Extension" #lgtm [py/multiple-definition] value = "" if self._TLV_DISPLAY_VENDOR_EXT: for c in tlv[2:2 + tlv[1]]: diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py index de08675c067f..7e3fd75bbe19 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py @@ -34,7 +34,7 @@ def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): self.fantray_index = tray_idx+1 for j in range(self.platform['num_fans_pertray']): # Fan index is 0-based for the init call - self._fan_list.append(Fan(tray_idx, j, self.pddf_obj, self.plugin_data)) + self._fan_list.append(Fan(tray_idx, j, self.pddf_obj, self.plugin_data)) #lgtm [py/call/wrong-number-class-arguments] def get_name(self): """ diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py index 7aa635cbe790..789c04addf1e 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py @@ -5,13 +5,9 @@ # Watchdog contains an implementation of SONiC Platform Base Watchdog API # ############################################################################# -import ctypes import fcntl import os -import subprocess -import time import array -import syslog try: from sonic_platform_base.watchdog_base import WatchdogBase diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform_setup.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform_setup.py index a1535165bb66..159e26656138 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform_setup.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform_setup.py @@ -1,5 +1,4 @@ import os -import sys from setuptools import setup os.listdir diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/utils/belgite_pddf_monitor.py b/platform/broadcom/sonic-platform-modules-cel/belgite/utils/belgite_pddf_monitor.py index b676c856592b..017a04709f3c 100755 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/utils/belgite_pddf_monitor.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/utils/belgite_pddf_monitor.py @@ -28,6 +28,7 @@ import logging.config import time # this is only being used as part of the example import signal + import math from sonic_platform import platform except ImportError as e: raise ImportError('%s - required module not found' % str(e)) @@ -121,21 +122,21 @@ def get_fan_speed_by_temperature(self, temp_list): # U4 U7 if not update_temp_sensor: # temperature down - b = 1400/13 + b = math.trunc(1400/13) if sensor_temp <= 32000: sensor_temp_speed = 40 elif sensor_temp >= 45000: sensor_temp_speed = 100 else: - sensor_temp_speed = int((60 / 13) * int(sensor_temp / 1000) - b) + sensor_temp_speed = int(math.trunc(60 / 13) * math.trunc(sensor_temp / 1000) - b) else: # temperature up - b = 1580 / 13 + b = math.trunc(1580 / 13) if sensor_temp <= 35000: sensor_temp_speed = 40 elif sensor_temp >= 48000: sensor_temp_speed = 100 else: - sensor_temp_speed = int((60/13) * int(sensor_temp/1000) - b) + sensor_temp_speed = int(math.trunc(60/13) * math.trunc(sensor_temp/1000) - b) # CPU if not update_temp_cpu: # temperature down From 9da2b1bf94cd187f5b85ca3eac46bf668fc4f0ce Mon Sep 17 00:00:00 2001 From: nicwu Date: Mon, 28 Feb 2022 01:50:38 +0000 Subject: [PATCH 07/16] [Author]:jersyang@celestica.com [Jira ID]:NA [Description]:fix the PDDF compliance with branch 202106 --- .../belgite/pddf/sonic_platform/chassis.py | 2 +- .../belgite/pddf/sonic_platform/eeprom.py | 4 +- .../belgite/pddf/sonic_platform/platform.py | 40 ++++++++++--------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py index 6d36345fbe8b..5616d2215af0 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py @@ -21,7 +21,7 @@ class Chassis(PddfChassis): def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) - vendor_ext = self.sys_eeprom.vendor_ext_str() + vendor_ext = self._eeprom.vendor_ext_str() with open(FAN_DIRECTION_FILE_PATH, "w+") as f: f.write(vendor_ext) for i in range(self.platform_inventory['num_fantrays']): diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py index b79af685ff22..bc1ef6420b68 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py @@ -23,8 +23,8 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): if self.eeprom_path is None: return - #super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) - super().__init__(self.eeprom_path, 0, '', True) + super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) + #super().__init__(self.pddf_obj, self.plugin_data) self.eeprom_tlv_dict = dict() try: self.eeprom_data = self.read_eeprom() diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py index aa11b0a52bf3..1b548d880e78 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py @@ -7,32 +7,34 @@ try: import json - from sonic_platform_pddf_base.pddfparse import PddfParse - from sonic_platform_base.platform_base import PlatformBase +# from . import pddfapi +# from sonic_platform_base.platform_base import PlatformBase + from sonic_platform_pddf_base.pddf_platform import PddfPlatform from sonic_platform.chassis import Chassis except ImportError as e: raise ImportError(str(e) + "- required module not found") -class PddfPlatform(PlatformBase): - """ - PDDF Generic Platform class - """ - pddf_data = {} - pddf_plugin_data = {} - - def __init__(self): +#class PddfPlatform(PlatformBase): +# """ +# PDDF Generic Platform class +# """ +# pddf_obj = {} +# pddf_plugin_data = {} +# +# def __init__(self): # Initialize the JSON data - self.pddf_data = PddfParse() - with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd: - self.pddf_plugin_data = json.load(pd) - - if not self.pddf_data or not self.pddf_plugin_data: - print("Error: PDDF JSON data is not loaded properly ... Exiting") - raise ValueError + +# self.pddf_data = pddfapi.PddfApi() +# with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd: +# self.pddf_plugin_data = json.load(pd) +# +# if not self.pddf_data or not self.pddf_plugin_data: +# print("Error: PDDF JSON data is not loaded properly ... Exiting") +# raise ValueError - PlatformBase.__init__(self) - self._chassis = Chassis(self.pddf_data, self.pddf_plugin_data) +# PlatformBase.__init__(self) +# self._chassis = Chassis(self.pddf_data, self.pddf_plugin_data) class Platform(PddfPlatform): """ From 77bfe8cd704b1cf3cb0821effdc4f721b570741e Mon Sep 17 00:00:00 2001 From: sandycelestica Date: Fri, 25 Mar 2022 06:50:53 +0000 Subject: [PATCH 08/16] correct the config.bcm or else SAI can not run well --- .../CELESTICA-BELGITE/belgite.config.bcm | 136 ++++++++++-------- 1 file changed, 80 insertions(+), 56 deletions(-) diff --git a/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/belgite.config.bcm b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/belgite.config.bcm index 0e451d472108..a249804582c9 100644 --- a/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/belgite.config.bcm +++ b/device/celestica/x86_64-cel_belgite-r0/CELESTICA-BELGITE/belgite.config.bcm @@ -1,66 +1,85 @@ +## 48xGE+4x10G+2xHGd[21] +phy_chain_rx_polarity_flip_physical{29.0}=1 +bcm_num_cos=8 +stable_size=0x5500000 +ifp_inports_support_enable=1 +ipv6_lpm_128b_enable=0x1 +l2xmsg_mode=1 +l2_mem_entries=32768 +l3_mem_entries=16384 +lpm_scaling_enable=0 +l3_alpm_enable=0 +riot_enable=0 +port_flex_enable=1 + +#Core clock Frequency +core_clock_frequency=266 + + #GPORT0 -portmap_25.0=2:1 +portmap_25=2:1 phy_port_primary_and_offset_25=0x0100 -portmap_26.0=1:1 +portmap_26=1:1 phy_port_primary_and_offset_26=0x0101 -portmap_27.0=4:1 +portmap_27=4:1 phy_port_primary_and_offset_27=0x0102 -portmap_28.0=3:1 +portmap_28=3:1 phy_port_primary_and_offset_28=0x0103 -portmap_29.0=6:1 +portmap_29=6:1 phy_port_primary_and_offset_29=0x0500 -portmap_30.0=5:1 +portmap_30=5:1 phy_port_primary_and_offset_30=0x0501 -portmap_31.0=8:1 +portmap_31=8:1 phy_port_primary_and_offset_31=0x0502 -portmap_32.0=7:1 +portmap_32=7:1 phy_port_primary_and_offset_32=0x0503 #GPORT1 -portmap_33.0=10:1 +portmap_33=10:1 phy_port_primary_and_offset_33=0x0900 -portmap_34.0=9:1 +portmap_34=9:1 phy_port_primary_and_offset_34=0x0901 -portmap_35.0=12:1 +portmap_35=12:1 phy_port_primary_and_offset_35=0x0902 -portmap_36.0=11:1 +portmap_36=11:1 phy_port_primary_and_offset_36=0x0903 -portmap_37.0=14:1 +portmap_37=14:1 phy_port_primary_and_offset_37=0x0d00 -portmap_38.0=13:1 +portmap_38=13:1 phy_port_primary_and_offset_38=0x0d01 -portmap_39.0=16:1 +portmap_39=16:1 phy_port_primary_and_offset_39=0x0d02 -portmap_40.0=15:1 +portmap_40=15:1 phy_port_primary_and_offset_40=0x0d03 #GPORT2 -portmap_41.0=18:1 +portmap_41=18:1 phy_port_primary_and_offset_41=0x1101 -portmap_42.0=17:1 +portmap_42=17:1 phy_port_primary_and_offset_42=0x1100 -portmap_43.0=20:1 +portmap_43=20:1 phy_port_primary_and_offset_43=0x1103 -portmap_44.0=19:1 +portmap_44=19:1 phy_port_primary_and_offset_44=0x1102 -portmap_45.0=22:1 +portmap_45=22:1 phy_port_primary_and_offset_45=0x1501 -portmap_46.0=21:1 +portmap_46=21:1 phy_port_primary_and_offset_46=0x1500 -portmap_47.0=24:1 +portmap_47=24:1 phy_port_primary_and_offset_47=0x1503 -portmap_48.0=23:1 +portmap_48=23:1 phy_port_primary_and_offset_48=0x1502 #PM4x10Q0 -portmap_1.0=26:1 -portmap_2.0=25:1 -portmap_3.0=28:1 -portmap_4.0=27:1 -portmap_5.0=30:1 -portmap_6.0=29:1 -portmap_7.0=32:1 -portmap_8.0=31:1 +port_gmii_mode{25}=1 +portmap_1=26:1 +portmap_2=25:1 +portmap_3=28:1 +portmap_4=27:1 +portmap_5=30:1 +portmap_6=29:1 +portmap_7=32:1 +portmap_8=31:1 phy_port_primary_and_offset_2=0x1900 phy_port_primary_and_offset_1=0x1901 phy_port_primary_and_offset_4=0x1902 @@ -78,14 +97,14 @@ port_phy_addr_5=0x06 port_phy_addr_8=0x07 port_phy_addr_7=0x08 -portmap_9.0=34:1 -portmap_10.0=33:1 -portmap_11.0=36:1 -portmap_12.0=35:1 -portmap_13.0=38:1 -portmap_14.0=37:1 -portmap_15.0=40:1 -portmap_16.0=39:1 +portmap_9=34:1 +portmap_10=33:1 +portmap_11=36:1 +portmap_12=35:1 +portmap_13=38:1 +portmap_14=37:1 +portmap_15=40:1 +portmap_16=39:1 phy_port_primary_and_offset_10=0x2100 phy_port_primary_and_offset_9=0x2101 @@ -105,14 +124,15 @@ port_phy_addr_16=0x30 port_phy_addr_15=0x31 #PM4x10Q1 -portmap_17.0=42:1 -portmap_18.0=41:1 -portmap_19.0=44:1 -portmap_20.0=43:1 -portmap_21.0=50:1 -portmap_22.0=49:1 -portmap_23.0=52:1 -portmap_24.0=51:1 +port_gmii_mode{41}=1 +portmap_17=42:1 +portmap_18=41:1 +portmap_19=44:1 +portmap_20=43:1 +portmap_21=50:1 +portmap_22=49:1 +portmap_23=52:1 +portmap_24=51:1 phy_port_primary_and_offset_18=0x2900 phy_port_primary_and_offset_17=0x2901 @@ -132,14 +152,18 @@ port_phy_addr_24=0x59 port_phy_addr_23=0x5a #PM4x25 -portmap_49.0=60:10 -portmap_50.0=58:10 -portmap_51.0=59:10 -portmap_52.0=57:10 +portmap_49=60:10 +portmap_50=58:10 +portmap_51=59:10 +portmap_52=57:10 ##PM4x10HG -portmap_53.0=62:10 -portmap_54.0=64:10 -portmap_55.0=61:10 -portmap_56.0=63:10 +portmap_53=62:10 +portmap_54=64:10 +portmap_55=61:10 +portmap_56=63:10 + + +pbmp_xport_xe=0x01FFFFFFFFFFFFFE +# \ No newline at end of file From 138ba897b62490417b11706080bede93eb0b0e9f Mon Sep 17 00:00:00 2001 From: nicwu Date: Mon, 11 Apr 2022 09:51:41 +0000 Subject: [PATCH 09/16] [Author]:jersyang@celestica.com [Jira ID]:N/A [Description]:fix the watchdog issue --- .../belgite/modules/pddf_custom_wdt.c | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c index 93998b718539..190fa85471cf 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c @@ -114,7 +114,7 @@ static unsigned int watchdog_get_timeleft(struct cpld_wdt_private *wdt) time = time << 8 | inb(WDT_TIMER_L_BIT_REG); time = time/1000; mutex_unlock(&wdt->wdat.lock); - + //pr_crit("Watchdog Get Timeleft:%u\n", time); return time; } static int watchdog_get_timeout(struct cpld_wdt_private *wdt) @@ -153,7 +153,7 @@ static int watchdog_set_timeout(struct cpld_wdt_private *wdt, unsigned int timeo wdt->wdat.timer_val = timeout; } /* Set timer value */ - pr_crit("Watchdog Timeout:0x%06x\n", wdt->wdat.timer_val); + //pr_crit("Watchdog Timeout:0x%06x\n", wdt->wdat.timer_val); outb((wdt->wdat.timer_val >> 16) & 0xff, WDT_SET_TIMER_H_BIT_REG); outb((wdt->wdat.timer_val >> 8) & 0xff, WDT_SET_TIMER_M_BIT_REG); @@ -175,7 +175,7 @@ static int watchdog_ping(struct cpld_wdt_private *wdt) outb(WDT_START_FEED, WDT_FEED_REG); /* stop feed watchdog */ outb(WDT_STOP_FEED, WDT_FEED_REG); - + //pr_crit("Watchdog Ping\n"); mutex_unlock(&wdt->wdat.lock); return 0; @@ -183,16 +183,22 @@ static int watchdog_ping(struct cpld_wdt_private *wdt) static void watchdog_keepalive(struct cpld_wdt_private *wdt) { + unsigned char val = 0; if(!wdt) return; mutex_lock(&wdt->wdat.lock); - /* start feed watchdog */ - outb(WDT_START_FEED, WDT_FEED_REG); - /* stop feed watchdog */ - outb(WDT_STOP_FEED, WDT_FEED_REG); - + val = inb(WDT_FEED_REG); + + val &= 0x1; + + val = ~val; + + val &= 0x1; + /* start feed watchdog */ + outb(val, WDT_FEED_REG); + //pr_crit("Watchdog Keepalive\n"); mutex_unlock(&wdt->wdat.lock); return; } @@ -208,7 +214,7 @@ static int watchdog_start(struct cpld_wdt_private *wdt) outb(WDT_ENABLE, WDT_ENABLE_REG); outb(WDT_RESTART, WDT_PUNCH_REG); mutex_unlock(&wdt->wdat.lock); - + //pr_crit("Watchdog Start:Enable and PUNCH\n"); return 0; } @@ -220,6 +226,7 @@ static int watchdog_stop(struct cpld_wdt_private *wdt) mutex_lock(&wdt->wdat.lock); outb(WDT_DISABLE, WDT_ENABLE_REG); mutex_unlock(&wdt->wdat.lock); + //pr_crit("Watchdog Stop\n"); return 0; } @@ -392,7 +399,7 @@ static int watchdog_release(struct inode *inode, struct file *file) clear_bit(0, &p->wdat.opened); if (!p->wdat.expect_close) { - watchdog_keepalive(p); + //watchdog_keepalive(p); //pr_crit("Unexpected close, Not stopping watchdog!\n"); } else if (!nowayout) { //pr_crit("Cpld Watchdog Stopped!\n"); @@ -515,7 +522,7 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd, new_timeout = new_timeout*1000; if (watchdog_set_timeout(p, new_timeout)) return -EINVAL; - watchdog_keepalive(p); + //watchdog_keepalive(p); /* Fall */ return 0; case WDIOC_GETTIMEOUT: From 38fce5f635b0c3c9913026e68b3439a4c31eb408 Mon Sep 17 00:00:00 2001 From: nicwu Date: Mon, 11 Apr 2022 11:00:06 +0000 Subject: [PATCH 10/16] [Author]:jersyang@celestica.com [Jira ID]:N/A [Description]: fix fan led issue --- .../belgite/pddf/sonic_platform/fan.py | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py index 8b39b847258d..871e135f4fd6 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py @@ -3,6 +3,12 @@ import os except ImportError as e: raise ImportError(str(e) + "- required module not found") +# ------------------------------------------------------------------ +# HISTORY: +# 5/1/2022 (A.D.) +# add function:set_status_led, +# Solve the problem that when a fan is pulled out, the Fan LED on the front panel is still green Issue-#11525 +# ------------------------------------------------------------------ FAN_DIRECTION_FILE_PATH = "/var/fan_direction" @@ -62,3 +68,46 @@ def get_status(self): status = True if (speed != 0) else False return status + 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) + """ + target_speed = 0 + if self.is_psu_fan: + # Target speed not usually supported for PSU fans + target_speed = "N/A" + else: + idx = (self.fantray_index - 1) * 1 + self.fan_index + attr = "fan" + str(idx) + "_pwm" + pwm_path = "/sys/devices/pci0000:00/0000:00:12.0/i2c-0/i2c-2/2-0066/" + attr + pwm = 0 + with open(pwm_path, "r") as f: + pwm = f.read() + + percentage = int(pwm.strip()) + speed_percentage = int(round(percentage / 255 * 100)) + target_speed = speed_percentage + + return target_speed + + def set_status_led(self, color): + color_dict = {"green": "STATUS_LED_COLOR_GREEN", + "red": "STATUS_LED_COLOR_AMBER"} + color = color_dict.get(color, "off") + index = str(self.fantray_index - 1) + led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED" + + result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color) + if result is False: + return False + device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] + self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) + self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) + self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path()) + + self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path()) + return True From 84c953b196cc2ea24e3e2e8f0f4254d1611906d8 Mon Sep 17 00:00:00 2001 From: nicwu Date: Tue, 12 Apr 2022 12:15:48 +0000 Subject: [PATCH 11/16] [Author]:jersyang@celesitca.com [Jira ID]:N/A [Description]:fix the thermal API testbed issues --- .../belgite/pddf/sonic_platform/thermal.py | 99 ++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py index 99b743c6d343..f5426b75bd83 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py @@ -10,5 +10,102 @@ class Thermal(PddfThermal): def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data) - + self.minimum_thermal = self.get_temperature() + self.maximum_thermal = self.get_temperature() # Provide the functions/variables below for which implementation is to be overwritten + + 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 + """ + return 0.001 + + 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 + """ + + return 100.000 + + 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 + """ + tmp = self.get_temperature() + if tmp < self.minimum_thermal: + self.minimum_thermal = tmp + + return self.minimum_thermal + + 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 + """ + tmp = self.get_temperature() + if tmp > self.maximum_thermal: + self.maximum_thermal = tmp + + return self.maximum_thermal + + def get_presence(self): + """ + Retrieves the presence of the PSU + 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 device + Returns: + string: Model/part number of device + """ + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return "N/A" + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + if not self.get_presence(): + return False + + return True + + def is_replaceable(self): + """ + Retrieves whether thermal module is replaceable + Returns: + A boolean value, True if replaceable, False if not + """ + return False + + def get_position_in_parent(self): + """ + Retrieves the thermal position information + Returns: + A int value, 0 represent ASIC thermal, 1 represent CPU thermal info + """ + return 0 From c97ce76058da7580d2344f0b04efe6ed3ce5ceaf Mon Sep 17 00:00:00 2001 From: nicwu Date: Wed, 20 Apr 2022 06:26:09 +0000 Subject: [PATCH 12/16] [Author]:jersyang@celesitca.com [Jira ID]:N/A [Description]:fix the testbed chassis/fan/psu API issues --- .../x86_64-cel_belgite-r0/platform.json | 403 ++++++++++++++++++ .../belgite/pddf/sonic_platform/chassis.py | 74 ++++ .../belgite/pddf/sonic_platform/component.py | 119 ++++++ .../belgite/pddf/sonic_platform/fan.py | 33 ++ .../belgite/pddf/sonic_platform/psu.py | 17 + 5 files changed, 646 insertions(+) create mode 100644 device/celestica/x86_64-cel_belgite-r0/platform.json create mode 100644 platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py diff --git a/device/celestica/x86_64-cel_belgite-r0/platform.json b/device/celestica/x86_64-cel_belgite-r0/platform.json new file mode 100644 index 000000000000..31fbe1d9d1b1 --- /dev/null +++ b/device/celestica/x86_64-cel_belgite-r0/platform.json @@ -0,0 +1,403 @@ +{ + "chassis": { + "name": "E1070", + "status_led": { + "controllable": true, + "colors": ["green", "amber", "off"] + }, + "thermal_manager": false, + "components": [ + { + "name": "SWCPLD" + }, + { + "name": "Main_BIOS" + }, + { + "name": "Backup_BIOS" + } + ], + "fans": [ + { + "name": "Fantray1_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + }, + { + "name": "Fantray2_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + }, + { + "name": "Fantray3_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + }, + { + "name": "Fantray1_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + }, + { + "name": "Fantray2_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + }, + { + "name": "Fantray3_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + } + ], + "fan_drawers": [ + { + "name": "Fantray1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + }, + "max_consumed_power": false, + "fans": [ + { + "name": "Fantray1_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + } + ] + }, + { + "name": "Fantray2", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + }, + "max_consumed_power": false, + "fans": [ + { + "name": "Fantray2_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + } + ] + }, + { + "name": "Fantray3", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + }, + "max_consumed_power": false, + "fans": [ + { + "name": "Fantray3_1", + "speed": { + "controllable": false + }, + "status_led": { + "controllable": true, + "colors": ["green", "amber","off"] + } + } + ] + } + ], + "psus": [ + { + "name": "PSU1", + "fans": [ + { + "name": "PSU1_FAN1", + "speed": { + "controllable": true, + "minimum": 25, + "maximum": 100 + }, + "status_led": { + "controllable": false + } + } + ], + "current": true, + "power": true, + "max_power": false, + "voltage_high_threshold": false, + "voltage_low_threshold": false, + "temperature": false, + "status_led": { + "controllable": false + } + }, + { + "name": "PSU2", + "fans": [ + { + "name": "PSU2_FAN1", + "speed": { + "controllable": true, + "minimum": 25, + "maximum": 100 + }, + "status_led": { + "controllable": false + } + } + ], + "current": true, + "power": true, + "max_power": false, + "voltage_high_threshold": false, + "voltage_low_threshold": false, + "temperature": false, + "status_led": { + "controllable": false + } + } + ], + "thermals": [ + { + "name": "LM75_U10", + "controllable": false, + "low-threshold": false, + "low-crit-threshold": true + }, + { + "name": "LM75_U4", + "controllable": false, + "low-threshold": false, + "low-crit-threshold": true + }, + { + "name": "LM75_U7", + "controllable": false, + "low-threshold": false, + "low-crit-threshold": true + }, + { + "name": "LM75_U60", + "controllable": false, + "low-threshold": false, + "low-crit-threshold": true + } + ], + "sfps": [ + { + "name": "PORT0" + }, + { + "name": "PORT1" + }, + { + "name": "PORT2" + }, + { + "name": "PORT3" + }, + { + "name": "PORT4" + }, + { + "name": "PORT5" + }, + { + "name": "PORT6" + }, + { + "name": "PORT7" + }, + { + "name": "PORT8" + }, + { + "name": "PORT9" + }, + { + "name": "PORT10" + }, + { + "name": "PORT11" + }, + { + "name": "PORT12" + }, + { + "name": "PORT13" + }, + { + "name": "PORT14" + }, + { + "name": "PORT15" + }, + { + "name": "PORT16" + }, + { + "name": "PORT17" + }, + { + "name": "PORT18" + }, + { + "name": "PORT19" + }, + { + "name": "PORT20" + }, + { + "name": "PORT21" + }, + { + "name": "PORT22" + }, + { + "name": "PORT23" + }, + { + "name": "PORT24" + }, + { + "name": "PORT25" + }, + { + "name": "PORT26" + }, + { + "name": "PORT27" + }, + { + "name": "PORT28" + }, + { + "name": "PORT29" + }, + { + "name": "PORT30" + }, + { + "name": "PORT31" + }, + { + "name": "PORT32" + }, + { + "name": "PORT33" + }, + { + "name": "PORT34" + }, + { + "name": "PORT35" + }, + { + "name": "PORT36" + }, + { + "name": "PORT37" + }, + { + "name": "PORT38" + }, + { + "name": "PORT39" + }, + { + "name": "PORT40" + }, + { + "name": "PORT41" + }, + { + "name": "PORT42" + }, + { + "name": "PORT43" + }, + { + "name": "PORT44" + }, + { + "name": "PORT45" + }, + { + "name": "PORT46" + }, + { + "name": "PORT47" + }, + { + "name": "PORT48" + }, + { + "name": "PORT49" + }, + { + "name": "PORT50" + }, + { + "name": "PORT51" + }, + { + "name": "PORT52" + }, + { + "name": "PORT53" + }, + { + "name": "PORT54" + }, + { + "name": "PORT55" + } + ] + }, + "interfaces": {} +} diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py index 5616d2215af0..f1b7209ad6ff 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py @@ -3,14 +3,20 @@ # Module contains an implementation of SONiC Chassis API # ############################################################################# +import os try: from sonic_platform_pddf_base.pddf_chassis import PddfChassis + from sonic_platform_pddf_base.pddf_eeprom import PddfEeprom + from sonic_platform_base.chassis_base import ChassisBase from sonic_platform.fan_drawer import FanDrawer from sonic_platform.watchdog import Watchdog + import sys + import subprocess except ImportError as e: raise ImportError(str(e) + "- required module not found") +NUM_COMPONENT = 3 FAN_DIRECTION_FILE_PATH = "/var/fan_direction" @@ -28,6 +34,13 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): fandrawer = FanDrawer(i, self.pddf_obj, self.plugin_data) #lgtm [py/call/wrong-number-class-arguments] self._fan_drawer_list.append(fandrawer) self._fan_list.extend(fandrawer._fan_list) + self.__initialize_components() + + def __initialize_components(self): + from sonic_platform.component import Component + for index in range(0, NUM_COMPONENT): + component = Component(index) + self._component_list.append(component) # Provide the functions/variables below for which implementation is to be overwritten @@ -67,3 +80,64 @@ def get_watchdog(self): self._watchdog = Watchdog() return self._watchdog + 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. + """ + hw_reboot_cause = "" + with open("/sys/devices/platform/cpld_wdt/reason", "r") as f: + hw_reboot_cause = f.read().strip() + + if hw_reboot_cause == "0x77": + reboot_cause = self.REBOOT_CAUSE_WATCHDOG + description = 'Hardware Watchdog Reset' + elif hw_reboot_cause == "0x66": + reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER + description = 'GPIO Request Warm Reset' + elif hw_reboot_cause == "0x55": + reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER + description = 'CPU Cold Reset' + elif hw_reboot_cause == "0x44": + reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE + description = 'CPU Warm Reset' + elif hw_reboot_cause == "0x33": + reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE + description = 'Soft-Set Cold Reset' + elif hw_reboot_cause == "0x22": + reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE + description = 'Soft-Set Warm Reset' + elif hw_reboot_cause == "0x11": + reboot_cause = self.REBOOT_CAUSE_POWER_LOSS + description = 'Power Loss' + else: + reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE + description = 'Unkown Reason' + + return (reboot_cause, description) + + def get_serial(self): + return self._eeprom.serial_number_str() + + def get_revision(self): + return self._eeprom.revision_str() + + @staticmethod + def get_position_in_parent(): + return -1 + + @staticmethod + def is_replaceable(): + return True + + def get_base_mac(self): + return self._eeprom.base_mac_addr() + + def get_system_eeprom_info(self): + return self._eeprom.system_eeprom_info() + diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py new file mode 100644 index 000000000000..4b8a3ffaffb4 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python + +############################################################################# +# Celestica +# +# Component contains an implementation of SONiC Platform Base API and +# provides the components firmware management function +# +############################################################################# + +import os.path +import subprocess +import time +import os + +try: + from sonic_platform_base.component_base import ComponentBase + #from helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +SWCPLD_VERSION_PATH = "i2cget -y -f 2 0x32 0" +BIOS_VERSION_PATH = "dmidecode -t bios | grep Version" +COMPONENT_NAME_LIST = ["SWCPLD", "Main_BIOS", "Backup_BIOS"] +COMPONENT_DES_LIST = ["Use for boot control and BIOS switch", + "Main basic Input/Output System", + "Backup basic Input/Output System"] + + +class Component(ComponentBase): + """Platform-specific Component class""" + + DEVICE_TYPE = "component" + + def __init__(self, component_index): + ComponentBase.__init__(self) + self.index = component_index + #self._api_helper = APIHelper() + self.name = self.get_name() + + def run_command(self,cmd): + responses = os.popen(cmd).read() + return responses + + def __get_bios_version(self): + # Retrieves the BIOS firmware version + result = self.run_command("i2cget -y -f 2 0x32 0x19") + if result.strip() == "0x01": + if self.name == "Main_BIOS": + version = self.run_command(BIOS_VERSION_PATH) + bios_version = version.strip().split(" ")[1] + return str(bios_version) + elif self.name == "Backup_BIOS": + bios_version = "na" + return bios_version + + elif result.strip() == "0x03": + if self.name == "Backup_BIOS": + version = self.run_command(BIOS_VERSION_PATH) + bios_version = version.strip().split(" ")[1] + return str(bios_version) + elif self.name == "Main_BIOS": + bios_version = "na" + return bios_version + + def __get_cpld_version(self): + if self.name == "SWCPLD": + ver = self.run_command(SWCPLD_VERSION_PATH) + print("ver is %s" % ver) + ver = ver.strip().split("x")[1] + print("ver2 is %s" % ver) + version = int(ver.strip()) / 10 + return str(version) + + + def get_name(self): + """ + Retrieves the name of the component + Returns: + A string containing the name of the component + """ + return COMPONENT_NAME_LIST[self.index] + + def get_description(self): + """ + Retrieves the description of the component + Returns: + A string containing the description of the component + """ + return COMPONENT_DES_LIST[self.index] + + def get_firmware_version(self): + """ + Retrieves the firmware version of module + Returns: + string: The firmware versions of the module + """ + fw_version = None + + if "BIOS" in self.name: + fw_version = self.__get_bios_version() + elif "CPLD" in self.name: + fw_version = self.__get_cpld_version() + + return fw_version + + def install_firmware(self, image_path): + """ + Install firmware to module + Args: + image_path: A string, path to firmware image + Returns: + A boolean, True if install successfully, False if not + """ + return False + + def update_firmware(self, image_path): + + return False diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py index 871e135f4fd6..36e95f2c0c08 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan.py @@ -111,3 +111,36 @@ def set_status_led(self, color): self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path()) return True + + @staticmethod + def get_model(): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + model = "Unknown" + return model + + @staticmethod + def get_serial(): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + serial = "Unknown" + return serial + + def get_position_in_parent(self): + """ + Retrieves the fan/psu fan index number + """ + return self.fantray_index if not self.is_psu_fan else self.fans_psu_index + 4 + + @staticmethod + def is_replaceable(): + """ + Retrieves whether the device is replaceable + """ + return False diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py index 2ba3f2e152ad..0e2c925a0f07 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py @@ -34,3 +34,20 @@ def get_type(self): # This platform supports AC PSU return ptype + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + + def get_position_in_parent(self): + """ + Retrieves the psu index number + """ + return self.psu_index + + def get_revision(self): + + return "N/A" From 318e5eaee017e68cf1bea50ce6326a09b37fe5de Mon Sep 17 00:00:00 2001 From: nicwu-cel Date: Mon, 25 Apr 2022 12:54:33 +0000 Subject: [PATCH 13/16] [Author]:jersyang@celestica.com [Jira ID]:N/A [Description]: update code to be compatiable BRCM PDDF update --- .../x86_64-cel_belgite-r0/installer.conf | 2 +- .../belgite/pddf/sonic_platform/chassis.py | 5 +- .../belgite/pddf/sonic_platform/eeprom.py | 57 +-------------- .../belgite/pddf/sonic_platform/fan_drawer.py | 71 +------------------ .../belgite/pddf/sonic_platform/platform.py | 26 ------- .../belgite/pddf/sonic_platform/thermal.py | 4 +- .../sonic_platform_pddf_base/pddf_sfp.py | 1 + .../sonic_platform_pddf_base/pddf_thermal.py | 1 + .../sonic_platform_pddf_base/pddfapi.py | 2 + 9 files changed, 10 insertions(+), 159 deletions(-) diff --git a/device/celestica/x86_64-cel_belgite-r0/installer.conf b/device/celestica/x86_64-cel_belgite-r0/installer.conf index 332ea6217a1e..61846e4455e0 100644 --- a/device/celestica/x86_64-cel_belgite-r0/installer.conf +++ b/device/celestica/x86_64-cel_belgite-r0/installer.conf @@ -1,4 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 CONSOLE_SPEED=9600 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog" +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog" diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py index f1b7209ad6ff..6595f365efa8 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py @@ -30,10 +30,7 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): vendor_ext = self._eeprom.vendor_ext_str() with open(FAN_DIRECTION_FILE_PATH, "w+") as f: f.write(vendor_ext) - for i in range(self.platform_inventory['num_fantrays']): - fandrawer = FanDrawer(i, self.pddf_obj, self.plugin_data) #lgtm [py/call/wrong-number-class-arguments] - self._fan_drawer_list.append(fandrawer) - self._fan_list.extend(fandrawer._fan_list) + self.__initialize_components() def __initialize_components(self): diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py index bc1ef6420b68..b49c65ffe571 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py @@ -6,63 +6,8 @@ class Eeprom(PddfEeprom): - _TLV_DISPLAY_VENDOR_EXT = True - _TLV_INFO_MAX_LEN = 256 - pddf_obj = {} - plugin_data = {} - def __init__(self, pddf_data=None, pddf_plugin_data=None): - if not pddf_data or not pddf_plugin_data: - raise ValueError('PDDF JSON data error') - - self.pddf_obj = pddf_data - self.plugin_data = pddf_plugin_data - - # system EEPROM always has device name EEPROM1 - self.eeprom_path = self.pddf_obj.get_path("EEPROM1", "eeprom") - if self.eeprom_path is None: - return - - super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) - #super().__init__(self.pddf_obj, self.plugin_data) - self.eeprom_tlv_dict = dict() - try: - self.eeprom_data = self.read_eeprom() - except Exception as e: - self.eeprom_data = "N/A" - raise RuntimeError("PddfEeprom is not Programmed - Error: {}".format(str(e))) - else: - eeprom = self.eeprom_data - - if not self.is_valid_tlvinfo_header(eeprom): - return - - total_length = ((eeprom[9]) << 8) | (eeprom[10]) - tlv_index = self._TLV_INFO_HDR_LEN - tlv_end = self._TLV_INFO_HDR_LEN + total_length - - while (tlv_index + 2) < self._TLV_INFO_MAX_LEN and tlv_index < tlv_end: - if not self.is_valid_tlv(eeprom[tlv_index:]): - break - - tlv = eeprom[tlv_index:tlv_index + 2 - + (eeprom[tlv_index + 1])] - code = "0x%02X" % ((tlv[0])) - - if (tlv[0]) == self._TLV_CODE_VENDOR_EXT: - name = "Vendor Extension" #lgtm [py/multiple-definition] - value = "" - if self._TLV_DISPLAY_VENDOR_EXT: - for c in tlv[2:2 + tlv[1]]: - value += "0x%02X " % c - else: - name, value = self.decoder(None, tlv) - - self.eeprom_tlv_dict[code] = value - if (eeprom[tlv_index]) == self._TLV_CODE_CRC_32: - break - - tlv_index += (eeprom[tlv_index+1]) + 2 + PddfEeprom.__init__(self, pddf_data, pddf_plugin_data) def vendor_ext_str(self): """ diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py index 7e3fd75bbe19..7a9e3ecabbc8 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py @@ -6,79 +6,10 @@ ############################################################################# try: - from sonic_platform_base.fan_drawer_base import FanDrawerBase - from sonic_platform.fan import Fan + from sonic_platform_pddf_base.pddf_fan_drawer import PddfFanDrawer except ImportError as e: raise ImportError(str(e) + "- required module not found") - -class PddfFanDrawer(FanDrawerBase): - """PDDF generic Fan Drawer class""" - - pddf_obj = {} - plugin_data = {} - - def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): - FanDrawerBase.__init__(self) - if not pddf_data or not pddf_plugin_data: - raise ValueError('PDDF JSON data error') - - self.pddf_obj = pddf_data - self.plugin_data = pddf_plugin_data - self.platform = self.pddf_obj.get_platform() - - if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']: - print("Invalid fantray index %d\n" % tray_idx) - return - - self.fantray_index = tray_idx+1 - for j in range(self.platform['num_fans_pertray']): - # Fan index is 0-based for the init call - self._fan_list.append(Fan(tray_idx, j, self.pddf_obj, self.plugin_data)) #lgtm [py/call/wrong-number-class-arguments] - - def get_name(self): - """ - Retrieves the fan drawer name - Returns: String containing fan-drawer name - """ - return "Fantray{0}".format(self.fantray_index) - - def get_presence(self): - status = False - # Usually if a tray is removed, all the fans inside it are absent - if self._fan_list: - status = self._fan_list[0].get_presence() - - return status - - def get_status(self): - status = False - # if all the fans are working fine, then tray status should be okay - if self._fan_list: - status = all(fan.get_status() == True for fan in self._fan_list) - - return status - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - # Usually Fantrays are replaceable - return False - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. - Returns: - integer: The 1-based relative physical position in parent - device or -1 if cannot determine the position - """ - return self.fantray_index - - - class FanDrawer(PddfFanDrawer): """PDDF Platform-Specific Fan-Drawer class""" diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py index 1b548d880e78..d6fee81bea31 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/platform.py @@ -6,36 +6,10 @@ ############################################################################# try: - import json -# from . import pddfapi -# from sonic_platform_base.platform_base import PlatformBase from sonic_platform_pddf_base.pddf_platform import PddfPlatform - from sonic_platform.chassis import Chassis except ImportError as e: raise ImportError(str(e) + "- required module not found") - -#class PddfPlatform(PlatformBase): -# """ -# PDDF Generic Platform class -# """ -# pddf_obj = {} -# pddf_plugin_data = {} -# -# def __init__(self): - # Initialize the JSON data - -# self.pddf_data = pddfapi.PddfApi() -# with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd: -# self.pddf_plugin_data = json.load(pd) -# -# if not self.pddf_data or not self.pddf_plugin_data: -# print("Error: PDDF JSON data is not loaded properly ... Exiting") -# raise ValueError - -# PlatformBase.__init__(self) -# self._chassis = Chassis(self.pddf_data, self.pddf_plugin_data) - class Platform(PddfPlatform): """ PDDF Platform-Specific Platform Class diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py index f5426b75bd83..7dd294fb8475 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/thermal.py @@ -8,8 +8,8 @@ class Thermal(PddfThermal): """PDDF Platform-Specific Thermal class""" - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): - PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data) + def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): + PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) self.minimum_thermal = self.get_temperature() self.maximum_thermal = self.get_temperature() # Provide the functions/variables below for which implementation is to be overwritten diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py index f11acf1a209b..66fe58543f51 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py @@ -6,6 +6,7 @@ try: from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase + import time except ImportError as e: raise ImportError(str(e) + "- required module not found") diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py index a0fe6a28bf44..9c1db0384dad 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py @@ -13,6 +13,7 @@ try: from sonic_platform_base.thermal_base import ThermalBase + import time except ImportError as e: raise ImportError(str(e) + "- required module not found") diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py index a4075af87a94..7e9a382d0c46 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py @@ -50,6 +50,7 @@ def get_platform_and_hwsku(self): proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], stdout=subprocess.PIPE, shell=False, + universal_newlines=True, stderr=subprocess.STDOUT) stdout = proc.communicate()[0] proc.wait() @@ -58,6 +59,7 @@ def get_platform_and_hwsku(self): proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY], stdout=subprocess.PIPE, shell=False, + universal_newlines=True, stderr=subprocess.STDOUT) stdout = proc.communicate()[0] proc.wait() From 6f31f8b4bec200450149e18ce848688317401ed3 Mon Sep 17 00:00:00 2001 From: nicwu-cel Date: Thu, 28 Apr 2022 07:10:40 +0000 Subject: [PATCH 14/16] [Author]: jersyang@celestica.com [Jira ID]:N/A fix the i2c controller initialize sequence --- .../x86_64-cel_belgite-r0/installer.conf | 2 +- .../belgite/pddf/sonic_platform/eeprom.py | 57 ++++++++++++++++++- .../scripts/pddf_post_device_create.sh | 3 +- platform/pddf/i2c/utils/pddf_util.py | 4 +- platform/pddf/i2c/utils/pddfparse.py | 28 +-------- .../sonic_platform_pddf_base/pddfapi.py | 28 +-------- 6 files changed, 65 insertions(+), 57 deletions(-) diff --git a/device/celestica/x86_64-cel_belgite-r0/installer.conf b/device/celestica/x86_64-cel_belgite-r0/installer.conf index 61846e4455e0..6ba1f09f192f 100644 --- a/device/celestica/x86_64-cel_belgite-r0/installer.conf +++ b/device/celestica/x86_64-cel_belgite-r0/installer.conf @@ -1,4 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 CONSOLE_SPEED=9600 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog" +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich,i2c-ismt,i2c_ismt,i2c-i801,i2c_i801 crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog" diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py index b49c65ffe571..bc1ef6420b68 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/eeprom.py @@ -6,8 +6,63 @@ class Eeprom(PddfEeprom): + _TLV_DISPLAY_VENDOR_EXT = True + _TLV_INFO_MAX_LEN = 256 + pddf_obj = {} + plugin_data = {} + def __init__(self, pddf_data=None, pddf_plugin_data=None): - PddfEeprom.__init__(self, pddf_data, pddf_plugin_data) + if not pddf_data or not pddf_plugin_data: + raise ValueError('PDDF JSON data error') + + self.pddf_obj = pddf_data + self.plugin_data = pddf_plugin_data + + # system EEPROM always has device name EEPROM1 + self.eeprom_path = self.pddf_obj.get_path("EEPROM1", "eeprom") + if self.eeprom_path is None: + return + + super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) + #super().__init__(self.pddf_obj, self.plugin_data) + self.eeprom_tlv_dict = dict() + try: + self.eeprom_data = self.read_eeprom() + except Exception as e: + self.eeprom_data = "N/A" + raise RuntimeError("PddfEeprom is not Programmed - Error: {}".format(str(e))) + else: + eeprom = self.eeprom_data + + if not self.is_valid_tlvinfo_header(eeprom): + return + + total_length = ((eeprom[9]) << 8) | (eeprom[10]) + tlv_index = self._TLV_INFO_HDR_LEN + tlv_end = self._TLV_INFO_HDR_LEN + total_length + + while (tlv_index + 2) < self._TLV_INFO_MAX_LEN and tlv_index < tlv_end: + if not self.is_valid_tlv(eeprom[tlv_index:]): + break + + tlv = eeprom[tlv_index:tlv_index + 2 + + (eeprom[tlv_index + 1])] + code = "0x%02X" % ((tlv[0])) + + if (tlv[0]) == self._TLV_CODE_VENDOR_EXT: + name = "Vendor Extension" #lgtm [py/multiple-definition] + value = "" + if self._TLV_DISPLAY_VENDOR_EXT: + for c in tlv[2:2 + tlv[1]]: + value += "0x%02X " % c + else: + name, value = self.decoder(None, tlv) + + self.eeprom_tlv_dict[code] = value + if (eeprom[tlv_index]) == self._TLV_CODE_CRC_32: + break + + tlv_index += (eeprom[tlv_index+1]) + 2 def vendor_ext_str(self): """ diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh index 8dd9ac8a8486..414eea7a2b40 100755 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_post_device_create.sh @@ -6,4 +6,5 @@ sudo i2cset -y -f 6 0x49 0x1 0x2 sleep 0.1 #Set LM75 shutdown enable sudo i2cset -y -f 2 0x32 0x45 0x1 - + +echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state diff --git a/platform/pddf/i2c/utils/pddf_util.py b/platform/pddf/i2c/utils/pddf_util.py index fdefc8933c15..d3ee5e43aca9 100755 --- a/platform/pddf/i2c/utils/pddf_util.py +++ b/platform/pddf/i2c/utils/pddf_util.py @@ -21,7 +21,7 @@ import shutil import subprocess import sys - +from sonic_py_common import device_info import pddfparse PLATFORM_ROOT_PATH = '/usr/share/sonic/device' @@ -139,7 +139,7 @@ def driver_check(): def get_path_to_device(): # Get platform and hwsku - (platform, hwsku) = pddf_obj.get_platform_and_hwsku() + (platform, hwsku) = device_info.get_platform_and_hwsku() # Load platform module from source platform_path = "/".join([PLATFORM_ROOT_PATH, platform]) diff --git a/platform/pddf/i2c/utils/pddfparse.py b/platform/pddf/i2c/utils/pddfparse.py index b8c7f39138a5..8d48586ee0b6 100755 --- a/platform/pddf/i2c/utils/pddfparse.py +++ b/platform/pddf/i2c/utils/pddfparse.py @@ -8,6 +8,7 @@ import sys import time import unicodedata +from sonic_py_common import device_info bmc_cache = {} cache = {} @@ -33,7 +34,7 @@ class PddfParse(): def __init__(self): if not os.path.exists("/usr/share/sonic/platform"): - platform, hwsku = self.get_platform_and_hwsku() + platform, hwsku = device_info.get_platform_and_hwsku() os.symlink("/usr/share/sonic/device/"+platform, "/usr/share/sonic/platform") try: @@ -47,31 +48,6 @@ def __init__(self): self.data_sysfs_obj = {} self.sysfs_obj = {} - # Returns platform and HW SKU - def get_platform_and_hwsku(self): - try: - proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], - stdout=subprocess.PIPE, - shell=False, - universal_newlines=True, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - platform = stdout.rstrip('\n') - - proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY], - stdout=subprocess.PIPE, - shell=False, - universal_newlines=True, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - hwsku = stdout.rstrip('\n') - except OSError as e: - raise OSError("Cannot detect platform") - - return (platform, hwsku) - ################################################################################################################### # GENERIC DEFS ################################################################################################################### diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py index 7e9a382d0c46..352ad1b1744f 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py @@ -6,6 +6,7 @@ import subprocess import time import unicodedata +from sonic_py_common import device_info bmc_cache = {} cache = {} @@ -31,7 +32,7 @@ class PddfApi(): def __init__(self): if not os.path.exists("/usr/share/sonic/platform"): - self.platform, self.hwsku = self.get_platform_and_hwsku() + self.platform, self.hwsku = device_info.get_platform_and_hwsku() os.symlink("/usr/share/sonic/device/"+self.platform, "/usr/share/sonic/platform") try: @@ -44,31 +45,6 @@ def __init__(self): self.data_sysfs_obj = {} self.sysfs_obj = {} - # Returns platform and HW SKU - def get_platform_and_hwsku(self): - try: - proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], - stdout=subprocess.PIPE, - shell=False, - universal_newlines=True, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - platform = stdout.rstrip('\n') - - proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY], - stdout=subprocess.PIPE, - shell=False, - universal_newlines=True, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - hwsku = stdout.rstrip('\n') - except OSError as e: - raise OSError("Cannot detect platform") - - return (platform, hwsku) - ################################################################################################################# # GENERIC DEFS ################################################################################################################# From c5ebd2f951f3a6fd9e1057aa53643a358c0103ce Mon Sep 17 00:00:00 2001 From: nicwu-cel Date: Mon, 9 May 2022 08:46:59 +0000 Subject: [PATCH 15/16] [Author]:jersyang@celestica.com [Jira ID]:N/A [Description]: fix the watchdog API issue --- .../x86_64-cel_belgite-r0/installer.conf | 2 +- .../x86_64-cel_belgite-r0/platform.json | 40 ++++++++----------- .../belgite/modules/mc24lc64t.c | 2 +- .../belgite/modules/pddf_custom_wdt.c | 6 +-- .../belgite/pddf/sonic_platform/chassis.py | 26 +++++++++++- .../belgite/pddf/sonic_platform/component.py | 23 +++++++++++ .../belgite/pddf/sonic_platform/fan_drawer.py | 8 ++++ .../belgite/pddf/sonic_platform/psu.py | 4 +- .../belgite/pddf/sonic_platform/watchdog.py | 4 +- .../scripts/pddf_pre_driver_install.sh | 4 +- 10 files changed, 84 insertions(+), 35 deletions(-) diff --git a/device/celestica/x86_64-cel_belgite-r0/installer.conf b/device/celestica/x86_64-cel_belgite-r0/installer.conf index 6ba1f09f192f..61846e4455e0 100644 --- a/device/celestica/x86_64-cel_belgite-r0/installer.conf +++ b/device/celestica/x86_64-cel_belgite-r0/installer.conf @@ -1,4 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 CONSOLE_SPEED=9600 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich,i2c-ismt,i2c_ismt,i2c-i801,i2c_i801 crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog" +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog" diff --git a/device/celestica/x86_64-cel_belgite-r0/platform.json b/device/celestica/x86_64-cel_belgite-r0/platform.json index 31fbe1d9d1b1..1d4a1f9e3420 100644 --- a/device/celestica/x86_64-cel_belgite-r0/platform.json +++ b/device/celestica/x86_64-cel_belgite-r0/platform.json @@ -21,7 +21,7 @@ { "name": "Fantray1_1", "speed": { - "controllable": false + "controllable": true }, "status_led": { "controllable": true, @@ -31,7 +31,7 @@ { "name": "Fantray2_1", "speed": { - "controllable": false + "controllable": true }, "status_led": { "controllable": true, @@ -41,7 +41,7 @@ { "name": "Fantray3_1", "speed": { - "controllable": false + "controllable": true }, "status_led": { "controllable": true, @@ -51,7 +51,7 @@ { "name": "Fantray1_1", "speed": { - "controllable": false + "controllable": true }, "status_led": { "controllable": true, @@ -61,7 +61,7 @@ { "name": "Fantray2_1", "speed": { - "controllable": false + "controllable": true }, "status_led": { "controllable": true, @@ -71,7 +71,7 @@ { "name": "Fantray3_1", "speed": { - "controllable": false + "controllable": true }, "status_led": { "controllable": true, @@ -86,8 +86,7 @@ "controllable": false }, "status_led": { - "controllable": true, - "colors": ["green", "amber","off"] + "controllable": false }, "max_consumed_power": false, "fans": [ @@ -97,8 +96,7 @@ "controllable": false }, "status_led": { - "controllable": true, - "colors": ["green", "amber","off"] + "controllable": false } } ] @@ -109,8 +107,7 @@ "controllable": false }, "status_led": { - "controllable": true, - "colors": ["green", "amber","off"] + "controllable": false }, "max_consumed_power": false, "fans": [ @@ -120,8 +117,7 @@ "controllable": false }, "status_led": { - "controllable": true, - "colors": ["green", "amber","off"] + "controllable": false } } ] @@ -132,8 +128,7 @@ "controllable": false }, "status_led": { - "controllable": true, - "colors": ["green", "amber","off"] + "controllable": false }, "max_consumed_power": false, "fans": [ @@ -143,8 +138,7 @@ "controllable": false }, "status_led": { - "controllable": true, - "colors": ["green", "amber","off"] + "controllable": false } } ] @@ -157,9 +151,7 @@ { "name": "PSU1_FAN1", "speed": { - "controllable": true, - "minimum": 25, - "maximum": 100 + "controllable": false }, "status_led": { "controllable": false @@ -172,6 +164,7 @@ "voltage_high_threshold": false, "voltage_low_threshold": false, "temperature": false, + "fans_target_speed": false, "status_led": { "controllable": false } @@ -182,9 +175,7 @@ { "name": "PSU2_FAN1", "speed": { - "controllable": true, - "minimum": 25, - "maximum": 100 + "controllable": false }, "status_led": { "controllable": false @@ -197,6 +188,7 @@ "voltage_high_threshold": false, "voltage_low_threshold": false, "temperature": false, + "fans_target_speed": false, "status_led": { "controllable": false } diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/mc24lc64t.c b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/mc24lc64t.c index 49e9d8b21f8f..e71e551438eb 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/mc24lc64t.c +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/mc24lc64t.c @@ -18,7 +18,7 @@ #include #include -#define EEPROM_SIZE 8192 //mc24lt64t eeprom size in bytes. +#define EEPROM_SIZE 256 //mc24lt64t eeprom size in bytes. struct mc24lc64t_data { struct mutex update_lock; diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c index 190fa85471cf..a73a6f6eb143 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/modules/pddf_custom_wdt.c @@ -522,9 +522,9 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd, new_timeout = new_timeout*1000; if (watchdog_set_timeout(p, new_timeout)) return -EINVAL; - //watchdog_keepalive(p); - /* Fall */ - return 0; + + val = watchdog_get_timeout(p); + return put_user(val, uarg.i); case WDIOC_GETTIMEOUT: val = watchdog_get_timeout(p); return put_user(val, uarg.i); diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py index 6595f365efa8..5e2b204e3d0b 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/chassis.py @@ -13,23 +13,25 @@ from sonic_platform.watchdog import Watchdog import sys import subprocess + from sonic_py_common import device_info except ImportError as e: raise ImportError(str(e) + "- required module not found") NUM_COMPONENT = 3 FAN_DIRECTION_FILE_PATH = "/var/fan_direction" - class Chassis(PddfChassis): """ PDDF Platform-specific Chassis class """ def __init__(self, pddf_data=None, pddf_plugin_data=None): + PddfChassis.__init__(self, pddf_data, pddf_plugin_data) vendor_ext = self._eeprom.vendor_ext_str() with open(FAN_DIRECTION_FILE_PATH, "w+") as f: f.write(vendor_ext) + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() self.__initialize_components() @@ -74,9 +76,11 @@ def get_watchdog(self): An object derived from WatchdogBase representing the hardware watchdog device """ - self._watchdog = Watchdog() + if self._watchdog is None: + self._watchdog = Watchdog() return self._watchdog + def get_reboot_cause(self): """ Retrieves the cause of the previous reboot @@ -138,3 +142,21 @@ def get_base_mac(self): def get_system_eeprom_info(self): return self._eeprom.system_eeprom_info() + def get_name(self): + return self.modelstr() + + def get_model(self): + return self._eeprom.part_number_str() + + def set_status_led(self, color): + color_dict = { + 'green': "STATUS_LED_COLOR_GREEN", + 'red': "STATUS_LED_COLOR_AMBER", + 'amber': "STATUS_LED_COLOR_AMBER", + 'off': "STATUS_LED_COLOR_OFF" + } + return self.set_system_led("SYS_LED", color_dict.get(color, "off")) + + def get_status_led(self): + return self.get_system_led("SYS_LED") + diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py index 4b8a3ffaffb4..e4f3e1257da8 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/component.py @@ -115,5 +115,28 @@ def install_firmware(self, image_path): return False def update_firmware(self, image_path): + return False + + def get_available_firmware_version(self, image_path): + return 'N/A' + + def get_firmware_update_notification(self, image_path): + return "None" + + def get_model(self): + return 'N/A' + + def get_position_in_parent(self): + return -1 + + def get_presence(self): + return True + + def get_serial(self): + return 'N/A' + + def get_status(self): + return True + def is_replaceable(self): return False diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py index 7a9e3ecabbc8..ac80aad4b1eb 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/fan_drawer.py @@ -23,3 +23,11 @@ def set_status_led(self, color): def get_status_led(self, color=None): return self._fan_list[0].get_status_led() + + def get_serial(self): + serial = "Unknown" + return serial + + def get_model(self): + model = "Unknown" + return model diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py index 0e2c925a0f07..9616d030012f 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/psu.py @@ -49,5 +49,7 @@ def get_position_in_parent(self): return self.psu_index def get_revision(self): - return "N/A" + + def temperature(self): + return self.get_temperature() diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py index 789c04addf1e..7973e8a3cfad 100644 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/pddf/sonic_platform/watchdog.py @@ -154,16 +154,16 @@ def arm(self, seconds): try: if self.timeout != seconds: self.timeout = self._settimeout(seconds) + if self.armed: self._keepalive() else: - self._settimeout(seconds) self._enable() self.armed = True + ret = self.timeout except IOError as e: pass - return ret def disarm(self): diff --git a/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_pre_driver_install.sh b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_pre_driver_install.sh index a25c39df41a1..2b37a5d5f6ff 100755 --- a/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_pre_driver_install.sh +++ b/platform/broadcom/sonic-platform-modules-cel/belgite/scripts/pddf_pre_driver_install.sh @@ -1,3 +1,5 @@ #!/bin/bash modprobe -r i2c_ismt -modprobe -r i2c-i801 +sleep 0.1 +modprobe -r i2c-i801 +sleep 0.1 From b725940689b1dae06cd705100e267d9fb9598506 Mon Sep 17 00:00:00 2001 From: nicwu-cel Date: Tue, 10 May 2022 02:56:09 +0000 Subject: [PATCH 16/16] [Author]:jersyang@celestica.com [Jira ID]:N/A [Description]:fix the merge conflict with PDDF --- platform/pddf/i2c/utils/pddf_util.py | 4 +-- platform/pddf/i2c/utils/pddfparse.py | 28 +++++++++++++++++-- .../sonic_platform_pddf_base/pddf_sfp.py | 1 - .../sonic_platform_pddf_base/pddf_thermal.py | 1 - .../sonic_platform_pddf_base/pddfapi.py | 26 +++++++++++++++-- 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/platform/pddf/i2c/utils/pddf_util.py b/platform/pddf/i2c/utils/pddf_util.py index d3ee5e43aca9..fdefc8933c15 100755 --- a/platform/pddf/i2c/utils/pddf_util.py +++ b/platform/pddf/i2c/utils/pddf_util.py @@ -21,7 +21,7 @@ import shutil import subprocess import sys -from sonic_py_common import device_info + import pddfparse PLATFORM_ROOT_PATH = '/usr/share/sonic/device' @@ -139,7 +139,7 @@ def driver_check(): def get_path_to_device(): # Get platform and hwsku - (platform, hwsku) = device_info.get_platform_and_hwsku() + (platform, hwsku) = pddf_obj.get_platform_and_hwsku() # Load platform module from source platform_path = "/".join([PLATFORM_ROOT_PATH, platform]) diff --git a/platform/pddf/i2c/utils/pddfparse.py b/platform/pddf/i2c/utils/pddfparse.py index 8d48586ee0b6..b8c7f39138a5 100755 --- a/platform/pddf/i2c/utils/pddfparse.py +++ b/platform/pddf/i2c/utils/pddfparse.py @@ -8,7 +8,6 @@ import sys import time import unicodedata -from sonic_py_common import device_info bmc_cache = {} cache = {} @@ -34,7 +33,7 @@ class PddfParse(): def __init__(self): if not os.path.exists("/usr/share/sonic/platform"): - platform, hwsku = device_info.get_platform_and_hwsku() + platform, hwsku = self.get_platform_and_hwsku() os.symlink("/usr/share/sonic/device/"+platform, "/usr/share/sonic/platform") try: @@ -48,6 +47,31 @@ def __init__(self): self.data_sysfs_obj = {} self.sysfs_obj = {} + # Returns platform and HW SKU + def get_platform_and_hwsku(self): + try: + proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], + stdout=subprocess.PIPE, + shell=False, + universal_newlines=True, + stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + platform = stdout.rstrip('\n') + + proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY], + stdout=subprocess.PIPE, + shell=False, + universal_newlines=True, + stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + hwsku = stdout.rstrip('\n') + except OSError as e: + raise OSError("Cannot detect platform") + + return (platform, hwsku) + ################################################################################################################### # GENERIC DEFS ################################################################################################################### diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py index 66fe58543f51..f11acf1a209b 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py @@ -6,7 +6,6 @@ try: from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase - import time except ImportError as e: raise ImportError(str(e) + "- required module not found") diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py index 9c1db0384dad..a0fe6a28bf44 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py @@ -13,7 +13,6 @@ try: from sonic_platform_base.thermal_base import ThermalBase - import time except ImportError as e: raise ImportError(str(e) + "- required module not found") diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py index 352ad1b1744f..a4075af87a94 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py @@ -6,7 +6,6 @@ import subprocess import time import unicodedata -from sonic_py_common import device_info bmc_cache = {} cache = {} @@ -32,7 +31,7 @@ class PddfApi(): def __init__(self): if not os.path.exists("/usr/share/sonic/platform"): - self.platform, self.hwsku = device_info.get_platform_and_hwsku() + self.platform, self.hwsku = self.get_platform_and_hwsku() os.symlink("/usr/share/sonic/device/"+self.platform, "/usr/share/sonic/platform") try: @@ -45,6 +44,29 @@ def __init__(self): self.data_sysfs_obj = {} self.sysfs_obj = {} + # Returns platform and HW SKU + def get_platform_and_hwsku(self): + try: + proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], + stdout=subprocess.PIPE, + shell=False, + stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + platform = stdout.rstrip('\n') + + proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY], + stdout=subprocess.PIPE, + shell=False, + stderr=subprocess.STDOUT) + stdout = proc.communicate()[0] + proc.wait() + hwsku = stdout.rstrip('\n') + except OSError as e: + raise OSError("Cannot detect platform") + + return (platform, hwsku) + ################################################################################################################# # GENERIC DEFS #################################################################################################################