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"