diff --git a/builds/any/installer/installer.sh.in b/builds/any/installer/installer.sh.in index e3d968aa..6711709d 100644 --- a/builds/any/installer/installer.sh.in +++ b/builds/any/installer/installer.sh.in @@ -144,7 +144,14 @@ if test "$installer_debug"; then fi # Pickup ONIE defines for this machine. -if test -r /etc/machine.conf; then +if test "$onie_platform"; then + : +else + onie_platform=$(onie-sysinfo -p 2>/dev/null) || : +fi +if test "$onie_platform"; then + : +elif test -r /etc/machine.conf; then . /etc/machine.conf fi @@ -252,7 +259,7 @@ if test "${onie_platform}"; then } else if test "$ARCH_X86"; then - echo "Missing onie_platform (invalid /etc/machine.conf)" 1>&2 + echo "Missing onie_platform (invalid or missing onie-sysinfo or /etc/machine.conf)" 1>&2 exit 1 fi # diff --git a/packages/base/all/vendor-config-onl/src/bin/onie-sysinfo b/packages/base/all/vendor-config-onl/src/bin/onie-sysinfo new file mode 100755 index 00000000..fabd2026 --- /dev/null +++ b/packages/base/all/vendor-config-onl/src/bin/onie-sysinfo @@ -0,0 +1,7 @@ +#!/usr/bin/python + +"""Run native onie-sysinfo +""" + +import onl.install.ShellApp +onl.install.ShellApp.OnieSysinfoApp.main() diff --git a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh index 0a5ea184..3835580f 100644 --- a/packages/base/all/vendor-config-onl/src/lib/install/lib.sh +++ b/packages/base/all/vendor-config-onl/src/lib/install/lib.sh @@ -122,7 +122,7 @@ installer_mkchroot() { mkdir -p "${rootdir}${TMPDIR}" fi - # export ONIE defines to the installer + # export ONIE defines to the installer, if they exist if test -r /etc/machine.conf; then cp /etc/machine.conf "${rootdir}/etc/machine.conf" fi diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/App.py b/packages/base/all/vendor-config-onl/src/python/onl/install/App.py index 69b83f8f..13465b90 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/App.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/App.py @@ -17,7 +17,7 @@ import time from InstallUtils import InitrdContext from InstallUtils import SubprocessMixin from InstallUtils import ProcMountsParser -from ShellApp import OnieBootContext +from ShellApp import OnieBootContext, OnieSysinfo import ConfUtils, BaseInstall class App(SubprocessMixin, object): @@ -129,7 +129,7 @@ class App(SubprocessMixin, object): def runLocalOrChroot(self): if self.machineConf is None: - self.log.error("missing machine.conf") + self.log.error("missing onie-sysinfo or machine.conf") return 1 if self.installerConf is None: self.log.error("missing installer.conf") @@ -230,10 +230,17 @@ class App(SubprocessMixin, object): def runLocal(self): self.log.info("getting installer configuration") - if os.path.exists(ConfUtils.MachineConf.PATH): + osi = OnieSysinfo(log=self.log.getChild("onie-sysinfo")) + try: + halp = osi.help + except AttributeError: + halp = None + if halp is not None: + self.machineConf = osi + elif os.path.exists(ConfUtils.MachineConf.PATH): self.machineConf = ConfUtils.MachineConf() else: - self.log.warn("missing /etc/machine.conf from ONIE runtime") + self.log.warn("missing onie-sysinfo or /etc/machine.conf from ONIE runtime") self.machineConf = ConfUtils.MachineConf(path='/dev/null') self.installerConf = ConfUtils.InstallerConf() @@ -243,7 +250,7 @@ class App(SubprocessMixin, object): def findPlatform(self): plat = arch = None - if os.path.exists(ConfUtils.MachineConf.PATH): + if self.machineConf is not None: plat = getattr(self.machineConf, 'onie_platform', None) arch = getattr(self.machineConf, 'onie_arch', None) if plat and arch: diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py b/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py index 7c5f2c6c..fcf7f93d 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/ShellApp.py @@ -15,9 +15,6 @@ from InstallUtils import ProcMountsParser, ProcMtdParser from InstallUtils import BlkidParser from InstallUtils import UbootInitrdContext -import onl.platform.current -from onl.sysconfig import sysconfig - class AppBase(SubprocessMixin, object): @property @@ -228,6 +225,105 @@ class Onie(AppBase): with OnieBootContext(log=self.log) as ctx: return self._runInitrdShell(ctx.initrd) +class OnieSysinfoApp(SubprocessMixin, object): + + PROG = "onie-sysinfo" + + def __init__(self, args=[], log=None): + + if log is not None: + self.log = log + else: + self.log = logging.getLogger(self.__class__.__name__) + self.args = args or ['-p',] + self.output = None + + def _runInitrdShell(self, initrd): + with InitrdContext(initrd=initrd, log=self.log) as ctx: + cmd = ['onie-sysinfo',] + cmd.extend(self.args) + cmd = ('chroot', ctx.dir, + '/bin/sh', '-c', 'IFS=;' + " ".join(cmd)) + try: + self.output = self.check_output(cmd) + ret = 0 + except subprocess.CalledProcessError, what: + self.log.error("failed command: %s", " ".join(what.cmd)) + for line in (what.output or "").splitlines(): + self.log.error(">>> %s", line) + ret = what.returncode + return ret + + def run(self): + with OnieBootContext(log=self.log) as ctx: + ret = self._runInitrdShell(ctx.initrd) + if self.output is not None: + sys.stdout.write(self.output) + return ret + + def shutdown(self): + pass + + @classmethod + def main(cls): + + logging.basicConfig() + logger = logging.getLogger(cls.PROG) + logger.setLevel(logging.INFO) + + args = list(sys.argv[1:]) + sysinfoArgs = [] + while args: + + if args[0] in ('-v', '--verbose',): + logger.setLevel(logging.DEBUG) + args.pop(0) + continue + + if args[0] in ('-q', '--quiet',): + logger.setLevel(logging.ERROR) + args.pop(0) + continue + + sysinfoArgs.append(args.pop(0)) + + app = cls(args=sysinfoArgs, log=logger) + try: + code = app.run() + except: + logger.exception("runner failed") + code = 1 + app.shutdown() + sys.exit(code) + +class OnieSysinfo(OnieSysinfoApp): + + def _runArgs(self, *args): + self.args = args + with OnieBootContext(log=self.log) as ctx: + ret = self._runInitrdShell(ctx.initrd) + if self.output is not None: + return self.output.rstrip() + raise AttributeError("cannot retrieve onie-sysinfo attribute via %s" % str(args)) + + @property + def help(self): + return self._runArgs('-h') + + @property + def onie_platform(self): + return self._runArgs('-p') + + @property + def onie_arch(self): + return self._runArgs('-c') + + @property + def onie_version(self): + return self._runArgs('-v') + + # XXX roth other switches too + class Loader(AppBase): """Application shell that uses the (installed) loader runtime.""" @@ -331,6 +427,7 @@ class Loader(AppBase): def run(self): + import onl.platform.current self.platform = onl.platform.current.OnlPlatform() self.pc = self.platform.platform_config @@ -353,6 +450,7 @@ class Upgrader(AppBase): def runGrub(self): + from onl.sysconfig import sysconfig d = sysconfig.upgrade.loader.package.dir for b in sysconfig.upgrade.loader.package.grub: p = os.path.join(d, b) @@ -365,6 +463,7 @@ class Upgrader(AppBase): def runUboot(self): + from onl.sysconfig import sysconfig d = sysconfig.upgrade.loader.package.dir for b in sysconfig.upgrade.loader.package.fit: p = os.path.join(d, b) @@ -377,6 +476,7 @@ class Upgrader(AppBase): def run(self): + import onl.platform.current self.platform = onl.platform.current.OnlPlatform() self.pc = self.platform.platform_config diff --git a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py index ad6ce72e..09348f52 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/install/SystemInstall.py @@ -60,8 +60,9 @@ class App(SubprocessMixin): src = os.path.join(octx.initrdDir, "etc/machine.conf") dst = os.path.join(ctx.dir, "etc/machine.conf") - self.log.debug("+ /bin/cp %s %s", src, dst) - shutil.copy2(src, dst) + if os.path.exists(src): + self.log.debug("+ /bin/cp %s %s", src, dst) + shutil.copy2(src, dst) src = "/etc/fw_env.config" if os.path.exists(src): diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index 026aed28..170f1eac 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -482,6 +482,10 @@ class OnlPlatformPortConfig_48x10_6x40(object): PORT_COUNT=54 PORT_CONFIG="48x10 + 6x40" +class OnlPlatformPortConfig_48x10_4x100(object): + PORT_COUNT=52 + PORT_CONFIG="48x10 + 4x100" + class OnlPlatformPortConfig_48x25_6x100(object): PORT_COUNT=54 PORT_CONFIG="48x25 + 6x100" diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py index 1f43884b..30976a3a 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/baseconfig.py @@ -61,6 +61,13 @@ def baseconfig(): ONLPDUMP = "%s/bin/onlpdump" % (platform.basedir_onl()) + try: + import dmidecode + with open("%s/dmi-system-version" % platform.basedir_onl(), "w") as f: + f.write(dmidecode.QuerySection('system')['0x0001']['data']['Version']) + except: + pass + if not platform.baseconfig(): msg("*** platform class baseconfig failed.\n", fatal=True) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py index bdf4c915..36e9e457 100644 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/current.py @@ -14,8 +14,9 @@ # platform-config packages. # ############################################################ -import os +import os, sys import importlib +import subprocess def platform_name_get(): # Determine the current platform name. @@ -23,6 +24,22 @@ def platform_name_get(): if os.path.exists("/etc/onl/platform"): with open("/etc/onl/platform", 'r') as f: platform=f.read().strip() + elif os.path.exists("/bin/onie-sysinfo"): + try: + platform = subprocess.check_output(('/bin/onie-sysinfo', '-p',)).strip() + except subprocess.CalledProcessError as what: + for line in (what.output or "").splitlines(): + sys.stderr.write(">>> %s\n" % line) + sys.stderr.write("onie-sysinfo failed with code %d\n" % what.returncode) + platform = None + elif os.path.exists("/usr/bin/onie-shell"): + try: + platform = subprocess.check_output(('/usr/bin/onie-shell', '-c', "onie-sysinfo -p",)).strip() + except subprocess.CalledProcessError as what: + for line in (what.output or "").splitlines(): + sys.stderr.write(">>> %s\n" % line) + sys.stderr.write("onie-sysinfo (onie-shell) failed with code %d\n" % what.returncode) + platform = None elif os.path.exists("/etc/machine.conf"): with open("/etc/machine.conf", 'r') as f: lines = f.readlines(False) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py index 29128db9..9ebec5b5 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/upgrade/loader.py @@ -12,7 +12,7 @@ from onl.upgrade import ubase from onl.sysconfig import sysconfig from onl.mounts import OnlMountManager, OnlMountContextReadOnly, OnlMountContextReadWrite from onl.install import BaseInstall, ConfUtils, InstallUtils -from onl.install.ShellApp import OnieBootContext +from onl.install.ShellApp import OnieBootContext, OnieSysinfo import onl.platform.current import onl.versions @@ -83,8 +83,12 @@ class LoaderUpgrade_Fit(LoaderUpgradeBase): onlPlatform = onl.platform.current.OnlPlatform() with OnieBootContext(log=self.logger) as octx: - path = os.path.join(octx.initrdDir, "etc/machine.conf") - machineConf = ConfUtils.MachineConf(path=path) + if os.path.exists("/usr/bin/onie-shell"): + machineConf = OnieSysinfo(log=self.logger.getChild("onie-sysinfo")) + else: + path = os.path.join(octx.initrdDir, "etc/machine.conf") + if os.path.exists(path): + machineConf = ConfUtils.MachineConf(path=path) installerConf = ConfUtils.InstallerConf(path="/dev/null") # start with an empty installerConf, fill it in piece by piece diff --git a/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config index a7f0259f..109a7ccd 100644 --- a/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/3.16-lts/configs/x86_64-all/x86_64-all.config @@ -2004,7 +2004,7 @@ CONFIG_GPIO_GENERIC_PLATFORM=y # CONFIG_GPIO_F7188X is not set # CONFIG_GPIO_SCH311X is not set CONFIG_GPIO_SCH=y -# CONFIG_GPIO_ICH is not set +CONFIG_GPIO_ICH=m # CONFIG_GPIO_VX855 is not set # CONFIG_GPIO_LYNXPOINT is not set diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/8472.h b/packages/base/any/onlp/src/sff/module/inc/sff/8472.h index 6b7a1161..20b52d70 100644 --- a/packages/base/any/onlp/src/sff/module/inc/sff/8472.h +++ b/packages/base/any/onlp/src/sff/module/inc/sff/8472.h @@ -968,7 +968,6 @@ _sff8472_media_sfp28_cr(const uint8_t* idprom) /* module should be sfp */ if (!SFF8472_MODULE_SFP(idprom)) return 0; - if (idprom[2] != SFF8472_CONN_NOSEP) return 0; if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) == 0) return 0; if (idprom[12] == 0xFF) return 1; diff --git a/packages/base/any/onlp/src/sff/module/src/sff.c b/packages/base/any/onlp/src/sff/module/src/sff.c index bb916944..281c4450 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff.c +++ b/packages/base/any/onlp/src/sff/module/src/sff.c @@ -472,6 +472,7 @@ sff_eeprom_parse_standard__(sff_eeprom_t* se, uint8_t* eeprom) se->info.length = se->eeprom[146]; break; case SFF_SFP_TYPE_SFP: + case SFF_SFP_TYPE_SFP28: se->info.length = se->eeprom[18]; break; default: diff --git a/packages/base/any/onlp/src/sff/module/src/sff_db.c b/packages/base/any/onlp/src/sff/module/src/sff_db.c index 095aecdb..15f69fbf 100644 --- a/packages/base/any/onlp/src/sff/module/src/sff_db.c +++ b/packages/base/any/onlp/src/sff/module/src/sff_db.c @@ -34,6 +34,8 @@ #define SFF_25G_BASE_SR_PROPERTIES \ SFF_SFP_TYPE_SFP28, "SFP28", SFF_MODULE_TYPE_25G_BASE_SR, "25GBASE-SR", SFF_MEDIA_TYPE_FIBER, "Fiber",SFF_MODULE_CAPS_F_25G +#define SFF_25G_BASE_CR_PROPERTIES \ + SFF_SFP_TYPE_SFP28, "SFP28", SFF_MODULE_TYPE_25G_BASE_CR, "25GBASE-CR", SFF_MEDIA_TYPE_COPPER, "Copper", SFF_MODULE_CAPS_F_25G #define SFF_40G_BASE_SR4_PROPERTIES \ SFF_SFP_TYPE_QSFP_PLUS, "QSFP+", SFF_MODULE_TYPE_40G_BASE_SR4, "40GBASE-SR4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_40G @@ -1655,6 +1657,122 @@ static sff_db_entry_t sff_database__[] = }, }, }, + { + { + .eeprom = { + 0x03, 0x04, 0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0d, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x43, 0x43, 0x47, 0x46, 0x2d, 0x43, + 0x31, 0x30, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x03, 0x00, 0x00, 0x17, + 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x37, 0x31, 0x34, 0x31, 0x30, 0x34, 0x35, 0x55, + 0x47, 0x56, 0x20, 0x20, 0x31, 0x37, 0x30, 0x34, 0x30, 0x38, 0x20, 0x20, 0x00, 0x00, 0x08, 0x83, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + }, + .info = { + "Amphenol ", + "NDCCGF-C104 ", + "APF17141045UGV ", + SFF_25G_BASE_CR_PROPERTIES, + 1, + } , + }, + }, + { + { + .eeprom = { + 0x03, 0x04, 0x21, 0x01, 0x00, 0x00, 0x04, 0x41, 0x84, 0x80, 0xd5, 0x06, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0b, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x43, 0x43, 0x47, 0x46, 0x2d, 0x48, + 0x33, 0x30, 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xaf, + 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x34, 0x35, 0x33, 0x30, 0x31, 0x33, 0x33, + 0x50, 0x31, 0x20, 0x20, 0x31, 0x36, 0x31, 0x31, 0x31, 0x36, 0x20, 0x20, 0x00, 0x00, 0x08, 0x41, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .info = { + "Amphenol ", + "NDCCGF-H301 ", + "APF164530133P1 ", + SFF_25G_BASE_CR_PROPERTIES, + 1, + } , + }, + }, + { + { + .eeprom = { + 0x03, 0x04, 0x21, 0x01, 0x00, 0x00, 0x04, 0x41, 0x84, 0x80, 0xd5, 0x06, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x0b, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x41, 0x51, 0x47, 0x46, 0x2d, 0x48, + 0x33, 0x30, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xbf, + 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x35, 0x30, 0x33, 0x30, 0x33, 0x31, 0x4c, + 0x50, 0x44, 0x20, 0x20, 0x31, 0x36, 0x31, 0x32, 0x31, 0x37, 0x20, 0x20, 0x00, 0x00, 0x08, 0x6b, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + .info = { + "Amphenol ", + "NDAQGF-H303 ", + "APF16503031LPD ", + SFF_25G_BASE_CR_PROPERTIES, + 3, + }, + }, + }, + { + { + .eeprom = { + 0x03, 0x04, 0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x03, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x00, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x41, 0x51, 0x47, 0x46, 0x2d, 0x30, + 0x30, 0x30, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x32, 0x35, 0x30, 0x30, 0x33, 0x31, 0x4b, + 0x43, 0x55, 0x20, 0x20, 0x31, 0x36, 0x30, 0x36, 0x32, 0x35, 0x20, 0x20, 0x00, 0x00, 0x08, 0x6f, + 0x44, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + }, + .info = { + "Amphenol ", + "NDAQGF-0003 ", + "APF16250031KCU ", + SFF_25G_BASE_CR_PROPERTIES, + 3, + }, + }, + }, { { .eeprom = { diff --git a/packages/platforms-closed b/packages/platforms-closed index ab1e0396..03cd2a46 160000 --- a/packages/platforms-closed +++ b/packages/platforms-closed @@ -1 +1 @@ -Subproject commit ab1e0396cb725abba9d57c4d2d28993463a38261 +Subproject commit 03cd2a4666ac46b68234b2a9976bcdfe30dfbb4a diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c index 8bc4398d..4d2e8a28 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5822-54x/modules/builds/x86-64-accton-as5822-54x-psu.c @@ -224,6 +224,55 @@ static struct i2c_driver as5822_54x_psu_driver = { .address_list = normal_i2c, }; +static int as5822_54x_psu_read_byte(struct i2c_client *client, u8 command, u8 *data) +{ + int status = 0; + int retry_count = 5; + + while (retry_count) { + status = i2c_smbus_read_byte_data(client, command); + if (unlikely(status < 0)) { + msleep(10); + retry_count--; + continue; + } + + break; + } + + if (unlikely(status < 0)) { + dev_dbg(&client->dev, "sfp read byte data failed, command(0x%2x), data(0x%2x)\r\n", command, status); + goto abort; + } + + *data = (u8)status; + +abort: + return status; +} + +static int as5822_54x_psu_read_bytes(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int ret = 0; + + while (data_len) { + ssize_t status; + + status = as5822_54x_psu_read_byte(client, command, data); + if (status <= 0) { + ret = status; + break; + } + + data += 1; + command += 1; + data_len -= 1; + } + + return ret; +} + static int as5822_54x_psu_read_block(struct i2c_client *client, u8 command, u8 *data, int data_len) { @@ -284,7 +333,7 @@ static struct as5822_54x_psu_data *as5822_54x_psu_update_device(struct device *d if (IS_PRESENT(data->index, data->status)) { /* Read model name */ - status = as5822_54x_psu_read_block(client, MODEL_NAME_REG_OFFSET, data->model_name, + status = as5822_54x_psu_read_bytes(client, MODEL_NAME_REG_OFFSET, data->model_name, ARRAY_SIZE(data->model_name)-1); if (status < 0) { @@ -300,7 +349,7 @@ static struct as5822_54x_psu_data *as5822_54x_psu_update_device(struct device *d } /* Read serial number */ - status = as5822_54x_psu_read_block(client, SERIAL_NUM_REG_OFFSET, data->serial, + status = as5822_54x_psu_read_bytes(client, SERIAL_NUM_REG_OFFSET, data->serial, ARRAY_SIZE(data->serial)-1); if (status < 0) { diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c index eae7970e..a6bc521e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_psu.c @@ -176,8 +176,8 @@ static ssize_t for_linear_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(value >> 11, 5, 0x1f); mantissa = two_complement_to_int(value & 0x7ff, 11, 0x7ff); - return (exponent >= 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ + return (exponent >= 0) ? \ + sprintf(buf, "%d\n", (mantissa << exponent) * multiplier) : \ sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent)); } @@ -201,9 +201,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); mantissa = data->v_out; - return (exponent > 0) ? sprintf(buf, "%d\n", \ - mantissa * (1 << exponent)) : \ - sprintf(buf, "%d\n", mantissa / (1 << -exponent) * multiplier); + return (exponent > 0) ? \ + sprintf(buf, "%d\n", mantissa * multiplier * (1 << exponent)) : \ + sprintf(buf, "%d\n", mantissa * multiplier / (1 << -exponent)); } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c index a0459f37..198084f1 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_ag5648_sfp.c @@ -199,7 +199,7 @@ static ssize_t for_r_port_data(struct device *dev, struct device_attribute *dev_ } } - return sprintf(buf, "%d\n", sfp_port_data); + return sprintf(buf, "%d\n", (int)sfp_port_data); } static ssize_t set_w_lp_mode_data(struct device *dev, struct device_attribute *dev_attr, const char *buf, size_t count) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c index 00ed5ebe..ba63bdc8 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/modules/builds/dni_emc2305.c @@ -32,6 +32,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf); static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf); +static ssize_t show_percentage(struct device *dev, struct device_attribute *devattr, + char *buf); static ssize_t set_fan(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count); static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *devattr, @@ -57,6 +59,7 @@ static const unsigned short normal_i2c[] = { 0x2C, 0x2D, 0x2E, 0x2F, 0x4C, #define EMC2305_DEVICE 0x34 #define EMC2305_VENDOR 0x5D +#define MAX_FAN_SPEED 23000 struct emc2305_data { @@ -95,17 +98,17 @@ static SENSOR_DEVICE_ATTR(fan1_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 0); static SENSOR_DEVICE_ATTR(fan2_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 1); static SENSOR_DEVICE_ATTR(fan3_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 2); static SENSOR_DEVICE_ATTR(fan4_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 3); -static SENSOR_DEVICE_ATTR(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4); -static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 0); -static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 1); -static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 2); -static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 3); -static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_fan, set_fan_percentage, 4); +//static SENSOR_DEVICE_ATTR(fan5_input, S_IWUSR | S_IRUGO, show_fan, set_fan, 4); +static SENSOR_DEVICE_ATTR(fan1_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 0); +static SENSOR_DEVICE_ATTR(fan2_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 1); +static SENSOR_DEVICE_ATTR(fan3_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 2); +static SENSOR_DEVICE_ATTR(fan4_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 3); +//static SENSOR_DEVICE_ATTR(fan5_input_percentage, S_IWUSR | S_IRUGO, show_percentage, set_fan_percentage, 4); static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3); -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 4); +//static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 4); static struct attribute *emc2305_attr[] = { @@ -113,17 +116,17 @@ static struct attribute *emc2305_attr[] = &sensor_dev_attr_fan2_input.dev_attr.attr, &sensor_dev_attr_fan3_input.dev_attr.attr, &sensor_dev_attr_fan4_input.dev_attr.attr, - &sensor_dev_attr_fan5_input.dev_attr.attr, +// &sensor_dev_attr_fan5_input.dev_attr.attr, &sensor_dev_attr_fan1_input_percentage.dev_attr.attr, &sensor_dev_attr_fan2_input_percentage.dev_attr.attr, &sensor_dev_attr_fan3_input_percentage.dev_attr.attr, &sensor_dev_attr_fan4_input_percentage.dev_attr.attr, - &sensor_dev_attr_fan5_input_percentage.dev_attr.attr, +// &sensor_dev_attr_fan5_input_percentage.dev_attr.attr, &sensor_dev_attr_pwm1.dev_attr.attr, &sensor_dev_attr_pwm2.dev_attr.attr, &sensor_dev_attr_pwm3.dev_attr.attr, &sensor_dev_attr_pwm4.dev_attr.attr, - &sensor_dev_attr_pwm5.dev_attr.attr, +// &sensor_dev_attr_pwm5.dev_attr.attr, NULL }; @@ -169,6 +172,25 @@ static ssize_t set_fan_percentage(struct device *dev, struct device_attribute *d return count; } +static ssize_t show_percentage(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct emc2305_data *data = i2c_get_clientdata(client); + int val; + + + mutex_lock(&data->lock); + val = i2c_smbus_read_word_swapped(client, + EMC2305_REG_FAN_TACH(attr->index)); + mutex_unlock(&data->lock); + /* Left shift 3 bits for showing correct RPM */ + val = val >> 3; + if ((int)(3932160 * 2 / (val > 0 ? val : 1) == 960))return sprintf(buf, "%d\n", 0); + + return sprintf(buf, "%d\n", (int)(3932160 * 2 / (val > 0 ? val : 1) * 100 / MAX_FAN_SPEED)); +} static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, char *buf) @@ -332,7 +354,7 @@ static int emc2305_probe(struct i2c_client *client, goto exit_remove; } - for (i = 0; i < 5; i++) + for (i = 0; i < 4; i++) { /* set minimum drive to 0% */ i2c_smbus_write_byte_data(client, EMC2305_REG_FAN_MIN_DRIVE(i), FAN_MINIMUN); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c index 3c3014e0..4b2d45f0 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/fani.c @@ -39,14 +39,14 @@ typedef struct fan_path_S static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { { NULL, NULL, NULL }, - { "/3-004d/fan1_fault", "/3-004d/fan1_input", "/3-004d/fan1_input" }, - { "/3-004d/fan2_fault", "/3-004d/fan2_input", "/3-004d/fan2_input" }, - { "/3-004d/fan3_fault", "/3-004d/fan3_input", "/3-004d/fan3_input" }, - { "/3-004d/fan4_fault", "/3-004d/fan4_input", "/3-004d/fan4_input" }, - { "/5-004d/fan1_fault", "/5-004d/fan1_input", "/5-004d/fan1_input" }, - { "/5-004d/fan2_fault", "/5-004d/fan2_input", "/5-004d/fan2_input" }, - { "/5-004d/fan3_fault", "/5-004d/fan3_input", "/5-004d/fan3_input" }, - { "/5-004d/fan4_fault", "/5-004d/fan4_input", "/5-004d/fan4_input" }, + { "/3-004d/fan1_fault", "/3-004d/fan1_input", "/3-004d/fan1_input_percentage" }, + { "/3-004d/fan2_fault", "/3-004d/fan2_input", "/3-004d/fan2_input_percentage" }, + { "/3-004d/fan3_fault", "/3-004d/fan3_input", "/3-004d/fan3_input_percentage" }, + { "/3-004d/fan4_fault", "/3-004d/fan4_input", "/3-004d/fan4_input_percentage" }, + { "/5-004d/fan1_fault", "/5-004d/fan1_input", "/5-004d/fan1_input_percentage" }, + { "/5-004d/fan2_fault", "/5-004d/fan2_input", "/5-004d/fan2_input_percentage" }, + { "/5-004d/fan3_fault", "/5-004d/fan3_input", "/5-004d/fan3_input_percentage" }, + { "/5-004d/fan4_fault", "/5-004d/fan4_input", "/5-004d/fan4_input_percentage" }, { "/6-0059/psu_fan1_fault", "/6-0059/psu_fan1_speed_rpm", "/6-0059/psu_fan1_duty_cycle_percentage" }, { "/6-0058/psu_fan1_fault", "/6-0058/psu_fan1_speed_rpm", "/6-0058/psu_fan1_duty_cycle_percentage" } }; @@ -55,7 +55,7 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */ { \ { ONLP_FAN_ID_CREATE(FAN_##id##_ON_FAN_BOARD), "Chassis Fan "#id, 0 }, \ 0x0, \ - (ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM | ONLP_FAN_CAPS_GET_RPM), \ 0, \ 0, \ ONLP_FAN_MODE_INVALID, \ @@ -274,7 +274,7 @@ onlp_fani_rpm_set(onlp_oid_t id, int rpm) case FAN_6_ON_FAN_BOARD: case FAN_7_ON_FAN_BOARD: case FAN_8_ON_FAN_BOARD: - sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); + sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed); break; default: return ONLP_STATUS_E_INVALID; @@ -303,13 +303,21 @@ onlp_fani_percentage_set(onlp_oid_t id, int percentage) /* Select PSU member */ switch (local_id) { - case FAN_1_ON_PSU1: - case FAN_1_ON_PSU2: - break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + case FAN_7_ON_FAN_BOARD: + case FAN_8_ON_FAN_BOARD: + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); + break; default: return ONLP_STATUS_E_INVALID; } - sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].ctrl_speed); /* Write percentage to psu_fan1_duty_cycle_percentage */ sprintf(data, "%d", percentage); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c index 4400b2cc..a6584362 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/ledi.c @@ -2,7 +2,7 @@ * * * Copyright 2014 Big Switch Networks, Inc. - * Copyright (C) 2017 Delta Networks, Inc. + * Copyright (C) 2017 Delta Networks, Inc. * * Licensed under the Eclipse Public License, Version 1.0 (the * "License"); you may not use this file except in compliance @@ -43,44 +43,44 @@ * Get the information for the given LED OID. */ static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ { - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - }, - }; + { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "FAN TRAY 1 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "FAN TRAY 2 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "FAN TRAY 3 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, + { + { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "FAN TRAY 4 LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, + }, +}; /* * This function will be called prior to any other onlp_ledi_* functions. */ @@ -104,10 +104,10 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) dev_info.flags = DEFAULT_FLAG; /* Set front panel's mode of leds */ - r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); + r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); int local_id = ONLP_OID_ID_GET(id); switch(local_id) - { + { case LED_FRONT_FAN: if((r_data & 0xc0) == 0x80) info->mode = ONLP_LED_MODE_GREEN; @@ -118,6 +118,7 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) else info->mode = ONLP_LED_MODE_OFF; break; + case LED_FRONT_SYS: if((r_data & 0x30) == 0x10) info->mode = ONLP_LED_MODE_GREEN; @@ -125,9 +126,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) info->mode = ONLP_LED_MODE_ORANGE; else if((r_data & 0x30) == 0x00) info->mode = ONLP_LED_MODE_GREEN_BLINKING; + else if((r_data & 0x30) == 0x30) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; else return ONLP_STATUS_E_INTERNAL; break; + case LED_FRONT_PWR: if((r_data & 0x06) == 0x04) info->mode = ONLP_LED_MODE_GREEN; @@ -138,67 +142,80 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) else info->mode = ONLP_LED_MODE_OFF; break; + case LED_REAR_FAN_TRAY_1: dev_info.addr = FAN_TRAY_1; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x01) == 0x01) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x01) == 0x01) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x02) == 0x02) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_2: dev_info.addr = FAN_TRAY_2; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x04) == 0x04) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x08) == 0x08) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_3: dev_info.addr = FAN_TRAY_3; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x10) == 0x10) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x10) == 0x10) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x20) == 0x20) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + case LED_REAR_FAN_TRAY_4: dev_info.addr = FAN_TRAY_4; r_data = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); fantray_present = dni_i2c_lock_read(NULL, &dev_info); if(fantray_present >= 0) - { - if((r_data & 0x40) == 0x40) - info->mode = ONLP_LED_MODE_GREEN; - else - info->mode = ONLP_LED_MODE_ORANGE; - } + { + if((r_data & 0x40) == 0x40) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x80) == 0x80) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; + } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; + default: break; - } + } /* Set the on/off status */ - if (info->mode == ONLP_LED_MODE_OFF) + if (info->mode == ONLP_LED_MODE_OFF) info->status |= ONLP_LED_STATUS_FAILED; else info->status |=ONLP_LED_STATUS_PRESENT; @@ -236,186 +253,145 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { VALIDATE(id); int local_id = ONLP_OID_ID_GET(id); - int i = 0, count = 0 ,fan_board_not_present_count = 0 , fan_stat2_reg_mask = 0 , fan_stat1_reg_mask = 0 ; - int fantray_present = -1, rpm = 0, rpm1 = 0; - uint8_t front_panel_led_value, power_state,fan_tray_led_reg_value, fan_led_status_value, fan_tray_pres_value; - uint8_t psu1_state, psu2_state, alarm_reg_value, fan_tray_interface_detected_value; - dev_info_t dev_info; - dev_info.bus = I2C_BUS_3; - dev_info.offset = 0x00; - dev_info.flags = DEFAULT_FLAG; + uint8_t front_panel_led_value,fan_tray_led_reg_value; front_panel_led_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); fan_tray_led_reg_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG); - fan_led_status_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT1_REG); - fan_tray_pres_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); - alarm_reg_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,ALARM_REG); - + switch(local_id) - { + { case LED_FRONT_FAN: - /* Clean the bit 7,6 */ - front_panel_led_value &= ~0xC0; - fan_board_not_present_count = 0; - /* Read cpld fan status to check present. Fan tray 1-4 */ - for(i = 0; i < 4; i++) - { - fan_stat2_reg_mask = 0x01 << i; - fan_stat1_reg_mask = 0x01 << (i * 2); - if((fan_tray_pres_value & fan_stat2_reg_mask) == fan_stat2_reg_mask) - fan_board_not_present_count++; - else if((fan_led_status_value & fan_stat1_reg_mask) == fan_stat1_reg_mask) - count++; - } - /* Set front light of FAN */ - if(count == ALL_FAN_TRAY_EXIST) - { - front_panel_led_value |= 0x80;/*Solid green, FAN operates normally.*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - else if (fan_board_not_present_count > 0) - { - front_panel_led_value |= 0xc0;/*Blinking Yellow , FAN is failed */ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } + front_panel_led_value &= ~0xc0; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x80; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x40; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0xc0; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } else - { - front_panel_led_value |= 0x40;/*Solid Amber FAN operating is NOT present */ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - - break; - - case LED_FRONT_PWR: - /* Clean bit 2,1 */ - front_panel_led_value &= ~0x06; - /* switch CPLD to PSU 1 */ - dev_info.bus = I2C_BUS_6; - dev_info.addr = PSU1_EEPROM; - psu1_state = dni_i2c_lock_read(NULL, &dev_info); - /* switch CPLD to PSU 2 */ - dev_info.addr = PSU2_EEPROM; - psu2_state = dni_i2c_lock_read(NULL, &dev_info); - - if(psu1_state == 1 && psu2_state == 1) - { - power_state = dni_lock_cpld_read_attribute(MASTER_CPLD_PATH,PSU_STAT_REG); - - if((power_state & 0x40) == 0x40 || (power_state & 0x04) == 0x04) - { - front_panel_led_value |= 0x06; /*Blinking Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - else - { - front_panel_led_value |= 0x04; /*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); - } - } - else - front_panel_led_value |= 0x02; /*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG, front_panel_led_value); + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); break; case LED_FRONT_SYS: - /* Clean bit 4,5 */ front_panel_led_value &= ~0x30; - fan_board_not_present_count = 0; - /* Read fan eeprom to check present */ - for(i = 0;i < 4; i++) - { - fan_stat2_reg_mask = 0x01 << i; - if((fan_tray_pres_value & fan_stat2_reg_mask) == fan_stat2_reg_mask) - fan_board_not_present_count++; - } - if(fan_board_not_present_count > 0 || (alarm_reg_value & 0xff) == 0xff) - { - fan_tray_interface_detected_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,INTERRUPT_REG); - if(fan_tray_interface_detected_value == 0xfe || (alarm_reg_value & 0xff) == 0xff) - { - front_panel_led_value |= 0x20; - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH, LED_REG, front_panel_led_value); - } - } + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x10; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x20; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_GREEN_BLINKING) + { + front_panel_led_value |= 0x00; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0x30; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } else - { - front_panel_led_value |= 0x10; - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH, LED_REG, front_panel_led_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + break; + + case LED_FRONT_PWR: + front_panel_led_value &= ~0x06; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x04; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x02; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0x06; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); + } + else + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,LED_REG,front_panel_led_value); break; case LED_REAR_FAN_TRAY_1: - dev_info.addr = FAN_TRAY_1; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); fan_tray_led_reg_value &= ~0x03; - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x01;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x01; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x02; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x02;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_2: - dev_info.addr = FAN_TRAY_2; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); fan_tray_led_reg_value &= ~0x0c; - - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x04;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x04; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x08; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x08;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_3: - dev_info.addr = FAN_TRAY_3; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); fan_tray_led_reg_value &= ~0x30; - rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x10;/*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x10; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x20; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x20;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); break; case LED_REAR_FAN_TRAY_4: - dev_info.addr = FAN_TRAY_4; - fantray_present = dni_i2c_lock_read(NULL, &dev_info); fan_tray_led_reg_value &= ~0xc0; - rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); - if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm !=0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) - { - fan_tray_led_reg_value |= 0x40; /*Solid Green*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } + if(mode == ONLP_LED_MODE_GREEN) + { + fan_tray_led_reg_value |= 0x40; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_reg_value |= 0x80; + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + } else - { - fan_tray_led_reg_value |= 0x80;/*Solid Amber*/ - dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG, fan_tray_led_reg_value); - } - } + dni_lock_cpld_write_attribute(SLAVE_CPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_reg_value); + break; + } return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c index 648296d3..d6046c6e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.c @@ -41,24 +41,29 @@ int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, in int fd; int len; - if ((buffer == NULL) || (buf_size < 0)) { + if ((buffer == NULL) || (buf_size < 0)) + { return -1; } - if ((fd = open(filename, O_RDONLY)) == -1) { + if ((fd = open(filename, O_RDONLY)) == -1) + { return -1; } - if ((len = read(fd, buffer, buf_size)) < 0) { + if ((len = read(fd, buffer, buf_size)) < 0) + { close(fd); return -1; } - if ((close(fd) == -1)) { + if ((close(fd) == -1)) + { return -1; } - if ((len > buf_size) || (data_len != 0 && len != data_len)) { + if ((len > buf_size) || (data_len != 0 && len != data_len)) + { return -1; } @@ -278,3 +283,31 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data) return -1; } + +int dni_fan_speed_good() +{ + int rpm = 0, rpm1 = 0, speed_good = 0; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); + if(rpm != 0 && rpm != FAN_ZERO_RPM && rpm1 != 0 && rpm1 != FAN_ZERO_RPM) + speed_good++; + + return speed_good; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h index 8e617859..80792c62 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/platform_lib.h @@ -39,7 +39,7 @@ #define MAX_REAR_FAN_SPEED 20500 #define MAX_FRONT_FAN_SPEED 23000 -#define MAX_PSU_FAN_SPEED 19000 +#define MAX_PSU_FAN_SPEED 20256 #define NUM_OF_SFP 48 #define NUM_OF_QSFP 6 @@ -94,6 +94,7 @@ #define TURN_OFF (0) #define TURN_ON (1) #define ALL_FAN_TRAY_EXIST (4) +#define FAN_SPEED_NORMALLY (4) #define PSU_STATUS_PRESENT (1) #define PSU_NODE_MAX_PATH_LEN (64) #define FAN_ZERO_RPM (960) @@ -133,7 +134,6 @@ #define FAN_STAT1_REG (0x05) #define FAN_STAT2_REG (0x06) #define PSU_STAT_REG (0x03) -#define ALARM_REG (0x06) #define INTERRUPT_REG (0x02) #define PORT_ADDR (0x50) @@ -170,6 +170,7 @@ int dni_i2c_lock_read_attribute(mux_info_t * mux_info, char * fullpath); int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullpath); int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data); int dni_lock_cpld_read_attribute(char *cpld_path, int addr); +int dni_fan_speed_good(); #define DEBUG_MODE 0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c index f5e6204b..183d15fe 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/sysi.c @@ -172,10 +172,10 @@ onlp_sysi_oids_get(onlp_oid_t* table, int max) int onlp_sysi_platform_manage_fans(void) { - int i = 0; - int new_percentage; - int highest_temp = 0; - onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS]; + int i = 0; + int new_percentage; + int highest_temp = 0; + onlp_thermal_info_t thermal[NUM_OF_THERMAL_ON_BOARDS]; /* Get current temperature */ if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), &thermal[0]) != ONLP_STATUS_OK || onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), &thermal[1]) != ONLP_STATUS_OK || @@ -234,77 +234,136 @@ onlp_sysi_platform_manage_fans(void) int onlp_sysi_platform_manage_leds(void) { - /* Set front lights: fan, power supply 1, 2*/ - uint8_t addr, present_bit = 0x00; + int fantray_present = -1, rpm = 0, rpm1 = 0; + uint8_t psu1_state, psu2_state, power_state, fan_tray_interface_detected_value; + int fan_tray_pres_value, fan_board_not_present_count,i ,fan_stat_reg_mask; - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - /* Turn the fan led on or off */ - if((addr & 0xc0) == 0 ) + + dev_info_t dev_info; + dev_info.bus = I2C_BUS_3; + dev_info.offset = 0x00; + dev_info.flags = DEFAULT_FLAG; + + /* Fan tray 1 */ + dev_info.addr = FAN_TRAY_1; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED); } - /* Set front light of SYS */ - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - if((addr & 0x30) == 0x30) + /* Fan tray 2 */ + dev_info.addr = FAN_TRAY_2; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED); } - /* Set front light of PSU */ - addr = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,LED_REG); - - if((addr & 0x06) == 0x00) + /* Fan tray 3 */ + dev_info.addr = FAN_TRAY_3; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_ON); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED); } + + /* Fan tray 4 */ + dev_info.addr = FAN_TRAY_4; + fantray_present = dni_i2c_lock_read(NULL, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); + if(fantray_present >= 0 && rpm != FAN_ZERO_RPM && rpm != 0 && rpm1 != FAN_ZERO_RPM && rpm1 != 0 ) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN); + } + else + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_RED); + } + + /* FRONT FAN & SYS LED */ + fan_tray_pres_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); + fan_board_not_present_count = 0; + + for(i = 0;i < 4; i++) + { + fan_stat_reg_mask = 0x01 << i; + if((fan_tray_pres_value & fan_stat_reg_mask) == fan_stat_reg_mask) + fan_board_not_present_count++; + } + + if(fan_board_not_present_count == 0 && dni_fan_speed_good() == FAN_SPEED_NORMALLY) + { + /* Green FAN operates normally */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_GREEN); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_GREEN); + } + else + { + /* Solid Amber FAN or more failed*/ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN),ONLP_LED_MODE_ORANGE); + fan_tray_interface_detected_value = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,INTERRUPT_REG); + + if(fan_tray_interface_detected_value == 0xfe || (fan_tray_pres_value & 0x10) != 0x10) + { + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_SYS),ONLP_LED_MODE_ORANGE); + } + } + + /* Set front light of PWR */ + dev_info.bus = I2C_BUS_6; + dev_info.addr = PSU1_EEPROM; + psu1_state = dni_i2c_lock_read(NULL, &dev_info); - /* Turn on or off the FAN tray leds */ - present_bit = dni_lock_cpld_read_attribute(SLAVE_CPLD_PATH,FAN_STAT2_REG); - if((present_bit & 0x01) == 0x00) + dev_info.addr = PSU2_EEPROM; + psu2_state = dni_i2c_lock_read(NULL, &dev_info); + power_state = dni_lock_cpld_read_attribute(MASTER_CPLD_PATH,PSU_STAT_REG); + + if( psu1_state == 1 && psu2_state == 1 && (power_state & 0x22) == 0x22 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else if((power_state & 0x42) == 0x42 || (power_state & 0x24) == 0x24) + { + /* Blinking Amber */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE_BLINKING); } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON); - } - if((present_bit & 0x02) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_ON); - } - if((present_bit & 0x04) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_ON); - } - if((present_bit & 0x08) == 0x00) - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_OFF); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_ON); + else if ( ( power_state & 0x42 ) != 0x42 || ( power_state & 0x24 ) != 0x24 ) + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c index 22448190..b6ff50af 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/onlp/builds/src/module/src/thermali.c @@ -69,28 +69,28 @@ static char* cpu_coretemp_files[] = /* Static values */ static onlp_thermal_info_t linfo[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_CPU_BOARD), "Thermal sensor near CPU (U57, middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(65000,75000,80000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Thermal sensor near Middle of front vents (U291, Middle)", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(55000,65000,70000) - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Thermal sensor near Left of front vents (U290, Left)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_FAN_BOARD), "Thermal sensor near Middle of front vents (U291, Middle)", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(55000,65000,70000) + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Thermal sensor near Left of front vents (U290, Left)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Thermal sensor near MAC (U288, Middle)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(70000,80000,85000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Thermal sensor near Right of front vents (U289, right)", 0}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BOARD), "Thermal sensor near Right of front vents (U289, right)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(50000,60000,65000) }, @@ -98,11 +98,11 @@ static onlp_thermal_info_t linfo[] = { ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, dni_onlp_thermal_threshold(45000,55000,60000) }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS } @@ -151,5 +151,4 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) info->mcelsius = r_data / temp_base; return ONLP_STATUS_OK; -} - +} \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py index 336790ff..ae6dbc53 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag5648/platform-config/r0/src/python/x86_64_delta_ag5648_r0/__init__.py @@ -62,7 +62,6 @@ class OnlPlatform_x86_64_delta_ag5648_r0(OnlPlatformDelta, os.system("echo 80000 > /sys/class/hwmon/hwmon8/temp1_max_hyst") os.system("echo 60000 > /sys/class/hwmon/hwmon9/temp1_max_hyst") os.system("echo 55000 > /sys/class/hwmon/hwmon10/temp1_max_hyst") - return True diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c index 0d9b4aee..cc7c54cd 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/modules/builds/agc7648a_dps800ab.c @@ -257,9 +257,9 @@ static ssize_t for_vout_data(struct device *dev, struct device_attribute \ exponent = two_complement_to_int(data->vout_mode, 5, 0x1f); mantissa = data->v_out; - return (exponent > 0) ? sprintf(buf, "%d\n", \ - (mantissa << exponent) * multiplier) : \ - sprintf(buf, "%d\n", (mantissa << exponent) / (1 << -exponent)); + return (exponent > 0) ? \ + sprintf(buf, "%d\n", mantissa * multiplier * (1 << exponent)) : \ + sprintf(buf, "%d\n", mantissa * multiplier / (1 << -exponent)); } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c old mode 100755 new mode 100644 index b9b68115..d752236a --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/ledi.c @@ -51,37 +51,37 @@ static onlp_led_info_t linfo[] = { { ONLP_LED_ID_CREATE(LED_FRONT_FAN), "FRONT LED (FAN LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE_BLINKING, }, { { ONLP_LED_ID_CREATE(LED_FRONT_SYS), "FRONT LED (SYS LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING, }, { { ONLP_LED_ID_CREATE(LED_FRONT_PWR), "FRONT LED (PWR LED)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING | ONLP_LED_CAPS_GREEN, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), "REAR LED (FAN TRAY 1)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED , }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), "REAR LED (FAN TRAY 2)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), "REAR LED (FAN TRAY 3)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, }, { { ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), "REAR LED (FAN TRAY 4)", 0 }, ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_AUTO, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, } }; /* @@ -121,23 +121,35 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) { case LED_FRONT_FAN: if((r_data & 0x02) == 0x02) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data & 0x01) == 0x01) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0x01) == 0x01) + info->mode = ONLP_LED_MODE_ORANGE; + else if((r_data & 0x01) == 0x03) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; + else if((r_data & 0x01) == 0x00) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; break; case LED_FRONT_SYS: - if((r_data & 0x10) == 0x10) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data & 0x20) == 0x20) - info->mode = ONLP_LED_MODE_ORANGE; - else - return ONLP_STATUS_E_INTERNAL; + if((r_data & 0xF0) == 0x10) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data & 0xF0) == 0x20) + info->mode = ONLP_LED_MODE_ORANGE; + else if((r_data & 0xF0) == 0xa0) + info->mode = ONLP_LED_MODE_ORANGE_BLINKING; + else if((r_data & 0xF0) == 0x90) + info->mode = ONLP_LED_MODE_GREEN_BLINKING; + else if((r_data & 0xF0) == 0x0) + info->mode = ONLP_LED_MODE_OFF; + else + return ONLP_STATUS_E_INTERNAL; break; case LED_FRONT_PWR: if((r_data & 0x08) == 0x08) - info->mode = ONLP_LED_MODE_GREEN; + info->mode = ONLP_LED_MODE_GREEN; else if((r_data & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_ORANGE; else info->mode = ONLP_LED_MODE_OFF; break; @@ -151,10 +163,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x40) == 0x40) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x80) == 0x80) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_2: mux_info.channel= 0x01; @@ -166,10 +180,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x10) == 0x10) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x20) == 0x20) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_3: mux_info.channel= 0x02; @@ -178,13 +194,15 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); if(fantray_present >= 0) { - if((r_data1 & 0x04) == 0x04) - info->mode = ONLP_LED_MODE_GREEN; - else if((r_data1 & 0x08) == 0x08) - info->mode = ONLP_LED_MODE_ORANGE; + if((r_data1 & 0x04) == 0x04) + info->mode = ONLP_LED_MODE_GREEN; + else if((r_data1 & 0x08) == 0x08) + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; case LED_REAR_FAN_TRAY_4: mux_info.channel= 0x03; @@ -196,10 +214,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) if((r_data1 & 0x01) == 0x01) info->mode = ONLP_LED_MODE_GREEN; else if((r_data1 & 0x02) == 0x02) - info->mode = ONLP_LED_MODE_ORANGE; + info->mode = ONLP_LED_MODE_RED; + else + info->mode = ONLP_LED_MODE_OFF; } else - info->mode = ONLP_LED_MODE_OFF; + info->status = ONLP_LED_STATUS_FAILED; break; default: @@ -250,23 +270,7 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) { VALIDATE(id); int local_id = ONLP_OID_ID_GET(id); - int i = 0, count = 0 ; - int fantray_present = -1 ,rpm = 0,rpm1 = 0; - uint8_t front_panel_led_value, fan_tray_led_value, power_state; - - - mux_info_t mux_info; - mux_info.bus = I2C_BUS_5; - mux_info.addr = SWPLD; - mux_info.offset = FAN_MUX_REG; - mux_info.channel = 0x07; - mux_info.flags = DEFAULT_FLAG; - - dev_info_t dev_info; - dev_info.bus = I2C_BUS_3; - dev_info.offset = 0x00; - dev_info.flags = DEFAULT_FLAG; - + uint8_t front_panel_led_value, fan_tray_led_value; front_panel_led_value = dni_lock_cpld_read_attribute(SWPLD_PATH,LED_REG); fan_tray_led_value = dni_lock_cpld_read_attribute(SWPLD_PATH,FAN_TRAY_LED_REG); @@ -275,141 +279,137 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) case LED_FRONT_FAN: /* Clean the bit 1,0 */ front_panel_led_value &= ~0x3; - /* Read fan eeprom to check present */ - for(i = 0;i < 4; i++) + if(mode == ONLP_LED_MODE_GREEN) { - mux_info.channel = i; - /* FAN TRAT 1~4: 0x52 , 0x53, 0x54, 0x55 */ - dev_info.addr = FAN_TRAY_1 + i; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - if( fantray_present >= 0 ) - count++; + front_panel_led_value |= 0x02; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - /* Set front light of FAN */ - if(count == ALL_FAN_TRAY_EXIST) + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) { - front_panel_led_value|=0x02; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x03; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x01; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_OFF) + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); else - { - front_panel_led_value|=0x01; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); - } - + return ONLP_STATUS_E_UNSUPPORTED; break; + case LED_FRONT_SYS: + front_panel_led_value &= ~0xF0; + if(mode == ONLP_LED_MODE_GREEN) + { + front_panel_led_value |= 0x10; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE_BLINKING) + { + front_panel_led_value |= 0xA0; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_ORANGE) + { + front_panel_led_value |= 0x20; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_GREEN_BLINKING) + { + front_panel_led_value |= 0x90; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else if(mode == ONLP_LED_MODE_OFF) + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + else + return ONLP_STATUS_E_UNSUPPORTED; + break; + case LED_FRONT_PWR: /* Clean bit 3,2 */ front_panel_led_value &= ~0x0C; /* switch CPLD to PSU 1 */ - dev_info.bus = I2C_BUS_4; - dev_info.addr = PSU_EEPROM; - mux_info.channel = 0x00; - - /* Check the state of PSU 1, "state = 1, PSU exists' */ - power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); - /* Set the light of PSU */ - if((power_state&0x80) != 0x80) + if(mode == ONLP_LED_MODE_GREEN) { - /* Red */ - front_panel_led_value|=0x04; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x08; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - else if((power_state&0x80)==0x80) + else if(mode == ONLP_LED_MODE_ORANGE) { - /* Green */ - front_panel_led_value|=0x08; - dni_lock_cpld_write_attribute(SWPLD_PATH, LED_REG, front_panel_led_value); + front_panel_led_value |= 0x04; + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); } - else - dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG, front_panel_led_value); + else if(mode == ONLP_LED_MODE_OFF) + { + dni_lock_cpld_write_attribute(SWPLD_PATH,LED_REG,front_panel_led_value); + } + else + return ONLP_STATUS_E_UNSUPPORTED; break; - case LED_REAR_FAN_TRAY_1: - mux_info.channel= 0x00; - dev_info.addr = FAN_TRAY_1; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); fan_tray_led_value &= ~0xC0; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x40; + fan_tray_led_value |= 0x40; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x80; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x80; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; - case LED_REAR_FAN_TRAY_2: - mux_info.channel= 0x01; - dev_info.addr = FAN_TRAY_2; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); - fan_tray_led_value &= ~0x30; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + case LED_REAR_FAN_TRAY_2: + fan_tray_led_value &= ~0x30; + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x10; + fan_tray_led_value |= 0x10; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x20; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x20; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; case LED_REAR_FAN_TRAY_3: - mux_info.channel= 0x02; - dev_info.bus = I2C_BUS_3; - dev_info.addr = FAN_TRAY_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); fan_tray_led_value &= ~0x0c; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x04; + fan_tray_led_value |= 0x04; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x08; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x08; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } break; case LED_REAR_FAN_TRAY_4: - mux_info.channel= 0x03; - dev_info.addr = FAN_TRAY_4; - dev_info.bus = I2C_BUS_3; - fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); - rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); - rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); fan_tray_led_value &= ~0x03; - if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + if(mode == ONLP_LED_MODE_GREEN) { - /* Green */ - fan_tray_led_value |=0x01; + fan_tray_led_value |= 0x01; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + } + else if(mode == ONLP_LED_MODE_RED) + { + fan_tray_led_value |= 0x02; dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); } else - { - /* Red */ - fan_tray_led_value |=0x02; - dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); - } - break; + dni_lock_cpld_write_attribute(SWPLD_PATH,FAN_TRAY_LED_REG,fan_tray_led_value); + + break; } return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h old mode 100755 new mode 100644 index 3a73af24..1e1eb419 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/platform_lib.h @@ -33,7 +33,7 @@ #define PSU1_ID 1 #define PSU2_ID 2 - +#define ALL_FAN_TRAY_EXIST 4 #define SYS_DEV_PATH "/sys/bus/i2c/devices" #define CPU_CPLD_PATH SYS_DEV_PATH "/2-0031" #define SWPLD_PATH SYS_DEV_PATH "/5-0030" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c old mode 100755 new mode 100644 index 22214e61..d28595f5 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/onlp/builds/src/module/src/sysi.c @@ -58,27 +58,27 @@ decide_percentage(int *percentage, int temper) { int level; - if(temper < 65) + if(temper <= 25) { - *percentage = 50; + *percentage = 40; level = 0; } - else if(temper >= 65 && temper <= 70) + else if(temper > 25 && temper <= 40) { *percentage = 60; level = 1; } - else if(temper > 70 && temper <= 75) + else if(temper > 40 && temper <= 55) { - *percentage = 70; + *percentage = 80; level = 2; } - else if(temper > 75 && temper <= 80) + else if(temper > 55 && temper <= 75) { - *percentage = 85; + *percentage = 90; level = 3; } - else if(temper > 80) + else if(temper > 75) { *percentage = 100; level = 4; @@ -229,64 +229,156 @@ int onlp_sysi_platform_manage_leds(void) { - uint8_t present_bit = 0 ,addr = 0; - + uint8_t count, power_state; + int fantray_present = -1 ,rpm = 0,rpm1 = 0 , i; /* set PWR led in front panel */ - addr = dni_lock_cpld_read_attribute(SWPLD_PATH,LED_REG); - /* Turn the fan led on or off */ - if((addr & 0x3) == 0 || (addr & 0x3) == 0x3 ) + mux_info_t mux_info; + mux_info.bus = I2C_BUS_5; + mux_info.addr = SWPLD; + mux_info.offset = FAN_MUX_REG; + mux_info.channel = 0x07; + mux_info.flags = DEFAULT_FLAG; + + dev_info_t dev_info; + dev_info.bus = I2C_BUS_3; + dev_info.offset = 0x00; + dev_info.flags = DEFAULT_FLAG; + + + /* FRONT FAN & SYS LED */ + for(i = 0;i < 4; i++) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_OFF); + mux_info.channel = i; + /* FAN TRAT 1~4: 0x52 , 0x53, 0x54, 0x55 */ + dev_info.addr = FAN_TRAY_1 + i; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + if( fantray_present >= 0 ) + count++; + } + if(count == ALL_FAN_TRAY_EXIST) + { + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), TURN_ON); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_FAN), ONLP_LED_MODE_ORANGE); } - if(dni_psu_present_get(1) == 1) - { /* PSU1 is present */ - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_ON); - } - else - { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), TURN_OFF); - } - /* Rare light fan tray 1-4 */ - present_bit = dni_lock_cpld_read_attribute(SWPLD_PATH,FAN_TRAY_LED_REG); + dev_info.bus = I2C_BUS_4; + dev_info.addr = PSU_EEPROM; + mux_info.channel = 0x00; - if ((present_bit& 0x08) == 0x00) + /* Check the state of PSU 1, "state = 1, PSU exists' */ + power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); + /* Set the light of PSU */ + if((power_state&0x80) != 0x80) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_ON); + /* ORANGE */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); + } + else if((power_state&0x80)==0x80) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + + mux_info.channel= 0x00; + dev_info.addr = FAN_TRAY_1; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN4_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN4_REAR); + if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_1),ONLP_LED_MODE_RED); } - if ((present_bit& 0x04) == 0x00) + /* Fan tray 2 */ + mux_info.channel= 0x01; + dev_info.addr = FAN_TRAY_2; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN3_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN3_REAR); + if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_2),ONLP_LED_MODE_RED); } - if ((present_bit& 0x02) == 0x00) + + /* Fan tray 3 */ + mux_info.channel= 0x02; + dev_info.bus = I2C_BUS_3; + dev_info.addr = FAN_TRAY_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN2_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN2_REAR); + + if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_3),ONLP_LED_MODE_RED); } - if ((present_bit& 0x01) == 0x00) + + /* Fan tray 4 */ + mux_info.channel= 0x03; + dev_info.addr = FAN_TRAY_4; + dev_info.bus = I2C_BUS_3; + fantray_present = dni_i2c_lock_read(&mux_info, &dev_info); + rpm = dni_i2c_lock_read_attribute(NULL, FAN1_FRONT); + rpm1 = dni_i2c_lock_read_attribute(NULL, FAN1_REAR); + if(fantray_present >= 0 && rpm != 960 && rpm != 0 && rpm1 != 960 && rpm1 != 0 ) { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_ON); + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_GREEN); } else { - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4), TURN_OFF); + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN_TRAY_4),ONLP_LED_MODE_RED); } + + + /* Set front light of PWR */ + dev_info.bus = I2C_BUS_4; + dev_info.addr = PSU_EEPROM; + mux_info.channel = 0x00; + + /* Check the state of PSU 1, "state = 1, PSU exists' */ + power_state = dni_lock_cpld_read_attribute(SWPLD_PATH, PSU_PWR_REG); + /* Set the light of PSU */ + + if((power_state&0x80) == 0x80) + { + /* Green */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_GREEN); + } + else if((power_state&0x80) != 0x80) + { + /* Red */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_ORANGE); + } + else + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR), ONLP_LED_MODE_OFF); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py index bb01636e..7e84909b 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648a/platform-config/r0/src/python/x86_64_delta_agc7648a_r0/__init__.py @@ -50,6 +50,6 @@ class OnlPlatform_x86_64_delta_agc7648a_r0(OnlPlatformDelta, self.new_i2c_device('agc7648a_sfp', 0x50, 8) # Set front panel green light of sys led - os.system("echo 0x30 > /sys/bus/i2c/devices/5-0030/addr") + os.system("echo 0x1c > /sys/bus/i2c/devices/5-0030/addr") os.system("echo 0x10 > /sys/bus/i2c/devices/5-0030/data") return True diff --git a/packages/platforms/inventec/Makefile b/packages/platforms/inventec/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/vendor-config/Makefile b/packages/platforms/inventec/vendor-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/vendor-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/vendor-config/PKG.yml b/packages/platforms/inventec/vendor-config/PKG.yml new file mode 100644 index 00000000..4afa2f7c --- /dev/null +++ b/packages/platforms/inventec/vendor-config/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=inventec Vendor=Inventec diff --git a/packages/platforms/inventec/vendor-config/src/python/inventec/__init__.py b/packages/platforms/inventec/vendor-config/src/python/inventec/__init__.py new file mode 100644 index 00000000..41f7a3e6 --- /dev/null +++ b/packages/platforms/inventec/vendor-config/src/python/inventec/__init__.py @@ -0,0 +1,7 @@ +#!/usr/bin/python + +from onl.platform.base import * + +class OnlPlatformInventec(OnlPlatformBase): + MANUFACTURER='Inventec' + PRIVATE_ENTERPRISE_NUMBER=6569 diff --git a/packages/platforms/inventec/x86-64/Makefile b/packages/platforms/inventec/x86-64/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/modules/Makefile b/packages/platforms/inventec/x86-64/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/modules/PKG.yml b/packages/platforms/inventec/x86-64/modules/PKG.yml new file mode 100644 index 00000000..3690f5a9 --- /dev/null +++ b/packages/platforms/inventec/x86-64/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=amd64 VENDOR=inventec diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/PKG.yml new file mode 100644 index 00000000..cad0df03 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d7032q28b ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/Makefile new file mode 100644 index 00000000..1fe88c1d --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := inventec +BASENAME := x86-64-inventec-d7032q28b +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_cpld.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_cpld.c new file mode 100644 index 00000000..a5e38353 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_cpld.c @@ -0,0 +1,456 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "I2CHostCommunication.h" + +#define USE_SMBUS 1 + +/* definition */ +#define CPLD_INFO_OFFSET 0x00 +#define CPLD_RESET_OFFSET 0x08 +#define CPLD_PSU_OFFSET 0x09 +#define CPLD_LED_OFFSET 0x0E +#define CPLD_LED_STATU_OFFSET 0x0D +#define CPLD_CTL_OFFSET 0x0C + + + +/* Each client has this additional data */ +struct cpld_data { + struct device *hwmon_dev; + struct mutex update_lock; +}; + +/*-----------------------------------------------------------------------*/ + +static ssize_t cpld_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg[0].buf = msgbuf; + msg[0].len = 1; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + + status = i2c_transfer(client->adapter, msg, 2); + + if(status == 2) + status = count; + + return status; +#endif +} + +static ssize_t cpld_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + + return status; +#endif +} + +/*-----------------------------------------------------------------------*/ + +/* sysfs attributes for hwmon */ + +static ssize_t show_info(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + //struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 b[4]; + + memset(b, 0, 4); + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, b, CPLD_INFO_OFFSET, 4); + mutex_unlock(&data->update_lock); + + if(status != 4) return sprintf(buf, "read cpld info fail\n"); + + status = sprintf (buf, "The CPLD release date is %02d/%02d/%d.\n", b[2] & 0xf, (b[3] & 0x1f), 2014+(b[2] >> 4)); /* mm/dd/yyyy*/ + status = sprintf (buf, "%sThe PCB version is %X%X\n", buf, b[0]>>4, b[0]&0xf); + status = sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, b[1]>>4, b[1]&0xf); + + return strlen(buf); +} + +static ssize_t show_reset(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + //struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 b[1]; + + mutex_lock(&data->update_lock); + + status = cpld_i2c_read(client, b, CPLD_RESET_OFFSET, 1); + + mutex_unlock(&data->update_lock); + + if(status != 1) return sprintf(buf, "read cpld reset fail\n"); + + + status = sprintf (buf, "The CPLD 1 cpld_reset = %d\n", b[0]); + + return strlen(buf); +} + +static ssize_t set_reset(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + + u8 temp = simple_strtol(buf, NULL, 10); + + mutex_lock(&data->update_lock); + cpld_i2c_write(client, &temp, CPLD_RESET_OFFSET, 1); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_ctl(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + //struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 b[1]; + + mutex_lock(&data->update_lock); + + status = cpld_i2c_read(client, b, CPLD_CTL_OFFSET, 1); + + mutex_unlock(&data->update_lock); + + if(status != 1) return sprintf(buf, "read cpld ctl fail\n"); + + + status = sprintf (buf, "0x%X\n", b[0]); + + return strlen(buf); +} + +static ssize_t set_ctl(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 byte; + + u8 temp = simple_strtol(buf, NULL, 10); + + mutex_lock(&data->update_lock); + cpld_i2c_read(client, &byte, CPLD_CTL_OFFSET, 1); + if(temp) byte |= (1<<0); + else byte &= ~(1<<0); + cpld_i2c_write(client, &byte, CPLD_CTL_OFFSET, 1); + mutex_unlock(&data->update_lock); + + return count; +} + +static char* led_str[] = { + "OFF", //000 + "0.5 Hz", //001 + "1 Hz", //010 + "2 Hz", //011 + "NA", //100 + "NA", //101 + "NA", //110 + "ON", //111 +}; + +static ssize_t show_led(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 byte; + int shift = (attr->index == 0)?3:0; + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); + mutex_unlock(&data->update_lock); + + if(status != 1) return sprintf(buf, "read cpld offset 0x%x\n", CPLD_LED_OFFSET); + + byte = (byte >> shift) & 0x7; + + /* + 0: off + 1: 0.5hz + 2: 1 hz + 3: 2 hz + 4~6: not define + 7: on + */ + + status = sprintf (buf, "%d: %s\n", byte, led_str[byte]); + + return strlen(buf); +} + +static ssize_t set_led(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + + u8 temp = simple_strtol(buf, NULL, 16); + u8 byte; + int shift = (attr->index == 0)?3:0; + + temp &= 0x7; + //validate temp value: 0,1,2,3,7, TBD + + mutex_lock(&data->update_lock); + cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); + byte &= ~(0x7<update_lock); + + return count; +} + +/* +CPLD report the PSU0 status +000 = PSU normal operation +100 = PSU fault +010 = PSU unpowered +111 = PSU not installed + +7 6 | 5 4 3 | 2 1 0 +---------------------- + | psu0 | psu1 +*/ +static char* psu_str[] = { + "normal", //000 + "NA", //001 + "unpowered", //010 + "NA", //011 + "fault", //100 + "NA", //101 + "NA", //110 + "not installed", //111 +}; + +static ssize_t show_psu(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct cpld_data *data = i2c_get_clientdata(client); + u8 byte; + int shift = (attr->index == 1)?0:3; + + mutex_lock(&data->update_lock); + status = cpld_i2c_read(client, &byte, CPLD_PSU_OFFSET, 1); + mutex_unlock(&data->update_lock); + + byte = (byte >> shift) & 0x7; + + status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); + + return strlen(buf); +} + + +static SENSOR_DEVICE_ATTR(info, S_IRUGO, show_info, 0, 0); +static SENSOR_DEVICE_ATTR(reset, S_IWUSR|S_IRUGO, show_reset, set_reset, 0); +static SENSOR_DEVICE_ATTR(ctl, S_IWUSR|S_IRUGO, show_ctl, set_ctl, 0); + +static SENSOR_DEVICE_ATTR(grn_led, S_IWUSR|S_IRUGO, show_led, set_led, 0); +static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, 1); + +static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu, 0, 0); +static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 1); + +static struct attribute *cpld_attributes[] = { + //info + &sensor_dev_attr_info.dev_attr.attr, + &sensor_dev_attr_reset.dev_attr.attr, + &sensor_dev_attr_ctl.dev_attr.attr, + + &sensor_dev_attr_grn_led.dev_attr.attr, + &sensor_dev_attr_red_led.dev_attr.attr, + + &sensor_dev_attr_psu0.dev_attr.attr, + &sensor_dev_attr_psu1.dev_attr.attr, + + NULL +}; + +static const struct attribute_group cpld_group = { + .attrs = cpld_attributes, +}; + +/*-----------------------------------------------------------------------*/ + +/* device probe and removal */ + +static int +cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct cpld_data *data; + int status; + + printk("+%s\n", __func__); + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) + return -EIO; + + data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &cpld_group); + if (status) + goto exit_free; + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: sensor '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &cpld_group); +exit_free: + i2c_set_clientdata(client, NULL); + kfree(data); + return status; +} + +static int cpld_remove(struct i2c_client *client) +{ + struct cpld_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &cpld_group); + i2c_set_clientdata(client, NULL); + kfree(data); + return 0; +} + +static const struct i2c_device_id cpld_ids[] = { + { "inv_cpld", 0, }, + { /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, cpld_ids); + +static struct i2c_driver cpld_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "inv_cpld", + }, + .probe = cpld_probe, + .remove = cpld_remove, + .id_table = cpld_ids, +}; + +/*-----------------------------------------------------------------------*/ + +/* module glue */ + +static int __init inv_cpld_init(void) +{ + return i2c_add_driver(&cpld_driver); +} + +static void __exit inv_cpld_exit(void) +{ + i2c_del_driver(&cpld_driver); +} + +MODULE_AUTHOR("eddie.lan "); +MODULE_DESCRIPTION("inv cpld driver"); +MODULE_LICENSE("GPL"); + +module_init(inv_cpld_init); +module_exit(inv_cpld_exit); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_platform.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_platform.c new file mode 100644 index 00000000..f046ba8c --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/modules/builds/inv_platform.c @@ -0,0 +1,197 @@ +#include +//#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//#include +#define IO_EXPAND_BASE 64 +#define IO_EXPAND_NGPIO 16 + +struct inv_i2c_board_info { + int ch; + int size; + struct i2c_board_info *board_info; +}; + +#define bus_id(id) (id) +static struct pca954x_platform_mode mux_modes_0[] = { + {.adap_id = bus_id(2),}, {.adap_id = bus_id(3),}, + {.adap_id = bus_id(4),}, {.adap_id = bus_id(5),}, +}; +static struct pca954x_platform_mode mux_modes_0_0[] = { + {.adap_id = bus_id(6),}, {.adap_id = bus_id(7),}, + {.adap_id = bus_id(8),}, {.adap_id = bus_id(9),}, + {.adap_id = bus_id(10),}, {.adap_id = bus_id(11),}, + {.adap_id = bus_id(12),}, {.adap_id = bus_id(13),}, +}; + +static struct pca954x_platform_mode mux_modes_0_1[] = { + {.adap_id = bus_id(14),}, {.adap_id = bus_id(15),}, + {.adap_id = bus_id(16),}, {.adap_id = bus_id(17),}, + {.adap_id = bus_id(18),}, {.adap_id = bus_id(19),}, + {.adap_id = bus_id(20),}, {.adap_id = bus_id(21),}, +}; + +static struct pca954x_platform_mode mux_modes_0_2[] = { + {.adap_id = bus_id(22),}, {.adap_id = bus_id(23),}, + {.adap_id = bus_id(24),}, {.adap_id = bus_id(25),}, + {.adap_id = bus_id(26),}, {.adap_id = bus_id(27),}, + {.adap_id = bus_id(28),}, {.adap_id = bus_id(29),}, +}; + +static struct pca954x_platform_mode mux_modes_0_3[] = { + {.adap_id = bus_id(30),}, {.adap_id = bus_id(31),}, + {.adap_id = bus_id(32),}, {.adap_id = bus_id(33),}, + {.adap_id = bus_id(34),}, {.adap_id = bus_id(35),}, + {.adap_id = bus_id(36),}, {.adap_id = bus_id(37),}, +}; + +static struct pca954x_platform_data mux_data_0 = { + .modes = mux_modes_0, + .num_modes = 4, +}; +static struct pca954x_platform_data mux_data_0_0 = { + .modes = mux_modes_0_0, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_1 = { + .modes = mux_modes_0_1, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_2 = { + .modes = mux_modes_0_2, + .num_modes = 8, +}; +static struct pca954x_platform_data mux_data_0_3 = { + .modes = mux_modes_0_3, + .num_modes = 8, +}; + +static struct i2c_board_info i2c_device_info0[] __initdata = { + {"inv_psoc", 0, 0x66, 0, 0, 0},//psoc + {"inv_cpld", 0, 0x55, 0, 0, 0},//cpld + {"pca9545", 0, 0x70, &mux_data_0, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info1[] __initdata = { + {"pca9545", 0, 0x70, &mux_data_0, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info2[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_0, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info3[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_1, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info4[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_2, 0, 0}, +}; + +static struct i2c_board_info i2c_device_info5[] __initdata = { + {"pca9548", 0, 0x72, &mux_data_0_3, 0, 0}, +}; + + +static struct inv_i2c_board_info i2cdev_list[] = { + {0, ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //smbus 0 + {1, ARRAY_SIZE(i2c_device_info1), i2c_device_info1 }, //smbus 1 or gpio11+12 + + {bus_id(2), ARRAY_SIZE(i2c_device_info2), i2c_device_info2 }, //mux 0 + {bus_id(3), ARRAY_SIZE(i2c_device_info3), i2c_device_info3 }, //mux 1 + {bus_id(4), ARRAY_SIZE(i2c_device_info4), i2c_device_info4 }, //mux 2 + {bus_id(5), ARRAY_SIZE(i2c_device_info5), i2c_device_info5 }, //mux 3 +}; + +///////////////////////////////////////////////////////////////////////////////////////// +static struct i2c_gpio_platform_data i2c_gpio_platdata0 = { + .scl_pin = 8, + .sda_pin = 9, + + .udelay = 5, //5:100kHz + .sda_is_open_drain = 0, + .scl_is_open_drain = 0, + .scl_is_output_only = 0 +}; + +static struct i2c_gpio_platform_data i2c_gpio_platdata1 = { + .scl_pin = 12, + .sda_pin = 11, + + .udelay = 5, //5:100kHz + .sda_is_open_drain = 0, + .scl_is_open_drain = 0, + .scl_is_output_only = 0 +}; + +static struct platform_device device_i2c_gpio0 = { + .name = "i2c-gpio", + .id = 0, // adapter number + .dev.platform_data = &i2c_gpio_platdata0, +}; + +static struct platform_device device_i2c_gpio1 = { + .name = "i2c-gpio", + .id = 1, // adapter number + .dev.platform_data = &i2c_gpio_platdata1, +}; + +static int __init plat_redwood_x86_init(void) +{ + struct i2c_adapter *adap = NULL; + struct i2c_client *e = NULL; + int ret = 0; + int i,j; + + printk("el6661 plat_redwood_x86_init \n"); + +#if 0 //disable for ICOS + //use i2c-gpio + //register i2c gpio + //config gpio8,9 to gpio function + outl( inl(0x500) | (1<<8 | 1<<9), 0x500); + + ret = platform_device_register(&device_i2c_gpio0); + if (ret) { + printk(KERN_ERR "i2c-gpio: device_i2c_gpio0 register fail %d\n", ret); + } + + outl( inl(0x500) | (1<<11 | 1<<12), 0x500); + ret = platform_device_register(&device_i2c_gpio1); + if (ret) { + printk(KERN_ERR "i2c-gpio: device_i2c_gpio1 register fail %d\n", ret); + } +#endif + + for(i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "I2CHostCommunication.h" + +#define USE_SMBUS 1 + +//#define offsetof(st, m) ((size_t)(&((st *)0)->m)) +#define FAN_NUM 5 +#define PSU_NUM 2 + +struct __attribute__ ((__packed__)) psoc_psu_layout { + u16 psu1_iin; + u16 psu2_iin; + u16 psu1_iout; + u16 psu2_iout; + + u16 psu1_pin; + u16 psu2_pin; + u16 psu1_pout; + u16 psu2_pout; + + u16 psu1_vin; + u16 psu2_vin; + u16 psu1_vout; + u16 psu2_vout; +}; + +struct __attribute__ ((__packed__)) psoc_layout { + u8 ctl; //offset: 0 + u16 switch_temp; //offset: 1 + u8 reserve1; //offset: 3 + + u8 fw_upgrade; //offset: 4 + + //i2c bridge + u8 i2c_st; //offset: 5 + u8 i2c_ctl; //offset: 6 + u8 i2c_addr; //offset: 7 + u8 i2c_data[0x20]; //offset: 8 + + //gpo + u8 led_grn; //offset: 28 + u8 led_red; //offset: 29 + + //pwm duty + u8 pwm[FAN_NUM]; //offset: 2a + u8 pwm_psu[PSU_NUM]; //offset: 2f + + //fan rpm + u16 fan[FAN_NUM*2]; //offset: 31 + //u16 fan_psu[PSU_NUM]; + + //gpi + u8 gpi_fan; //offset: 45 + + //psu state + u8 psu_state; //offset: 46 + + //temperature + u16 temp[5]; //offset: 47 + u16 temp_psu[PSU_NUM]; //offset: 51 + + //version + u8 version[2]; //offset: 55 + + u8 reserve2[3]; //offset: 57 + struct psoc_psu_layout psu_info; //offset: 5a +}; + + +/* definition */ +#define PSOC_OFF(m) offsetof(struct psoc_layout, m) +#define PSOC_PSU_OFF(m) offsetof(struct psoc_psu_layout, m) + +#define SWITCH_TMP_OFFSET PSOC_OFF(switch_temp) //0x01 +#define PWM_OFFSET PSOC_OFF(pwm) +#define PWM_PSU_OFFSET PSOC_OFF(pwm_psu) +#define THERMAL_OFFSET PSOC_OFF(temp) +#define RPM_OFFSET PSOC_OFF(fan) +//#define RPM_PSU_OFFSET PSOC_OFF(fan_psu) +#define DIAG_FLAG_OFFSET PSOC_OFF(ctl) +#define FAN_LED_OFFSET PSOC_OFF(led_grn) +#define FAN_GPI_OFFSET PSOC_OFF(gpi_fan) +#define PSOC_PSU_OFFSET PSOC_OFF(psu_state) +#define VERSION_OFFSET PSOC_OFF(version) +#define PSU_INFO_OFFSET PSOC_OFF(psu_info) + + +/* Each client has this additional data */ +struct psoc_data { + struct device *hwmon_dev; + struct mutex update_lock; + u32 diag; +}; + +/*-----------------------------------------------------------------------*/ + +static ssize_t psoc_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg[0].buf = msgbuf; + msg[0].len = 1; + + msg[1].addr = client->addr; + msg[1].flags = I2C_M_RD; + msg[1].buf = buf; + msg[1].len = count; + + status = i2c_transfer(client->adapter, msg, 2); + + if(status == 2) + status = count; + + return status; +#endif +} + +static ssize_t psoc_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count) +{ +#if USE_SMBUS + int i; + + for(i=0; iaddr; + msg.flags = 0; + + /* msg.buf is u8 and casts will mask the values */ + msg.buf = writebuf; + + msg.buf[i++] = offset; + memcpy(&msg.buf[i], buf, count); + msg.len = i + count; + + status = i2c_transfer(client->adapter, &msg, 1); + if (status == 1) + status = count; + + return status; +#endif +} + +static u32 psoc_read32(struct i2c_client *client, u8 offset) +{ + u32 value = 0; + u8 buf[4]; + + if( psoc_i2c_read(client, buf, offset, 4) == 4) + value = (buf[0]<<24 | buf[1]<<16 | buf[2]<<8 | buf[3]); + + return value; +} + +static u16 psoc_read16(struct i2c_client *client, u8 offset) +{ + u16 value = 0; + u8 buf[2]; + + if(psoc_i2c_read(client, buf, offset, 2) == 2) + value = (buf[0]<<8 | buf[1]<<0); + + return value; +} + +static u8 psoc_read8(struct i2c_client *client, u8 offset) +{ + u8 value = 0; + u8 buf = 0; + + if(psoc_i2c_read(client, &buf, offset, 1) == 1) + value = buf; + + return value; +} + +static int psoc_write_value(struct i2c_client *client, unsigned offset, u16 value) +{ + //TBD + return 0; +} + + +//PSOC i2c bridge regsters +#define PSOC_I2C_STATUS PSOC_OFF(i2c_st) +#define PSOC_I2C_CNTRL PSOC_OFF(i2c_ctl) +#define PSOC_I2C_ADDR PSOC_OFF(i2c_addr) +#define PSOC_I2C_DATA PSOC_OFF(i2c_data) + +//status bit definition +#define PSOC_I2C_START (1 << 0) +#define PSOC_PMB_SEL (1 << 7) + +//addr bits definition +#define PSOC_I2C_READ (1 << 0) + +//PMBUS registers definition +#define PMBUS_READ_VIN (0x88) +#define PMBUS_READ_IIN (0x89) +#define PMBUS_READ_VOUT (0x8B) +#define PMBUS_READ_IOUT (0x8C) +#define PMBUS_READ_POUT (0x96) +#define PMBUS_READ_PIN (0x97) + +#define PMBUS_MFR_ID (0x99) +#define PMBUS_MFR_MODEL (0x9A) +#define PMBUS_MFR_REVISION (0x9B) +#define PMBUS_MFR_DATE (0x9D) +#define PMBUS_MFR_SERIAL (0x9E) + +static int psoc_i2c_bridge_read(struct i2c_client *client, + unsigned char bus, + unsigned char chip, + char *addr, int alen, + unsigned char *data, int len ) +{ + unsigned char txdata[28], rxdata[28]; + int index, timeout; + + txdata[PSOC_I2C_STATUS] = 0; /* the status */ + txdata[PSOC_I2C_CNTRL] = ((alen & 3) << 5) | (len & 0x1f); /* the sizes */ + txdata[PSOC_I2C_ADDR] = (chip << 1) | PSOC_I2C_READ; /* read address */ + for(index = 0; index < alen; index++) + txdata[PSOC_I2C_DATA + index] = addr[index]; /* the chip address */ + for(; index < alen+len; index++) + txdata[PSOC_I2C_DATA + index] = 0; /* clear the chip data */ + + psoc_i2c_write(client, &txdata[PSOC_I2C_CNTRL], PSOC_I2C_CNTRL, 2 + alen + len); + + //delay a while ??? + //--------------------------------------------------------------------- + //start write + txdata[PSOC_I2C_STATUS] = PSOC_I2C_START; /* the start bit*/ + if(bus) + txdata[PSOC_I2C_STATUS] |= PSOC_PMB_SEL;/* bus id */ + psoc_i2c_write(client, &txdata[PSOC_I2C_STATUS], PSOC_I2C_STATUS, 1); + + //delay a while + timeout = 40; //40*20==>800 ms + do { + psoc_i2c_read(client, &rxdata[PSOC_I2C_STATUS], PSOC_I2C_STATUS, 1); + + //check rxdata[5] error bit(1) and complete bit(0) ,TBD + if((rxdata[PSOC_I2C_STATUS] & 0x2) == 0x2) { + //printk("i2c bridge fail!!!\n"); + timeout = 0; + break; + } + if((rxdata[PSOC_I2C_STATUS] & PSOC_I2C_START) == 0) { + /* comand complete */ + psoc_i2c_read(client, &rxdata[PSOC_I2C_DATA+alen], PSOC_I2C_DATA+alen, len); + break; + } + + //delay + msleep(20); + } while(timeout--); + + if(timeout <= 0) { + return -1; + } + + //--------------------------------------------------------------------- + + for(index=0; index < len; index++) { + data[index] = rxdata[PSOC_I2C_DATA + alen + index]; + } + + return 0; +} + + +/* +CPLD report the PSU0 status +000 = PSU normal operation +100 = PSU fault +010 = PSU unpowered +111 = PSU not installed + +7 6 | 5 4 3 | 2 1 0 +---------------------- + | psu1 | psu0 +*/ +static char* psu_str[] = { + "normal", //000 + "NA", //001 + "unpowered", //010 + "NA", //011 + "fault", //100 + "NA", //101 + "NA", //110 + "not installed", //111 +}; + +static ssize_t show_psu_st(struct device *dev, struct device_attribute *da, + char *buf) +{ + u32 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 byte; + int shift = (attr->index == 0)?3:0; + + mutex_lock(&data->update_lock); + status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET, 1); + mutex_unlock(&data->update_lock); + + byte = (byte >> shift) & 0x7; + + status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); + + return strlen(buf); +} + +/*-----------------------------------------------------------------------*/ + +/* sysfs attributes for hwmon */ + +static ssize_t show_thermal(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index * 2 + THERMAL_OFFSET; + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, offset); + status = __swab16(status); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + (s8)(status>>8) * 1000 ); +} + + +static ssize_t show_pwm(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, offset); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + status); +} + +static ssize_t set_pwm(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + u8 pwm = simple_strtol(buf, NULL, 10); + if(pwm > 255) pwm = 255; + + if(data->diag) { + mutex_lock(&data->update_lock); + psoc_i2c_write(client, &pwm, offset, 1); + mutex_unlock(&data->update_lock); + } + + return count; +} + + +static ssize_t show_rpm(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, offset); + status = __swab16(status); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + status); +} +static ssize_t show_fan_type(struct device *dev, struct device_attribute *da, + char *buf) +{ + u8 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 index = attr->index; + int type = -1; + + mutex_lock(&data->update_lock); + status = psoc_read8(client, FAN_GPI_OFFSET); + mutex_unlock(&data->update_lock); + + if( (status & 1<update_lock); + status = psoc_i2c_read(client, (u8*)&temp, SWITCH_TMP_OFFSET, 2); + status = __swab16(status); + mutex_unlock(&data->update_lock); + + status = sprintf (buf, "%d\n", (s8)(temp>>8) * 1000 ); + + return strlen(buf); +} + +static ssize_t set_switch_tmp(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + + long temp = simple_strtol(buf, NULL, 10); + u16 temp2 = ( (temp/1000) <<8 ) & 0xFF00 ; + + //printk("set_switch_tmp temp=%d, temp2=0x%x (%x,%x)\n", temp, temp2, ( ( (temp/1000) <<8 ) & 0xFF00 ), (( (temp%1000) / 10 ) & 0xFF)); + + mutex_lock(&data->update_lock); + psoc_i2c_write(client, (u8*)&temp2, SWITCH_TMP_OFFSET, 2); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_diag(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 diag_flag = 0; + + mutex_lock(&data->update_lock); + status = psoc_i2c_read(client, (u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); + mutex_unlock(&data->update_lock); + + data->diag = (diag_flag & 0x80)?1:0; + status = sprintf (buf, "%d\n", data->diag); + + return strlen(buf); +} + +static ssize_t set_diag(struct device *dev, + struct device_attribute *devattr, + const char *buf, size_t count) +{ + //struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 value = 0; + u8 diag = simple_strtol(buf, NULL, 10); + + diag = diag?1:0; + data->diag = diag; + + mutex_lock(&data->update_lock); + psoc_i2c_read(client, (u8*)&value, DIAG_FLAG_OFFSET, 1); + if(diag) value |= (1<<7); + else value &= ~(1<<7); + psoc_i2c_write(client, (u8*)&value, DIAG_FLAG_OFFSET, 1); + mutex_unlock(&data->update_lock); + + return count; +} + +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + //struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + status = psoc_read16(client, VERSION_OFFSET); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "ver: %x.%x\n", (status & 0xFF00)>>8, (status & 0xFF) ); +} + + +static ssize_t show_fan_led(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 bit = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, FAN_LED_OFFSET); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", + (status & (1<index; + u8 led_state = 0; + + u8 v = simple_strtol(buf, NULL, 10); + + if(data->diag) { + mutex_lock(&data->update_lock); + led_state = psoc_read8(client, FAN_LED_OFFSET); + if(v) led_state |= (1<update_lock); + } + + return count; +} + +static ssize_t show_value8(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index; + + mutex_lock(&data->update_lock); + + status = psoc_read8(client, offset); + + mutex_unlock(&data->update_lock); + + return sprintf(buf, "0x%02X\n", status ); +} + +static long pmbus_reg2data_linear(int data, int linear16) +{ + s16 exponent; + s32 mantissa; + long val; + + if (linear16) { /* LINEAR16 */ + exponent = -9; + mantissa = (u16) data; + } else { /* LINEAR11 */ + exponent = ((s16)data) >> 11; + exponent = ((s16)( data & 0xF800) ) >> 11; + mantissa = ((s32)((data & 0x7ff) << 5)) >> 5; + } + + //printk("data=%d, m=%d, e=%d\n", data, exponent, mantissa); + val = mantissa; + + /* scale result to micro-units for power sensors */ + val = val * 1000L; + + if (exponent >= 0) + val <<= exponent; + else + val >>= -exponent; + + return val; +} + +static ssize_t show_psu(struct device *dev, struct device_attribute *da, + char *buf) +{ + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 reg = attr->index & 0xFF; + u8 len = ((attr->index & 0xFF00) >> 8); + u8 chip = (attr->index >> 16)? 0x59:0x58; + u8 bus = 1; + unsigned char value[2] = {0,0};; + + if (len == 2) + { + mutex_lock(&data->update_lock); + psoc_i2c_bridge_read(client, bus, chip, ®, 1, value, 2); + mutex_unlock(&data->update_lock); + + status = value[1]<<8 | value[0]; + //status1 = value[1]<<8 | value[0]; + + return sprintf(buf, "%ld\n", pmbus_reg2data_linear(status, (reg==PMBUS_READ_VOUT)?1:0) ); + } + else + { //len is not defined. + u8 tmpbuf[32]; + mutex_lock(&data->update_lock); + //length of block read + psoc_i2c_bridge_read(client, bus, chip, ®, 1, &len, 1); + //data included length + psoc_i2c_bridge_read(client, bus, chip, ®, 1, tmpbuf, len+1); + mutex_unlock(&data->update_lock); + + memcpy(buf, tmpbuf+1, len); + buf[len]='\n'; + + return len+1; + } +} + +static ssize_t show_psu_psoc(struct device *dev, struct device_attribute *da, + char *buf) +{ + u16 status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct psoc_data *data = i2c_get_clientdata(client); + u8 offset = attr->index + PSU_INFO_OFFSET; + + mutex_lock(&data->update_lock); + status = psoc_read16(client, offset); + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, strstr(attr->dev_attr.attr.name, "vout")? 1:0 )); +} + + +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_thermal, 0, 0); +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_thermal, 0, 1); +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_thermal, 0, 2); +static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_thermal, 0, 3); +static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_thermal, 0, 4); +static SENSOR_DEVICE_ATTR(thermal_psu1, S_IRUGO, show_thermal, 0, 5); +static SENSOR_DEVICE_ATTR(thermal_psu2, S_IRUGO, show_thermal, 0, 6); + +static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+0); +static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+1); +static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+2); +static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+3); +#if (FAN_NUM >= 5) +static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_OFFSET+4); +#endif +static SENSOR_DEVICE_ATTR(pwm_psu1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_PSU_OFFSET+0); +static SENSOR_DEVICE_ATTR(pwm_psu2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, PWM_PSU_OFFSET+1); + +static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu_st, 0, 0); +static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu_st, 0, 1); + +static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_rpm, 0, 0*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_rpm, 0, 1*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_rpm, 0, 2*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_rpm, 0, 3*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_rpm, 0, 4*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_rpm, 0, 5*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_rpm, 0, 6*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_rpm, 0, 7*2 + RPM_OFFSET); +#if (FAN_NUM >= 5) +static SENSOR_DEVICE_ATTR(fan9_input, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(fan10_input, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET); +#endif +static SENSOR_DEVICE_ATTR(rpm_psu1, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET); +static SENSOR_DEVICE_ATTR(rpm_psu2, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET); + +static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0); + +static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0); +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, 0, 0); + +static SENSOR_DEVICE_ATTR(fan_led_grn1, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 0); +static SENSOR_DEVICE_ATTR(fan_led_grn2, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 1); +static SENSOR_DEVICE_ATTR(fan_led_grn3, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 2); +static SENSOR_DEVICE_ATTR(fan_led_grn4, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 3); +static SENSOR_DEVICE_ATTR(fan_led_red1, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 4); +static SENSOR_DEVICE_ATTR(fan_led_red2, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 5); +static SENSOR_DEVICE_ATTR(fan_led_red3, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 6); +static SENSOR_DEVICE_ATTR(fan_led_red4, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 7); + +static SENSOR_DEVICE_ATTR(fan_gpi, S_IRUGO, show_value8, 0, FAN_GPI_OFFSET); +static SENSOR_DEVICE_ATTR(fan1_type, S_IRUGO, show_fan_type, 0, 0); +static SENSOR_DEVICE_ATTR(fan2_type, S_IRUGO, show_fan_type, 0, 1); +static SENSOR_DEVICE_ATTR(fan3_type, S_IRUGO, show_fan_type, 0, 2); +static SENSOR_DEVICE_ATTR(fan4_type, S_IRUGO, show_fan_type, 0, 3); + +static SENSOR_DEVICE_ATTR(psu1_vin, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_VIN); +static SENSOR_DEVICE_ATTR(psu1_vout, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_VOUT); +static SENSOR_DEVICE_ATTR(psu1_iin, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_IIN); +static SENSOR_DEVICE_ATTR(psu1_iout, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_IOUT); +static SENSOR_DEVICE_ATTR(psu1_pin, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_PIN); +static SENSOR_DEVICE_ATTR(psu1_pout, S_IRUGO, show_psu, 0, (0<<16) | (2<<8) | PMBUS_READ_POUT); + +static SENSOR_DEVICE_ATTR(psu1_vendor, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_ID); +static SENSOR_DEVICE_ATTR(psu1_model, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_MODEL); +static SENSOR_DEVICE_ATTR(psu1_version, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_REVISION); +static SENSOR_DEVICE_ATTR(psu1_date, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_DATE); +static SENSOR_DEVICE_ATTR(psu1_sn, S_IRUGO, show_psu, 0, (0<<16) | (0<<8) | PMBUS_MFR_SERIAL); + +static SENSOR_DEVICE_ATTR(psu2_vin, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_VIN); +static SENSOR_DEVICE_ATTR(psu2_vout, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_VOUT); +static SENSOR_DEVICE_ATTR(psu2_iin, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_IIN); +static SENSOR_DEVICE_ATTR(psu2_iout, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_IOUT); +static SENSOR_DEVICE_ATTR(psu2_pin, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_PIN); +static SENSOR_DEVICE_ATTR(psu2_pout, S_IRUGO, show_psu, 0, (1<<16) | (2<<8) | PMBUS_READ_POUT); + +static SENSOR_DEVICE_ATTR(psu2_vendor, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_ID); +static SENSOR_DEVICE_ATTR(psu2_model, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_MODEL); +static SENSOR_DEVICE_ATTR(psu2_version, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_REVISION); +static SENSOR_DEVICE_ATTR(psu2_date, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_DATE); +static SENSOR_DEVICE_ATTR(psu2_sn, S_IRUGO, show_psu, 0, (1<<16) | (0<<8) | PMBUS_MFR_SERIAL); + +static SENSOR_DEVICE_ATTR(psoc_psu1_vin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_vout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout)); +static SENSOR_DEVICE_ATTR(psoc_psu1_iin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_iout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout)); +static SENSOR_DEVICE_ATTR(psoc_psu1_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin)); +static SENSOR_DEVICE_ATTR(psoc_psu1_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pout)); + + +static SENSOR_DEVICE_ATTR(psoc_psu2_vin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_vout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout)); +static SENSOR_DEVICE_ATTR(psoc_psu2_iin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout)); +static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin)); +static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout)); + +static struct attribute *psoc_attributes[] = { + //thermal + &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, + &sensor_dev_attr_temp4_input.dev_attr.attr, + &sensor_dev_attr_temp5_input.dev_attr.attr, + + &sensor_dev_attr_thermal_psu1.dev_attr.attr, + &sensor_dev_attr_thermal_psu2.dev_attr.attr, + + + //pwm + &sensor_dev_attr_pwm1.dev_attr.attr, + &sensor_dev_attr_pwm2.dev_attr.attr, + &sensor_dev_attr_pwm3.dev_attr.attr, + &sensor_dev_attr_pwm4.dev_attr.attr, +#if (FAN_NUM >= 5) + //&sensor_dev_attr_pwm5.dev_attr.attr, +#endif + &sensor_dev_attr_pwm_psu1.dev_attr.attr, + &sensor_dev_attr_pwm_psu2.dev_attr.attr, + + //rpm + &sensor_dev_attr_fan1_input.dev_attr.attr, + &sensor_dev_attr_fan2_input.dev_attr.attr, + &sensor_dev_attr_fan3_input.dev_attr.attr, + &sensor_dev_attr_fan4_input.dev_attr.attr, + &sensor_dev_attr_fan5_input.dev_attr.attr, + &sensor_dev_attr_fan6_input.dev_attr.attr, + &sensor_dev_attr_fan7_input.dev_attr.attr, + &sensor_dev_attr_fan8_input.dev_attr.attr, +#if (FAN_NUM >= 5) + //&sensor_dev_attr_fan9_input.dev_attr.attr, + //&sensor_dev_attr_fan10_input.dev_attr.attr, +#endif + + &sensor_dev_attr_rpm_psu1.dev_attr.attr, + &sensor_dev_attr_rpm_psu2.dev_attr.attr, + + //switch temperature + &sensor_dev_attr_switch_tmp.dev_attr.attr, + + //diag flag + &sensor_dev_attr_diag.dev_attr.attr, + + //version + &sensor_dev_attr_version.dev_attr.attr, + + //fan led + &sensor_dev_attr_fan_led_grn1.dev_attr.attr, + &sensor_dev_attr_fan_led_grn2.dev_attr.attr, + &sensor_dev_attr_fan_led_grn3.dev_attr.attr, + &sensor_dev_attr_fan_led_grn4.dev_attr.attr, + &sensor_dev_attr_fan_led_red1.dev_attr.attr, + &sensor_dev_attr_fan_led_red2.dev_attr.attr, + &sensor_dev_attr_fan_led_red3.dev_attr.attr, + &sensor_dev_attr_fan_led_red4.dev_attr.attr, + + //fan GPI + &sensor_dev_attr_fan_gpi.dev_attr.attr, + + //fan type + &sensor_dev_attr_fan1_type.dev_attr.attr, + &sensor_dev_attr_fan2_type.dev_attr.attr, + &sensor_dev_attr_fan3_type.dev_attr.attr, + &sensor_dev_attr_fan4_type.dev_attr.attr, + + //psu + &sensor_dev_attr_psu1_vin.dev_attr.attr, + &sensor_dev_attr_psu1_vout.dev_attr.attr, + &sensor_dev_attr_psu1_iin.dev_attr.attr, + &sensor_dev_attr_psu1_iout.dev_attr.attr, + &sensor_dev_attr_psu1_pin.dev_attr.attr, + &sensor_dev_attr_psu1_pout.dev_attr.attr, + &sensor_dev_attr_psu2_vin.dev_attr.attr, + &sensor_dev_attr_psu2_vout.dev_attr.attr, + &sensor_dev_attr_psu2_iin.dev_attr.attr, + &sensor_dev_attr_psu2_iout.dev_attr.attr, + &sensor_dev_attr_psu2_pin.dev_attr.attr, + &sensor_dev_attr_psu2_pout.dev_attr.attr, + + &sensor_dev_attr_psu1_vendor.dev_attr.attr, + &sensor_dev_attr_psu1_model.dev_attr.attr, + &sensor_dev_attr_psu1_version.dev_attr.attr, + &sensor_dev_attr_psu1_date.dev_attr.attr, + &sensor_dev_attr_psu1_sn.dev_attr.attr, + &sensor_dev_attr_psu2_vendor.dev_attr.attr, + &sensor_dev_attr_psu2_model.dev_attr.attr, + &sensor_dev_attr_psu2_version.dev_attr.attr, + &sensor_dev_attr_psu2_date.dev_attr.attr, + &sensor_dev_attr_psu2_sn.dev_attr.attr, + + &sensor_dev_attr_psu0.dev_attr.attr, + &sensor_dev_attr_psu1.dev_attr.attr, + + //psu_psoc, new added on psoc 1.9 + &sensor_dev_attr_psoc_psu1_vin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_vout.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_iin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_iout.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_pin.dev_attr.attr, + &sensor_dev_attr_psoc_psu1_pout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_vin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_vout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_iin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_iout.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_pin.dev_attr.attr, + &sensor_dev_attr_psoc_psu2_pout.dev_attr.attr, + + NULL +}; + +static const struct attribute_group psoc_group = { + .attrs = psoc_attributes, +}; + +/*-----------------------------------------------------------------------*/ + +/* device probe and removal */ + +static int +psoc_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct psoc_data *data; + int status; + + printk("+%s\n", __func__); + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) + return -EIO; + + data = kzalloc(sizeof(struct psoc_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->diag = 0; + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &psoc_group); + if (status) + goto exit_free; + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: sensor '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &psoc_group); +exit_free: + i2c_set_clientdata(client, NULL); + kfree(data); + return status; +} + +static int psoc_remove(struct i2c_client *client) +{ + struct psoc_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &psoc_group); + i2c_set_clientdata(client, NULL); + kfree(data); + return 0; +} + +static const struct i2c_device_id psoc_ids[] = { + { "inv_psoc", 0, }, + { /* LIST END */ } +}; +MODULE_DEVICE_TABLE(i2c, psoc_ids); + +static struct i2c_driver psoc_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "inv_psoc", + }, + .probe = psoc_probe, + .remove = psoc_remove, + .id_table = psoc_ids, +}; + +/*-----------------------------------------------------------------------*/ + +/* module glue */ + +static int __init inv_psoc_init(void) +{ + return i2c_add_driver(&psoc_driver); +} + +static void __exit inv_psoc_exit(void) +{ + i2c_del_driver(&psoc_driver); +} + +MODULE_AUTHOR("eddie.lan "); +MODULE_DESCRIPTION("inv psoc driver"); +MODULE_LICENSE("GPL"); + +module_init(inv_psoc_init); +module_exit(inv_psoc_exit); diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/PKG.yml new file mode 100644 index 00000000..ea6da9a1 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d7032q28b ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/Makefile new file mode 100644 index 00000000..e8a03987 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-inventec-d7032q28b +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_inventec_d7032q28b onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-inventec-d7032q28b.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..c5c87ab8 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_inventec_d7032q28b onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.module b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.module new file mode 100644 index 00000000..a41675eb --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_inventec_d7032q28b diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile new file mode 100644 index 00000000..f3ba68e3 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_inventec_d7032q28b +AUTOMODULE := x86_64_inventec_d7032q28b +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..30860504 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_inventec_d7032q28b Autogeneration +# +############################################################################### +x86_64_inventec_d7032q28b_AUTO_DEFS := module/auto/x86_64_inventec_d7032q28b.yml +x86_64_inventec_d7032q28b_AUTO_DIRS := module/inc/x86_64_inventec_d7032q28b module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml new file mode 100644 index 00000000..b624ecde --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/auto/x86_64_inventec_d7032q28b.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_inventec_d7032q28b Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_INVENTEC_D7032Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_INVENTEC_D7032Q28B_CONFIG_PORTING_STDLIB +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_INVENTEC_D7032Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_INVENTEC_D7032Q28B_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_inventec_d7032q28b_config + + portingmacro: + X86_64_INVENTEC_D7032Q28B: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x new file mode 100644 index 00000000..47142477 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h new file mode 100644 index 00000000..232518dc --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_inventec_d7032q28b Configuration Header + * + * @addtogroup x86_64_inventec_d7032q28b-config + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_CONFIG_H__ +#define __x86_64_inventec_d7032q28b_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef x86_64_inventec_d7032q28b_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING +#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT +#define x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT +#define x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB +#define x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI +#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_inventec_d7032q28b_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_inventec_d7032q28b_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_inventec_d7032q28b_config_settings table. */ +extern x86_64_inventec_d7032q28b_config_settings_t x86_64_inventec_d7032q28b_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_inventec_d7032q28b_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_inventec_d7032q28b_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_inventec_d7032q28b_porting.h" + +#endif /* __x86_64_inventec_d7032q28b_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h new file mode 100644 index 00000000..727ff26a --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_inventec_d7032q28b Doxygen Header + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_DOX_H__ +#define __x86_64_inventec_d7032q28b_DOX_H__ + +/** + * @defgroup x86_64_inventec_d7032q28b x86_64_inventec_d7032q28b - x86_64_inventec_d7032q28b Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_inventec_d7032q28b-x86_64_inventec_d7032q28b Public Interface + * @defgroup x86_64_inventec_d7032q28b-config Compile Time Configuration + * @defgroup x86_64_inventec_d7032q28b-porting Porting Macros + * + * @} + * + */ + +#endif /* __x86_64_inventec_d7032q28b_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h new file mode 100644 index 00000000..55950ecd --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_inventec_d7032q28b Porting Macros. + * + * @addtogroup x86_64_inventec_d7032q28b-porting + * @{ + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_PORTING_H__ +#define __x86_64_inventec_d7032q28b_PORTING_H__ + + +/* */ +#if x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_inventec_d7032q28b_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_inventec_d7032q28b_MALLOC GLOBAL_MALLOC + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_MALLOC malloc + #else + #error The macro x86_64_inventec_d7032q28b_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_FREE + #if defined(GLOBAL_FREE) + #define x86_64_inventec_d7032q28b_FREE GLOBAL_FREE + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_FREE free + #else + #error The macro x86_64_inventec_d7032q28b_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_inventec_d7032q28b_MEMSET GLOBAL_MEMSET + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_MEMSET memset + #else + #error The macro x86_64_inventec_d7032q28b_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_inventec_d7032q28b_MEMCPY GLOBAL_MEMCPY + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_MEMCPY memcpy + #else + #error The macro x86_64_inventec_d7032q28b_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_inventec_d7032q28b_STRNCPY GLOBAL_STRNCPY + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_STRNCPY strncpy + #else + #error The macro x86_64_inventec_d7032q28b_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_inventec_d7032q28b_VSNPRINTF GLOBAL_VSNPRINTF + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_VSNPRINTF vsnprintf + #else + #error The macro x86_64_inventec_d7032q28b_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_inventec_d7032q28b_SNPRINTF GLOBAL_SNPRINTF + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_SNPRINTF snprintf + #else + #error The macro x86_64_inventec_d7032q28b_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_inventec_d7032q28b_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_inventec_d7032q28b_STRLEN GLOBAL_STRLEN + #elif x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB == 1 + #define x86_64_inventec_d7032q28b_STRLEN strlen + #else + #error The macro x86_64_inventec_d7032q28b_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __x86_64_inventec_d7032q28b_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..cec02d5e --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_inventec_d7032q28b_INCLUDES := -I $(THIS_DIR)inc +x86_64_inventec_d7032q28b_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_inventec_d7032q28b_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d7032q28b ucli:x86_64_inventec_d7032q28b + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..f82e1a89 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_inventec_d7032q28b_ucli.c + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..25addc7f --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/fani.c @@ -0,0 +1,329 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" + +#define PREFIX_PATH_ON_MAIN_BOARD "/sys/bus/i2c/devices/2-0066/" +#define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/" + +#define MAX_FAN_SPEED 18000 +#define MAX_PSU_FAN_SPEED 25500 + +#define PROJECT_NAME +#define LEN_FILE_NAME 80 + +#define FAN_RESERVED 0 +#define FAN_1_ON_MAIN_BOARD 1 +#define FAN_2_ON_MAIN_BOARD 2 +#define FAN_3_ON_MAIN_BOARD 3 +#define FAN_4_ON_MAIN_BOARD 4 +#define FAN_5_ON_MAIN_BOARD 5 +#define FAN_6_ON_MAIN_BOARD 6 +#define FAN_1_ON_PSU1 7 +#define FAN_1_ON_PSU2 8 + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \ + { #prj"fan"#id"_present", #prj"fan"#id"_fault", #prj"fan"#id"_front_speed_rpm", \ + #prj"fan"#id"_direction", #prj"fan_duty_cycle_percentage", #prj"fan"#id"_rear_speed_rpm" } + +#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) + +#define MAKE_FAN_PATH_ON_PSU(folder) \ + {"", #folder"/psu_fan1_fault", #folder"/psu_fan1_speed_rpm", \ + "", #folder"/psu_fan1_duty_cycle_percentage", "" } + +#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ + 0x0, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +/* Static fan information */ +onlp_fan_info_t linfo[] = { + { }, /* Not used */ + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(5), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(6), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1), +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value, ret; + + /* get fan present status + */ + ret = onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_B2F : ONLP_FAN_STATUS_F2B; + + + /* get front fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + ret = onlp_file_read_int(&value, "%s""fan_max_speed_rpm", FAN_BOARD_PATH); + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + info->percentage = (info->rpm * 100)/value; + + return ONLP_STATUS_OK; +} + + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } + } + + return 0; +} + + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan fault status + */ + if (psu_pmbus_info_get(pid, "psu_fan1_fault", &val) == ONLP_STATUS_OK) { + info->status |= (val > 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + /* get fan speed + */ + if (psu_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + } + + return ONLP_STATUS_OK; +} + + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int local_id; + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + *info = linfo[local_id]; + + switch (local_id) + { + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + rc = _onlp_fani_info_get_fan_on_psu(local_id, info); + break; + case FAN_1_ON_MAIN_BOARD: + case FAN_2_ON_MAIN_BOARD: + case FAN_3_ON_MAIN_BOARD: + case FAN_4_ON_MAIN_BOARD: + case FAN_5_ON_MAIN_BOARD: + case FAN_6_ON_MAIN_BOARD: + rc =_onlp_fani_info_get_fan(local_id, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_pmbus_info_set(PSU1_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_pmbus_info_set(PSU2_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + if (onlp_file_write_int(p, path, NULL) != 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..9cfd216b --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,253 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define prefix_path "/sys/class/leds/inventec_d7032q28b_led::" +#define filename "brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_DIAG, + LED_LOC, + LED_FAN, + LED_PSU1, + LED_PSU2 +}; + +enum led_light_mode { + LED_MODE_OFF = 0, + LED_MODE_GREEN, + LED_MODE_AMBER, + LED_MODE_RED, + LED_MODE_BLUE, + LED_MODE_GREEN_BLINK, + LED_MODE_AMBER_BLINK, + LED_MODE_RED_BLINK, + LED_MODE_BLUE_BLINK, + LED_MODE_AUTO, + LED_MODE_UNKNOWN +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED}, +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char last_path[][10] = /* must map with onlp_led_id */ +{ + "reserved", + "diag", + "loc", + "fan", + "psu1", + "psu2" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 1 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 2 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 4 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + /* + * Diag LED Off + */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int local_id; + char data[2] = {0}; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* get fullpath */ + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Set LED mode */ + if (onlp_file_read_string(fullpath, data, sizeof(data), 0) != 0) { + DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(local_id, atoi(data)); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int local_id; + char fullpath[50] = {0}; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename); + + if (onlp_file_write_int(onlp_to_driver_led_mode(local_id, mode), fullpath, NULL) != 0) + { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/make.mk b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..6176a32e --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_inventec_d7032q28b +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..9e4c5e06 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,189 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define PSU_NODE_MAX_PATH_LEN 64 + +int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len) +{ + if ((buffer == NULL) || (buf_size < 0)) { + return -1; + } + + return onlp_file_read((uint8_t*)buffer, buf_size, &data_len, "%s", filename); +} + +int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len) +{ + int ret; + + if (data_len >= buf_size) { + return -1; + } + + ret = onlp_file_read_binary(filename, buffer, buf_size-1, data_len); + + if (ret == 0) { + buffer[buf_size-1] = '\0'; + } + + return ret; +} + +#define I2C_PSU_MODEL_NAME_LEN 11 +#define I2C_PSU_FAN_DIR_LEN 3 +#include +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + char *node = NULL; + char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0}; + + /* Check AC model name */ + node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_model_name) : PSU2_AC_HWMON_NODE(psu_model_name); + + if (onlp_file_read_string(node, model_name, sizeof(model_name), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if(isspace(model_name[strlen(model_name)-1])) { + model_name[strlen(model_name)-1] = 0; + } + + if (strncmp(model_name, "YM-2651Y", 8) == 0) { + if (modelname) { + strncpy(modelname, model_name, 8); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + } + + if (strncmp(model_name, "YM-2651V", 8) == 0) { + if (modelname) { + strncpy(modelname, model_name, 8); + } + + node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_DC_48V_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_DC_48V_B2F; + } + } + + if (strncmp(model_name, "PSU-12V-750", 11) == 0) { + if (modelname) { + strncpy(modelname, model_name, 11); + } + + node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_fan_dir) : PSU2_AC_HWMON_NODE(psu_fan_dir); + if (onlp_file_read_string(node, fan_dir, sizeof(fan_dir), 0) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", 3) == 0) { + return PSU_TYPE_DC_12V_F2B; + } + + if (strncmp(fan_dir, "B2F", 3) == 0) { + return PSU_TYPE_DC_12V_B2F; + } + + if (strncmp(fan_dir, "NON", 3) == 0) { + return PSU_TYPE_DC_12V_FANLESS; + } + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + *value = 0; + + if (PSU1_ID == id) { + ret = onlp_file_read_int(value, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + ret = onlp_file_read_int(value, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (ret < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_int(value, path, NULL) != 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..2a50bf9e --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,82 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_inventec_d7032q28b_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 5 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/11-005b/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/10-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/11-0053/" +#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/10-0050/" + +#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node +#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node + +#define FAN_BOARD_PATH "/sys/devices/platform/fan/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-1/1-0057/eeprom" + +int onlp_file_read_binary(char *filename, char *buffer, int buf_size, int data_len); +int onlp_file_read_string(char *filename, char *buffer, int buf_size, int data_len); + +int psu_pmbus_info_get(int id, char *node, int *value); +int psu_pmbus_info_set(int id, char *node, int value); + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F, + PSU_TYPE_DC_48V_F2B, + PSU_TYPE_DC_48V_B2F, + PSU_TYPE_DC_12V_FANLESS, + PSU_TYPE_DC_12V_F2B, + PSU_TYPE_DC_12V_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) +#else + #define DEBUG_PRINT(format, ...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..8d12741e --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/psui.c @@ -0,0 +1,272 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + +#define PSU_NODE_MAX_INT_LEN 8 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + int ret = 0; + char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(node_path, "%s%s", PSU1_AC_HWMON_PREFIX, node); + } + else if (PSU2_ID == id) { + sprintf(node_path, "%s%s", PSU2_AC_HWMON_PREFIX, node); + } + + ret = onlp_file_read_int(value, node_path); + + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +static int +psu_ym2651_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char node_path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + sprintf(node_path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + ret = onlp_file_read_int(value, node_path); + + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +#include +#define DC12V_750_REG_TO_CURRENT(low, high) (((low << 4 | high >> 4) * 20 * 1000) / 754) +#define DC12V_750_REG_TO_VOLTAGE(low, high) ((low << 4 | high >> 4) * 25) + +static int +psu_dc12v_750_info_get(onlp_psu_info_t* info) +{ + int pid = ONLP_OID_ID_GET(info->hdr.id); + int bus = (PSU1_ID == pid) ? 11 : 10; + int iout_low, iout_high; + int vout_low, vout_high; + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_DC12; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Get current + */ + iout_low = onlp_i2c_readb(bus, 0x6f, 0x0, ONLP_I2C_F_FORCE); + iout_high = onlp_i2c_readb(bus, 0x6f, 0x1, ONLP_I2C_F_FORCE); + + if ((iout_low >= 0) && (iout_high >= 0)) { + info->miout = DC12V_750_REG_TO_CURRENT(iout_low, iout_high); + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + /* Get voltage + */ + vout_low = onlp_i2c_readb(bus, 0x6f, 0x2, ONLP_I2C_F_FORCE); + vout_high = onlp_i2c_readb(bus, 0x6f, 0x3, ONLP_I2C_F_FORCE); + + if ((vout_low >= 0) && (vout_high >= 0)) { + info->mvout = DC12V_750_REG_TO_VOLTAGE(vout_low, vout_high); + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + /* Get power based on current and voltage + */ + if ((info->caps & ONLP_PSU_CAPS_IOUT) && (info->caps & ONLP_PSU_CAPS_VOUT)) { + info->mpout = (info->miout * info->mvout) / 1000; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int val = 0; + int ret = ONLP_STATUS_OK; + int index = ONLP_OID_ID_GET(id); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + info->caps = ONLP_PSU_CAPS_AC; + ret = psu_ym2651_info_get(info); + break; + case PSU_TYPE_DC_48V_F2B: + case PSU_TYPE_DC_48V_B2F: + info->caps = ONLP_PSU_CAPS_DC48; + ret = psu_ym2651_info_get(info); + break; + case PSU_TYPE_DC_12V_F2B: + case PSU_TYPE_DC_12V_B2F: + case PSU_TYPE_DC_12V_FANLESS: + ret = psu_dc12v_750_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..0b568114 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,223 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +#include /* For O_RDWR && open */ +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define MAX_SFP_PATH 64 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +#define MUX_START_INDEX 18 +#define NUM_OF_SFP_PORT 32 +static const int sfp_mux_index[NUM_OF_SFP_PORT] = { + 4, 5, 6, 7, 9, 8, 11, 10, + 0, 1, 2, 3, 12, 13, 14, 15, +16, 17, 18, 19, 28, 29, 30, 31, +20, 21, 22, 23, 24, 25, 26, 27 +}; + +#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]+MUX_START_INDEX) + +static int +sfp_node_read_int(char *node_path, int *value, int data_len) +{ + int ret = 0; + *value = 0; + + ret = onlp_file_read_int(value, node_path); + + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", node_path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +static char* +sfp_get_port_path(int port, char *node_name) +{ + sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-0050/%s", + FRONT_PORT_TO_MUX_INDEX(port), + node_name); + + return sfp_node_path; +} + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 32} + */ + int p; + AIM_BITMAP_CLR_ALL(bmap); + + for(p = 0; p < NUM_OF_SFP_PORT; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + char* path = sfp_get_port_path(port, "sfp_is_present"); + + if (sfp_node_read_int(path, &present, 0) != 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[4]; + char* path; + FILE* fp; + + path = sfp_get_port_path(0, "sfp_is_present_all"); + fp = fopen(path, "r"); + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + int count = fscanf(fp, "%x %x %x %x", + bytes+0, + bytes+1, + bytes+2, + bytes+3 + ); + fclose(fp); + if(count != AIM_ARRAYSIZE(bytes)) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file."); + return ONLP_STATUS_E_INTERNAL; + } + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint32_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + char* path = sfp_get_port_path(port, "sfp_eeprom"); + int len = 0; + + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + memset(data, 0, 256); + + if (onlp_file_read((uint8_t*)data, 256, &len, path) < 0) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) +{ + int bus = FRONT_PORT_TO_MUX_INDEX(port); + return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sysi.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..d3a4b629 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,295 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "x86_64_inventec_d7032q28b_int.h" +#include "x86_64_inventec_d7032q28b_log.h" + +#include "platform_lib.h" + +#define NUM_OF_THERMAL_ON_MAIN_BROAD CHASSIS_THERMAL_COUNT +#define NUM_OF_FAN_ON_MAIN_BROAD CHASSIS_FAN_COUNT +#define NUM_OF_PSU_ON_MAIN_BROAD 2 +#define NUM_OF_LED_ON_MAIN_BROAD 5 + +#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/" +#define NUM_OF_CPLD 3 +static char arr_cplddev_name[NUM_OF_CPLD][10] = +{ + "4-0060", + "5-0062", + "6-0064" +}; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-inventec-d7032q28b-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int i, v[NUM_OF_CPLD]={0}; + for (i=0; i < NUM_OF_CPLD; i++) { + v[i] = 0; + if(onlp_file_read_int(v+i, "%s%s/version", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + } + pi->cpld_versions = aim_fstrdup("%d.%d.%d", v[0], v[1], v[2]); + return 0; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ + aim_free(pi->cpld_versions); +} + + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 4 Thermal sensors on the chassis */ + for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 4 Fans on the chassis */ + for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +typedef struct fan_ctrl_policy { + int duty_cycle; + int temp_down_adjust; /* The boundary temperature to down adjust fan speed */ + int temp_up_adjust; /* The boundary temperature to up adjust fan speed */ +} fan_ctrl_policy_t; + +fan_ctrl_policy_t fan_ctrl_policy_f2b[] = { +{32, 0, 174000}, +{38, 170000, 182000}, +{50, 178000, 190000}, +{63, 186000, 0} +}; + +fan_ctrl_policy_t fan_ctrl_policy_b2f[] = { +{32, 0, 140000}, +{38, 135000, 150000}, +{50, 145000, 160000}, +{69, 155000, 0} +}; + +#define FAN_DUTY_CYCLE_MAX 100 +#define FAN_SPEED_CTRL_PATH "/sys/bus/i2c/devices/2-0066/fan_duty_cycle_percentage" + +/* + * For AC power Front to Back : + * * If any fan fail, please fan speed register to 15 + * * The max value of Fan speed register is 9 + * [LM75(48) + LM75(49) + LM75(4A)] > 174 => set Fan speed value from 4 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] > 182 => set Fan speed value from 5 to 7 + * [LM75(48) + LM75(49) + LM75(4A)] > 190 => set Fan speed value from 7 to 9 + * + * [LM75(48) + LM75(49) + LM75(4A)] < 170 => set Fan speed value from 5 to 4 + * [LM75(48) + LM75(49) + LM75(4A)] < 178 => set Fan speed value from 7 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] < 186 => set Fan speed value from 9 to 7 + * + * + * For AC power Back to Front : + * * If any fan fail, please fan speed register to 15 + * * The max value of Fan speed register is 10 + * [LM75(48) + LM75(49) + LM75(4A)] > 140 => set Fan speed value from 4 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] > 150 => set Fan speed value from 5 to 7 + * [LM75(48) + LM75(49) + LM75(4A)] > 160 => set Fan speed value from 7 to 10 + * + * [LM75(48) + LM75(49) + LM75(4A)] < 135 => set Fan speed value from 5 to 4 + * [LM75(48) + LM75(49) + LM75(4A)] < 145 => set Fan speed value from 7 to 5 + * [LM75(48) + LM75(49) + LM75(4A)] < 155 => set Fan speed value from 10 to 7 + */ +int +onlp_sysi_platform_manage_fans(void) +{ + int i = 0, arr_size, temp; + fan_ctrl_policy_t *policy; + int cur_duty_cycle, new_duty_cycle; + onlp_thermal_info_t thermal_1, thermal_2, thermal_3; + + int fd, len; + char buf[10] = {0}; + + /* Get each fan status + */ + for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) + { + onlp_fan_info_t fan_info; + + if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); + return ONLP_STATUS_E_INTERNAL; + } + + /* Decision 1: Set fan as full speed if any fan is failed. + */ + if (fan_info.status & ONLP_FAN_STATUS_FAILED) { + AIM_LOG_ERROR("Fan(%d) is not working, set the other fans as full speed\r\n", i); + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + } + + /* Decision 1.1: Set fan as full speed if any fan is not present. + */ + if (!(fan_info.status & ONLP_FAN_STATUS_PRESENT)) { + AIM_LOG_ERROR("Fan(%d) is not present, set the other fans as full speed\r\n", i); + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + } + + /* Get fan direction (Only get the first one since all fan direction are the same) + */ + if (i == 1) { + if (fan_info.status & ONLP_FAN_STATUS_F2B) { + policy = fan_ctrl_policy_f2b; + arr_size = AIM_ARRAYSIZE(fan_ctrl_policy_f2b); + } + else { + policy = fan_ctrl_policy_b2f; + arr_size = AIM_ARRAYSIZE(fan_ctrl_policy_b2f); + } + } + } + + /* Get current fan speed + */ + fd = open(FAN_SPEED_CTRL_PATH, O_RDONLY); + if (fd == -1){ + AIM_LOG_ERROR("Unable to open fan speed control node (%s)", FAN_SPEED_CTRL_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + AIM_LOG_ERROR("Unable to read fan speed from (%s)", FAN_SPEED_CTRL_PATH); + return ONLP_STATUS_E_INTERNAL; + } + cur_duty_cycle = atoi(buf); + + + /* Decision 2: If no matched fan speed is found from the policy, + * use FAN_DUTY_CYCLE_MIN as default speed + */ + for (i = 0; i < arr_size; i++) { + if (policy[i].duty_cycle != cur_duty_cycle) + continue; + + break; + } + + if (i == arr_size) { + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), policy[0].duty_cycle); + } + + /* Get current temperature + */ + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_1) != ONLP_STATUS_OK || + onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(3), &thermal_2) != ONLP_STATUS_OK || + onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(4), &thermal_3) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read thermal status"); + return ONLP_STATUS_E_INTERNAL; + } + temp = thermal_1.mcelsius + thermal_2.mcelsius + thermal_3.mcelsius; + + + /* Decision 3: Decide new fan speed depend on fan direction/current fan speed/temperature + */ + new_duty_cycle = cur_duty_cycle; + + if ((temp >= policy[i].temp_up_adjust) && (i != (arr_size-1))) { + new_duty_cycle = policy[i+1].duty_cycle; + } + else if ((temp <= policy[i].temp_down_adjust) && (i != 0)) { + new_duty_cycle = policy[i-1].duty_cycle; + } + + if (new_duty_cycle == cur_duty_cycle) { + /* Duty cycle does not change, just return */ + return ONLP_STATUS_OK; + } + + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty_cycle); +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/thermali.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..94f5353c --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* devfiles__[] = /* must map with onlp_thermal_id */ +{ + "reserved", + NULL, /* CPU_CORE files */ + "/sys/bus/i2c/devices/3-0048*temp1_input", + "/sys/bus/i2c/devices/3-0049*temp1_input", + "/sys/bus/i2c/devices/3-004a*temp1_input", + "/sys/bus/i2c/devices/3-004b*temp1_input", + "/sys/bus/i2c/devices/11-005b*psu_temp1_input", + "/sys/bus/i2c/devices/10-0058*psu_temp1_input", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "Chassis Thermal Sensor 1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "Chassis Thermal Sensor 2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int local_id; + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + if(local_id == THERMAL_CPU_CORE) { + int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + return rv; + } + + return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); +} diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c new file mode 100644 index 00000000..d75ca1b8 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(_x) +x86_64_inventec_d7032q28b_config_settings_t x86_64_inventec_d7032q28b_config_settings[] = +{ +#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_PORTING_STDLIB(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE(x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ x86_64_inventec_d7032q28b_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d7032q28b_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_inventec_d7032q28b_config_STRINGIFY_VALUE +#undef __x86_64_inventec_d7032q28b_config_STRINGIFY_NAME + +const char* +x86_64_inventec_d7032q28b_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_inventec_d7032q28b_config_settings[i].name; i++) { + if(strcmp(x86_64_inventec_d7032q28b_config_settings[i].name, setting)) { + return x86_64_inventec_d7032q28b_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_inventec_d7032q28b_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_inventec_d7032q28b_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_inventec_d7032q28b_config_settings[i].name, x86_64_inventec_d7032q28b_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_enums.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_enums.c new file mode 100644 index 00000000..28b49fa2 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_int.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_int.h new file mode 100644 index 00000000..f112cb20 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_inventec_d7032q28b Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_INT_H__ +#define __x86_64_inventec_d7032q28b_INT_H__ + +#include + + +#endif /* __x86_64_inventec_d7032q28b_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c new file mode 100644 index 00000000..6ab416f3 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_inventec_d7032q28b_log.h" +/* + * x86_64_inventec_d7032q28b log struct. + */ +AIM_LOG_STRUCT_DEFINE( + x86_64_inventec_d7032q28b_CONFIG_LOG_OPTIONS_DEFAULT, + x86_64_inventec_d7032q28b_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + x86_64_inventec_d7032q28b_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.h b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.h new file mode 100644 index 00000000..8b66dc39 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_inventec_d7032q28b_LOG_H__ +#define __x86_64_inventec_d7032q28b_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_inventec_d7032q28b +#include + +#endif /* __x86_64_inventec_d7032q28b_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_module.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_module.c new file mode 100644 index 00000000..fe89a47a --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_inventec_d7032q28b_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_inventec_d7032q28b_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_inventec_d7032q28b_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_ucli.c b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_ucli.c new file mode 100644 index 00000000..4d15b02c --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/onlp/builds/src/module/src/x86_64_inventec_d7032q28b_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_inventec_d7032q28b_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_inventec_d7032q28b_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d7032q28b) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_inventec_d7032q28b_ucli_module__ = + { + "x86_64_inventec_d7032q28b_ucli", + NULL, + x86_64_inventec_d7032q28b_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_inventec_d7032q28b_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_inventec_d7032q28b_ucli_module__); + n = ucli_node_create("x86_64_inventec_d7032q28b", NULL, &x86_64_inventec_d7032q28b_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d7032q28b")); + return n; +} + +#else +void* +x86_64_inventec_d7032q28b_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/PKG.yml new file mode 100644 index 00000000..ac682e0b --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d7032q28b REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml new file mode 100644 index 00000000..19bcea27 --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for d7032q28b +# +###################################################################### + +x86-64-inventec-d7032q28b-r0: + + grub: + + serial: >- + --port=0x2f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + console=ttyS1,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py new file mode 100644 index 00000000..181b07cc --- /dev/null +++ b/packages/platforms/inventec/x86-64/x86-64-inventec-d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py @@ -0,0 +1,15 @@ +from onl.platform.base import * +from onl.platform.inventec import * + +class OnlPlatform_x86_64_inventec_d7032q28b_r0(OnlPlatformInventec, + OnlPlatformPortConfig_32x100): + PLATFORM='x86-64-inventec-d7032q28b-r0' + MODEL="X86-D7032Q28B" + SYS_OBJECT_ID=".1.32" + + def baseconfig(self): + os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko gpiobase=0") + self.insmod('inv_platform') + self.insmod('inv_psoc') + self.insmod('inv_cpld') + return True diff --git a/packages/platforms/mellanox/vendor-config/src/python/mellanox/__init__.py b/packages/platforms/mellanox/vendor-config/src/python/mellanox/__init__.py index 56cd4d71..db5e2d06 100644 --- a/packages/platforms/mellanox/vendor-config/src/python/mellanox/__init__.py +++ b/packages/platforms/mellanox/vendor-config/src/python/mellanox/__init__.py @@ -14,6 +14,7 @@ class OnlPlatformMellanox(OnlPlatformBase): print "Caching ONIE System EEPROM..." onie = self.onie_syseeprom_get() mc = self.onie_machine_get() + # XXX roth -- deprecated if 'onie_version' in mc: onie['0x29'] = mc['onie_version'] self.onie_syseeprom_set(onie) diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/.gitignore new file mode 100755 index 00000000..60f9dd9d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/.gitignore @@ -0,0 +1,2 @@ +*x86*64*quanta*ly7*rglbmc.mk +onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/PKG.yml new file mode 100755 index 00000000..7f33b579 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly7-rglbmc KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/.gitignore new file mode 100755 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/Makefile new file mode 100755 index 00000000..aec5bb59 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := quanta +BASENAME := x86-64-quanta-ly7-rglbmc +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/quanta_platform_ly7.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/quanta_platform_ly7.c new file mode 100755 index 00000000..2efdfab3 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/modules/builds/quanta_platform_ly7.c @@ -0,0 +1,403 @@ +/* + * Quanta LY7 platform driver + * + * + * Copyright (C) 2017 Quanta Computer inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)) +#include +#else +#include +#endif + +#define MUX_INFO(bus, deselect) \ + {.adap_id = bus, .deselect_on_exit = deselect} + +static struct pca954x_platform_mode pca9548sfp1_modes[] = { + MUX_INFO(0x20, 1), + MUX_INFO(0x21, 1), + MUX_INFO(0x22, 1), + MUX_INFO(0x23, 1), + MUX_INFO(0x24, 1), + MUX_INFO(0x25, 1), + MUX_INFO(0x26, 1), + MUX_INFO(0x27, 1), +}; + +static struct pca954x_platform_data pca9548sfp1_data = { + .modes = pca9548sfp1_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp2_modes[] = { + MUX_INFO(0x28, 1), + MUX_INFO(0x29, 1), + MUX_INFO(0x2a, 1), + MUX_INFO(0x2b, 1), + MUX_INFO(0x2c, 1), + MUX_INFO(0x2d, 1), + MUX_INFO(0x2e, 1), + MUX_INFO(0x2f, 1), +}; + +static struct pca954x_platform_data pca9548sfp2_data = { + .modes = pca9548sfp2_modes, + .num_modes = 8, +}; +static struct pca954x_platform_mode pca9548sfp3_modes[] = { + MUX_INFO(0x30, 1), + MUX_INFO(0x31, 1), + MUX_INFO(0x32, 1), + MUX_INFO(0x33, 1), + MUX_INFO(0x34, 1), + MUX_INFO(0x35, 1), + MUX_INFO(0x36, 1), + MUX_INFO(0x37, 1), +}; + +static struct pca954x_platform_data pca9548sfp3_data = { + .modes = pca9548sfp3_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp4_modes[] = { + MUX_INFO(0x38, 1), + MUX_INFO(0x39, 1), + MUX_INFO(0x3a, 1), + MUX_INFO(0x3b, 1), + MUX_INFO(0x3c, 1), + MUX_INFO(0x3d, 1), + MUX_INFO(0x3e, 1), + MUX_INFO(0x3f, 1), +}; + +static struct pca954x_platform_data pca9548sfp4_data = { + .modes = pca9548sfp4_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp5_modes[] = { + MUX_INFO(0x40, 1), + MUX_INFO(0x41, 1), + MUX_INFO(0x42, 1), + MUX_INFO(0x43, 1), + MUX_INFO(0x44, 1), + MUX_INFO(0x45, 1), + MUX_INFO(0x46, 1), + MUX_INFO(0x47, 1), +}; + +static struct pca954x_platform_data pca9548sfp5_data = { + .modes = pca9548sfp5_modes, + .num_modes = 8, +}; + +static struct pca954x_platform_mode pca9548sfp6_modes[] = { + MUX_INFO(0x48, 1), + MUX_INFO(0x49, 1), + MUX_INFO(0x4a, 1), + MUX_INFO(0x4b, 1), + MUX_INFO(0x4c, 1), + MUX_INFO(0x4d, 1), + MUX_INFO(0x4e, 1), + MUX_INFO(0x4f, 1), +}; + +static struct pca954x_platform_data pca9548sfp6_data = { + .modes = pca9548sfp6_modes, + .num_modes = 8, +}; + +//ZQSFP +static struct pca954x_platform_mode pca9548sfp7_modes[] = { + MUX_INFO(0x50, 1), + MUX_INFO(0x51, 1), + MUX_INFO(0x52, 1), + MUX_INFO(0x53, 1), + MUX_INFO(0x54, 1), + MUX_INFO(0x55, 1), + MUX_INFO(0x56, 1), + MUX_INFO(0x57, 1), +}; + +static struct pca954x_platform_data pca9548sfp7_data = { + .modes = pca9548sfp7_modes, + .num_modes = 8, +}; + +// end port + +static struct pca954x_platform_mode pca9546_modes[] = { + MUX_INFO(0x10, 1), + MUX_INFO(0x11, 1), + MUX_INFO(0x12, 1), + MUX_INFO(0x13, 1), +}; + +static struct pca954x_platform_data pca9546_data = { + .modes = pca9546_modes, + .num_modes = 4, +}; + +static struct pca954x_platform_mode pca9548_modes[] = { + MUX_INFO(0x14, 1), + MUX_INFO(0x15, 1), + MUX_INFO(0x16, 1), + MUX_INFO(0x17, 1), + MUX_INFO(0x18, 1), + MUX_INFO(0x19, 1), + MUX_INFO(0x1a, 1), + MUX_INFO(0x1b, 1), +}; + +static struct pca954x_platform_data pca9548_data = { + .modes = pca9548_modes, + .num_modes = 8, +}; + +/* CPU Board i2c device */ +static struct pca954x_platform_mode pca9546_cpu_modes[] = { + MUX_INFO(0x02, 1), + MUX_INFO(0x03, 1), + MUX_INFO(0x04, 1), + MUX_INFO(0x05, 1), +}; + +static struct pca954x_platform_data pca9546_cpu_data = { + .modes = pca9546_cpu_modes, + .num_modes = 4, +}; +//MB Board Data +static struct pca953x_platform_data pca9555_1_data = { + .gpio_base = 0x10, +}; +//QSFP28 49-52 IO Expander +static struct pca953x_platform_data pca9698_2_data = { + .gpio_base = 0x20, +}; +//CPU Board pca9555 +static struct pca953x_platform_data pca9555_CPU_data = { + .gpio_base = 0x40, +}; +static struct i2c_board_info ly7_i2c_devices[] = { + { + I2C_BOARD_INFO("pca9546", 0x72), // 0 + .platform_data = &pca9546_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x77), // 1 + .platform_data = &pca9548_data, + }, + { + I2C_BOARD_INFO("24c02", 0x54), // 2 eeprom + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 3 0x77 ch0 + .platform_data = &pca9548sfp1_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 4 0x77 ch1 + .platform_data = &pca9548sfp2_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 5 0x77 ch2 + .platform_data = &pca9548sfp3_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 6 0x77 ch3 + .platform_data = &pca9548sfp4_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 7 0x77 ch4 + .platform_data = &pca9548sfp5_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 8 0x77 ch5 + .platform_data = &pca9548sfp6_data, + }, + { + I2C_BOARD_INFO("pca9548", 0x73), // 9 0x77 ch6 + .platform_data = &pca9548sfp7_data, + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 10 0x72 ch0 CPLD1_:SFP28 1~16 + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 11 0x72 ch1 CPLD2_:SFP28 17~32 + }, + { + I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 12 0x72 ch2 CPLD_3:SFP28 33~48 + }, + { + I2C_BOARD_INFO("pca9555", 0x23), // 13 0x72 ch3 MB Board Data + .platform_data = &pca9555_1_data, + }, + { + I2C_BOARD_INFO("pca9698", 0x21), // 14 0x72 ch3 QSFP:49~52 + .platform_data = &pca9698_2_data, + }, + { + I2C_BOARD_INFO("24c02", 0x50), // 15 0x50 SFP28, QSFP EEPROM + }, + { + I2C_BOARD_INFO("pca9546", 0x71), // 16 + .platform_data = &pca9546_cpu_data, + }, + { + I2C_BOARD_INFO("pca9555", 0x20), // 17 0x71 ch0 CPU Board Data + .platform_data = &pca9555_CPU_data, + }, +}; + +static struct platform_driver ly7_platform_driver = { + .driver = { + .name = "qci-ly7", + .owner = THIS_MODULE, + }, +}; + +static struct platform_device *ly7_device; + +static int __init ly7_platform_init(void) +{ + struct i2c_client *client; + struct i2c_adapter *adapter; + int ret, i; + + ret = platform_driver_register(&ly7_platform_driver); + if (ret < 0) + return ret; + + /* Register platform stuff */ + ly7_device = platform_device_alloc("qci-ly7", -1); + if (!ly7_device) { + ret = -ENOMEM; + goto fail_platform_driver; + } + + ret = platform_device_add(ly7_device); + if (ret) + goto fail_platform_device; + + adapter = i2c_get_adapter(0); + client = i2c_new_device(adapter, &ly7_i2c_devices[0]); // pca9546 + client = i2c_new_device(adapter, &ly7_i2c_devices[1]); // pca9548 + client = i2c_new_device(adapter, &ly7_i2c_devices[16]); // pca9546cpu + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x02); + client = i2c_new_device(adapter, &ly7_i2c_devices[17]); // CPU Board Data + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x10); + client = i2c_new_device(adapter, &ly7_i2c_devices[10]); // CPLD_1 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x11); + client = i2c_new_device(adapter, &ly7_i2c_devices[11]); // CPLD_2 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x12); + client = i2c_new_device(adapter, &ly7_i2c_devices[12]); // CPLD_3 + client = i2c_new_device(adapter, &ly7_i2c_devices[2]); // MB_BOARDINFO_EEPROM + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x13); + client = i2c_new_device(adapter, &ly7_i2c_devices[13]); // MB Board Data + client = i2c_new_device(adapter, &ly7_i2c_devices[14]); // QSFP:49~52 + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x14); + client = i2c_new_device(adapter, &ly7_i2c_devices[3]); // pca9548_1 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x15); + client = i2c_new_device(adapter, &ly7_i2c_devices[4]); // pca9548_2 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x16); + client = i2c_new_device(adapter, &ly7_i2c_devices[5]); // pca9548_3 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x17); + client = i2c_new_device(adapter, &ly7_i2c_devices[6]); // pca9548_4 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x18); + client = i2c_new_device(adapter, &ly7_i2c_devices[7]); // pca9548_5 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x19); + client = i2c_new_device(adapter, &ly7_i2c_devices[8]); // pca9548_6 SFP + i2c_put_adapter(adapter); + + adapter = i2c_get_adapter(0x1a); + client = i2c_new_device(adapter, &ly7_i2c_devices[9]); // pca9548_7 QSFP + i2c_put_adapter(adapter); + + for(i = 32; i < 84; i ++){ // SFP28 1~48 & QSFP 49~52 EEPROM + adapter = i2c_get_adapter(i); + client = i2c_new_device(adapter, &ly7_i2c_devices[15]); + i2c_put_adapter(adapter); + } + + return 0; + +fail_platform_device: + platform_device_put(ly7_device); + +fail_platform_driver: + platform_driver_unregister(&ly7_platform_driver); + return ret; +} + +static void __exit ly7_platform_exit(void) +{ + platform_device_unregister(ly7_device); + platform_driver_unregister(&ly7_platform_driver); +} + +module_init(ly7_platform_init); +module_exit(ly7_platform_exit); + + +MODULE_AUTHOR("Jonathan Tsai "); +MODULE_VERSION("1.0"); +MODULE_DESCRIPTION("Quanta LY7 Platform Driver"); +MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/PKG.yml new file mode 100755 index 00000000..76467669 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-quanta-ly7-rglbmc ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/Makefile new file mode 100755 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/lib/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/lib/Makefile new file mode 100755 index 00000000..3cd4efa5 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-quanta-ly7-rglbmc +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_quanta_ly7_rglbmc quanta_sys_eeprom onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-quanta-ly7-rglbmc.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/onlpdump/Makefile new file mode 100755 index 00000000..f50697a1 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/onlpdump/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_quanta_ly7_rglbmc quanta_sys_eeprom onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.module b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.module new file mode 100755 index 00000000..f225e551 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/.module @@ -0,0 +1 @@ +name: x86_64_quanta_ly7_rglbmc diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/Makefile new file mode 100755 index 00000000..d36660de --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_quanta_ly7_rglbmc +AUTOMODULE := x86_64_quanta_ly7_rglbmc +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/make.mk new file mode 100755 index 00000000..3c19c01d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_quanta_ly7_rglbmc Autogeneration +# +############################################################################### +x86_64_quanta_ly7_rglbmc_AUTO_DEFS := module/auto/x86_64_quanta_ly7_rglbmc.yml +x86_64_quanta_ly7_rglbmc_AUTO_DIRS := module/inc/x86_64_quanta_ly7_rglbmc module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml new file mode 100755 index 00000000..5d056542 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml @@ -0,0 +1,134 @@ +############################################################################### +# +# x86_64_quanta_ly7_rglbmc Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: + doc: "RPM Threshold at which the fan is considered to have failed." + default: 3000 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX: + doc: "Maximum system front-to-back fan speed." + default: 18000 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX: + doc: "Maximum system back-to-front fan speed." + default: 18000 +- X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS: + doc: "Time to hold Phy GPIO in reset, in ms" + default: 100 + +definitions: + cdefs: + X86_64_QUANTA_LY7_RGLBMC_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_quanta_ly7_rglbmc_config + + enum: &enums + + fan_id: + members: + - FAN1 : 1 + - FAN2 : 2 + - FAN3 : 3 + - FAN4 : 4 + - FAN5 : 5 + - FAN6 : 6 + - FAN7 : 7 + - FAN8 : 8 + - FAN9 : 9 + - FAN10 : 10 + + fan_oid: + members: + - FAN1 : ONLP_FAN_ID_CREATE(1) + - FAN2 : ONLP_FAN_ID_CREATE(2) + - FAN3 : ONLP_FAN_ID_CREATE(3) + - FAN4 : ONLP_FAN_ID_CREATE(4) + - FAN5 : ONLP_FAN_ID_CREATE(5) + - FAN6 : ONLP_FAN_ID_CREATE(6) + - FAN7 : ONLP_FAN_ID_CREATE(7) + - FAN8 : ONLP_FAN_ID_CREATE(8) + - FAN9 : ONLP_FAN_ID_CREATE(9) + - FAN10 : ONLP_FAN_ID_CREATE(10) + + psu_id: + members: + - PSU1 : 1 + - PSU2 : 2 + + psu_oid: + members: + - PSU1 : ONLP_PSU_ID_CREATE(1) + - PSU2 : ONLP_PSU_ID_CREATE(2) + + thermal_id: + members: + - THERMAL1 : 1 + - THERMAL2 : 2 + - THERMAL3 : 3 + - THERMAL4 : 4 + - THERMAL5 : 5 + - THERMAL6 : 6 + - THERMAL7 : 7 + - THERMAL8 : 8 + - THERMAL9 : 9 + - THERMAL10 : 10 + - THERMAL11 : 11 + - THERMAL12 : 12 + - THERMAL13 : 13 + - THERMAL14 : 14 + - THERMAL15 : 15 + - THERMAL16 : 16 + + + thermal_oid: + members: + - THERMAL1 : ONLP_THERMAL_ID_CREATE(1) + - THERMAL2 : ONLP_THERMAL_ID_CREATE(2) + - THERMAL3 : ONLP_THERMAL_ID_CREATE(3) + - THERMAL4 : ONLP_THERMAL_ID_CREATE(4) + - THERMAL5 : ONLP_THERMAL_ID_CREATE(5) + - THERMAL6 : ONLP_THERMAL_ID_CREATE(6) + - THERMAL7 : ONLP_THERMAL_ID_CREATE(7) + - THERMAL8 : ONLP_THERMAL_ID_CREATE(8) + - THERMAL9 : ONLP_THERMAL_ID_CREATE(9) + - THERMAL10 : ONLP_THERMAL_ID_CREATE(10) + - THERMAL11 : ONLP_THERMAL_ID_CREATE(11) + - THERMAL12 : ONLP_THERMAL_ID_CREATE(12) + - THERMAL13 : ONLP_THERMAL_ID_CREATE(13) + - THERMAL14 : ONLP_THERMAL_ID_CREATE(14) + - THERMAL15 : ONLP_THERMAL_ID_CREATE(15) + - THERMAL16 : ONLP_THERMAL_ID_CREATE(16) + + + portingmacro: + X86_64_QUANTA_LY7_RGLBMC: + macros: + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x new file mode 100755 index 00000000..fb92a8c9 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h new file mode 100755 index 00000000..77fc4eed --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h @@ -0,0 +1,167 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_quanta_ly7_rglbmc Configuration Header + * + * @addtogroup x86_64_quanta_ly7_rglbmc-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_CONFIG_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD + * + * RPM Threshold at which the fan is considered to have failed. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX + * + * Maximum system front-to-back fan speed. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX 18000 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX + * + * Maximum system back-to-front fan speed. */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX 18000 +#endif + +/** + * X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS + * + * Time to hold Phy GPIO in reset, in ms */ + + +#ifndef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS +#define X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS 100 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_quanta_ly7_rglbmc_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_quanta_ly7_rglbmc_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_quanta_ly7_rglbmc_config_settings table. */ +extern x86_64_quanta_ly7_rglbmc_config_settings_t x86_64_quanta_ly7_rglbmc_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_quanta_ly7_rglbmc_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_quanta_ly7_rglbmc_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_quanta_ly7_rglbmc_porting.h" + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h new file mode 100755 index 00000000..95cb5d2d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_quanta_ly7_rglbmc Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_DOX_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_DOX_H__ + +/** + * @defgroup x86_64_quanta_ly7_rglbmc x86_64_quanta_ly7_rglbmc - x86_64_quanta_ly7_rglbmc Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_quanta_ly7_rglbmc-x86_64_quanta_ly7_rglbmc Public Interface + * @defgroup x86_64_quanta_ly7_rglbmc-config Compile Time Configuration + * @defgroup x86_64_quanta_ly7_rglbmc-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h new file mode 100755 index 00000000..8317d978 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h @@ -0,0 +1,39 @@ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_GPIO_TABLE_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_GPIO_TABLE_H__ + +/* + * defined within platform/quanta_switch.c + * Quanta Switch Platform driver + */ +#define QUANTA_LY7_PCA953x_GPIO(P1, P2) (P1*8+P2) + +#define QUANTA_LY7_PCA9555_GPIO_SIZE 0x10 + +#define QUANTA_LY7_I2C_GPIO_BASE 0x10 + +#define QUANTA_LY7_I2C_GPIO_CPU_BASE 0x40 + +#define QUANTA_LY7_CPU_BOARD_GPIO_BASE (QUANTA_LY7_I2C_GPIO_CPU_BASE) +#define QUANTA_LY7_CPU_BOARD_SYS_P1 (QUANTA_LY7_CPU_BOARD_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,2)) +#define QUANTA_LY7_CPU_BOARD_SYS_P2 (QUANTA_LY7_CPU_BOARD_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,3)) + +#define QUANTA_LY7_ZQSFP_EN_GPIO_BASE QUANTA_LY7_I2C_GPIO_BASE +#define QUANTA_LY7_ZQSFP_EN_GPIO_SIZE QUANTA_LY7_PCA9555_GPIO_SIZE +#define QUANTA_LY7_ZQSFP_EN_GPIO_P3V3_PW_GD (QUANTA_LY7_ZQSFP_EN_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,4)) +#define QUANTA_LY7_ZQSFP_EN_GPIO_P3V3_PW_EN (QUANTA_LY7_ZQSFP_EN_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,5)) + +#define QUANTA_LY7_PCA9698_2_GPIO_BASE (QUANTA_LY7_I2C_GPIO_BASE + QUANTA_LY7_PCA9555_GPIO_SIZE) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_RESET_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,0)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_PRSNT_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,2)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_LPMOD_P (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,3)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_RESET_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,4)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_PRSNT_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,6)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_LPMOD_P (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(0,7)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_RESET_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,0)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_PRSNT_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,2)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_LPMOD_P (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,3)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_RESET_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,4)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_PRSNT_N (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,6)) +#define QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_LPMOD_P (QUANTA_LY7_PCA9698_2_GPIO_BASE + QUANTA_LY7_PCA953x_GPIO(1,7)) + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h new file mode 100755 index 00000000..32b963fa --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h @@ -0,0 +1,87 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_quanta_ly7_rglbmc Porting Macros. + * + * @addtogroup x86_64_quanta_ly7_rglbmc-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_PORTING_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_PORTING_H__ + + +/* */ +#if X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_QUANTA_LY7_RGLBMC_MEMSET GLOBAL_MEMSET + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_MEMSET memset + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_QUANTA_LY7_RGLBMC_MEMCPY GLOBAL_MEMCPY + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_MEMCPY memcpy + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_QUANTA_LY7_RGLBMC_STRNCPY GLOBAL_STRNCPY + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_STRNCPY strncpy + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_QUANTA_LY7_RGLBMC_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_VSNPRINTF vsnprintf + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_QUANTA_LY7_RGLBMC_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_SNPRINTF snprintf + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_QUANTA_LY7_RGLBMC_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_QUANTA_LY7_RGLBMC_STRLEN GLOBAL_STRLEN + #elif X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB == 1 + #define X86_64_QUANTA_LY7_RGLBMC_STRLEN strlen + #else + #error The macro X86_64_QUANTA_LY7_RGLBMC_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/make.mk new file mode 100755 index 00000000..9976c552 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_quanta_ly7_rglbmc_INCLUDES := -I $(THIS_DIR)inc +x86_64_quanta_ly7_rglbmc_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_quanta_ly7_rglbmc_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ly7_rglbmc ucli:x86_64_quanta_ly7_rglbmc + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/Makefile new file mode 100755 index 00000000..0aa71303 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_quanta_ly7_rglbmc_ucli.c + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/fani.c new file mode 100755 index 00000000..7594b0ca --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/fani.c @@ -0,0 +1,31 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_fani_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/ledi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/ledi.c new file mode 100755 index 00000000..74928269 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/ledi.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include + +#include "x86_64_quanta_ly7_rglbmc_int.h" +#include +#include + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t led_info[] = +{ + { }, /* Not used */ + { + { LED_OID_SYSTEM, "System LED", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, + } +}; + +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + + int led_id; + + led_id = ONLP_OID_ID_GET(id); + + *info = led_info[led_id]; + info->status |= ONLP_LED_STATUS_ON; + info->mode |= ONLP_LED_MODE_ON; + + return ONLP_STATUS_OK; +} + +void +Sysfs_Set_System_LED(onlp_led_mode_t mode) +{ + if(mode == ONLP_LED_MODE_GREEN){ + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P1, 0); + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P2, 1); + } + else if(mode == ONLP_LED_MODE_ORANGE){ + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P1, 1); + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P2, 0); + } + else{ + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P1, 1); + onlp_gpio_set(QUANTA_LY7_CPU_BOARD_SYS_P2, 1); + } +} + +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int led_id; + + led_id = ONLP_OID_ID_GET(id); + switch (led_id) { + case LED_ID_SYSTEM: + Sysfs_Set_System_LED(mode); + break; + default: + return ONLP_STATUS_E_INTERNAL; + break; + } + + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/make.mk b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/make.mk new file mode 100755 index 00000000..f48c4f6e --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_quanta_ly7_rglbmc +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/psui.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/psui.c new file mode 100755 index 00000000..b5cedce1 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/psui.c @@ -0,0 +1,15 @@ +/************************************************************ + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c new file mode 100755 index 00000000..5bb1079f --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c @@ -0,0 +1,409 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * SFPI Interface for the Quanta LY7 + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "x86_64_quanta_ly7_rglbmc_log.h" +#include +#include +#include + +/** + * This table maps the presence gpio, reset gpio, and eeprom file + * for each SFP port. + */ +typedef struct sfpmap_s { + int port; + const char* present_cpld; + const char* reset_gpio; + const char* eeprom; + const char* dom; +} sfpmap_t; + +static sfpmap_t sfpmap__[] = + { + { 1, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-1/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-32/32-0050/eeprom", NULL }, + { 2, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-2/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-33/33-0050/eeprom", NULL }, + { 3, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-3/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-34/34-0050/eeprom", NULL }, + { 4, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-4/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-35/35-0050/eeprom", NULL }, + { 5, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-5/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-36/36-0050/eeprom", NULL }, + { 6, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-6/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-37/37-0050/eeprom", NULL }, + { 7, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-7/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-38/38-0050/eeprom", NULL }, + { 8, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-8/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/i2c-39/39-0050/eeprom", NULL }, + { 9, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-9/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-40/40-0050/eeprom", NULL }, + { 10, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-10/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-41/41-0050/eeprom", NULL }, + { 11, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-11/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-42/42-0050/eeprom", NULL }, + { 12, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-12/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-43/43-0050/eeprom", NULL }, + { 13, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-13/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-44/44-0050/eeprom", NULL }, + { 14, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-14/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-45/45-0050/eeprom", NULL }, + { 15, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-15/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-46/46-0050/eeprom", NULL }, + { 16, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0038/cpld-sfp28/port-16/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-47/47-0050/eeprom", NULL }, + { 17, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-17/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-48/48-0050/eeprom", NULL }, + { 18, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-18/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-49/49-0050/eeprom", NULL }, + { 19, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-19/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-50/50-0050/eeprom", NULL }, + { 20, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-20/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-51/51-0050/eeprom", NULL }, + { 21, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-21/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-52/52-0050/eeprom", NULL }, + { 22, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-22/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-53/53-0050/eeprom", NULL }, + { 23, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-23/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-54/54-0050/eeprom", NULL }, + { 24, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-24/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-55/55-0050/eeprom", NULL }, + { 25, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-25/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-56/56-0050/eeprom", NULL }, + { 26, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-26/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-57/57-0050/eeprom", NULL }, + { 27, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-27/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-58/58-0050/eeprom", NULL }, + { 28, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-28/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-59/59-0050/eeprom", NULL }, + { 29, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-29/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-60/60-0050/eeprom", NULL }, + { 30, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-30/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-61/61-0050/eeprom", NULL }, + { 31, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-31/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-62/62-0050/eeprom", NULL }, + { 32, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-32/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-63/63-0050/eeprom", NULL }, + { 33, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-33/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-64/64-0050/eeprom", NULL }, + { 34, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-34/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-65/65-0050/eeprom", NULL }, + { 35, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-35/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-66/66-0050/eeprom", NULL }, + { 36, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-36/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-67/67-0050/eeprom", NULL }, + { 37, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-37/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-68/68-0050/eeprom", NULL }, + { 38, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-38/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-69/69-0050/eeprom", NULL }, + { 39, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-39/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-70/70-0050/eeprom", NULL }, + { 40, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-40/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-24/i2c-71/71-0050/eeprom", NULL }, + { 41, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-41/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-72/72-0050/eeprom", NULL }, + { 42, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-42/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-73/73-0050/eeprom", NULL }, + { 43, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-43/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-74/74-0050/eeprom", NULL }, + { 44, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-44/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-75/75-0050/eeprom", NULL }, + { 45, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-45/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-76/76-0050/eeprom", NULL }, + { 46, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-46/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-77/77-0050/eeprom", NULL }, + { 47, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-47/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-78/78-0050/eeprom", NULL }, + { 48, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0038/cpld-sfp28/port-48/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/i2c-79/79-0050/eeprom", NULL }, + }; + +typedef struct qsfpmap_s { + int port; + int present_gpio; + int reset_gpio; + int lplmod_gpio; + const char* eeprom; + const char* dom; +} qsfpmap_t; + +static qsfpmap_t qsfpmap__[] = + { + { 49, QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_PRSNT_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_RESET_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_49_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-80/80-0050/eeprom", NULL }, + { 50, QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_PRSNT_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_RESET_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_50_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-81/81-0050/eeprom", NULL }, + { 51, QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_PRSNT_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_RESET_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_51_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-82/82-0050/eeprom", NULL }, + { 52, QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_PRSNT_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_RESET_N, QUANTA_LY7_PCA9698_2_GPIO_QSFP_52_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-26/i2c-83/83-0050/eeprom", NULL }, + }; + +#define SFP_GET(_port) (sfpmap__ + _port - 1) +#define QSFP_GET(_port) (qsfpmap__ + _port - 49) +#define MAX_SFP_PATH 128 +static char sfp_node_path[MAX_SFP_PATH] = {0}; + +static char* +sfp_get_port_path(int port, char *node_name) +{ + sfpmap_t* sfp = SFP_GET(port); + + sprintf(sfp_node_path, sfp->present_cpld, + node_name); + return sfp_node_path; +} + +int +onlp_sfpi_init(void) +{ + int ret, i; + qsfpmap_t* qsfp; + + onlp_gpio_export(QUANTA_LY7_ZQSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); + ret = onlp_gpio_set(QUANTA_LY7_ZQSFP_EN_GPIO_P3V3_PW_EN, 1); + sleep(1); + + for(i = 49; i < 53 ; i ++) { + qsfp = QSFP_GET(i); + onlp_gpio_export(qsfp->present_gpio, ONLP_GPIO_DIRECTION_IN); + onlp_gpio_export(qsfp->reset_gpio, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_set(qsfp->reset_gpio, 1); + onlp_gpio_export(qsfp->lplmod_gpio, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_set(qsfp->lplmod_gpio, 0); + } + + return ret; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + + for(p = 1; p < 53; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + if(port > 48){ + int value = 0; + qsfpmap_t* qsfp = QSFP_GET(port); + + if(qsfp->present_gpio > 0) { + if(onlp_gpio_get(qsfp->present_gpio, &value) == ONLP_STATUS_OK) + return (value == 0); + else + return ONLP_STATUS_E_MISSING; + } + else { + /** + * If we can open and read a byte from the EEPROM file + * then we consider it present. + */ + int fd = open(qsfp->eeprom, O_RDONLY); + if (fd < 0) { + /* Not Present */ + return 0; + } + int rv; + uint8_t byte; + + if(read(fd, &byte, 1) == 1) { + /* Present */ + rv = 1; + } + else { + /* No Present */ + rv = 0; + } + close(fd); + return rv; + } + } + else{ + return onlplib_sfp_is_present_file(sfp_get_port_path(port, "pre_n"), /* Present */ "1\n", /* Absent */ "0\n"); + } +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + return onlplib_sfp_eeprom_read_file(qsfp->eeprom, data); + } + else{ + sfpmap_t* sfp = SFP_GET(port); + return onlplib_sfp_eeprom_read_file(sfp->eeprom, data); + } +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + return onlplib_sfp_eeprom_read_file(qsfp->dom, data); + } + else{ + sfpmap_t* sfp = SFP_GET(port); + return onlplib_sfp_eeprom_read_file(sfp->dom, data); + } +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + if(onlp_gpio_set(qsfp->reset_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to set reset status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + if(onlp_gpio_set(qsfp->lplmod_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to set lp_mode status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + else{ + switch(control){ + case ONLP_SFP_CONTROL_TX_DISABLE: + { + char* path = sfp_get_port_path(port, "tx_dis"); + + if (onlp_file_write_int(value, path) != 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + char* path = NULL; + + if(port > 48){ + qsfpmap_t* qsfp = QSFP_GET(port); + + switch(control){ + case ONLP_SFP_CONTROL_RESET_STATE: + { + if(onlp_gpio_get(qsfp->reset_gpio, value) == ONLP_STATUS_OK){ + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read reset status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_LP_MODE: + { + if(onlp_gpio_get(qsfp->lplmod_gpio, value) == ONLP_STATUS_OK){ + rv = ONLP_STATUS_OK; + } + else{ + AIM_LOG_ERROR("Unable to read lp_mode status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_RX_LOS: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + *value = 0; + rv = ONLP_STATUS_OK; + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + else{ + switch(control){ + case ONLP_SFP_CONTROL_RX_LOS: + { + path = sfp_get_port_path(port, "rx_los"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + path = sfp_get_port_path(port, "tx_fault"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + path = sfp_get_port_path(port, "tx_dis"); + + if (onlp_file_read_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to read tx_disable status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + if(*value == 0){ + *value = 1; + } + else{ + *value = 0; + } + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + } + + return rv; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sysi.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sysi.c new file mode 100755 index 00000000..2be2773f --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/sysi.c @@ -0,0 +1,66 @@ +/************************************************************ + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "x86_64_quanta_ly7_rglbmc_int.h" +#include "x86_64_quanta_ly7_rglbmc_log.h" +#include +#include +#include +#include +#include + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-quanta-ly7-rglbmc-r0"; +} + +int +onlp_sysi_init(void) +{ + /* Config GPIO */ + /* LED Output */ + onlp_gpio_export(QUANTA_LY7_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); + onlp_gpio_export(QUANTA_LY7_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); + + /* Set LED to green */ + onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); + + return ONLP_STATUS_OK; +} + +#define QUANTA_SYS_EEPROM_PATH \ +"/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/18-0054/eeprom" + +int +onlp_sysi_onie_info_get(onlp_onie_info_t* onie) +{ + int rv; + + rv = onlp_onie_decode_file(onie, QUANTA_SYS_EEPROM_PATH); + if(rv >= 0) { + onie->platform_name = aim_strdup("x86-64-quanta-ly7-rglbmc-r0"); + rv = quanta_onie_sys_eeprom_custom_format(onie); + } + return rv; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* + * 1 LEDs + */ + *e++ = LED_OID_SYSTEM; + + return 0; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/thermali.c new file mode 100755 index 00000000..2a84c017 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/thermali.c @@ -0,0 +1,31 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include + +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c new file mode 100755 index 00000000..0a811a3b --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c @@ -0,0 +1,95 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(_x) +x86_64_quanta_ly7_rglbmc_config_settings_t x86_64_quanta_ly7_rglbmc_config_settings[] = +{ +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_STDLIB(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS + { __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS) }, +#else +{ X86_64_QUANTA_LY7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_VALUE +#undef __x86_64_quanta_ly7_rglbmc_config_STRINGIFY_NAME + +const char* +x86_64_quanta_ly7_rglbmc_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_quanta_ly7_rglbmc_config_settings[i].name; i++) { + if(strcmp(x86_64_quanta_ly7_rglbmc_config_settings[i].name, setting)) { + return x86_64_quanta_ly7_rglbmc_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_quanta_ly7_rglbmc_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_quanta_ly7_rglbmc_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_quanta_ly7_rglbmc_config_settings[i].name, x86_64_quanta_ly7_rglbmc_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c new file mode 100755 index 00000000..1d1f3f93 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h new file mode 100755 index 00000000..c0d51dca --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h @@ -0,0 +1,281 @@ +/**************************************************************************//** + * + * x86_64_quanta_ly7_rglbmc Internal Header + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_INT_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_INT_H__ + +#include +#include + +/* */ +/** thermal_oid */ +typedef enum thermal_oid_e { + THERMAL_OID_THERMAL1 = ONLP_THERMAL_ID_CREATE(1), + THERMAL_OID_THERMAL2 = ONLP_THERMAL_ID_CREATE(2), + THERMAL_OID_THERMAL3 = ONLP_THERMAL_ID_CREATE(3), + THERMAL_OID_THERMAL4 = ONLP_THERMAL_ID_CREATE(4), + THERMAL_OID_THERMAL5 = ONLP_THERMAL_ID_CREATE(5), + THERMAL_OID_THERMAL6 = ONLP_THERMAL_ID_CREATE(6), + THERMAL_OID_THERMAL7 = ONLP_THERMAL_ID_CREATE(7), + THERMAL_OID_THERMAL8 = ONLP_THERMAL_ID_CREATE(8), + THERMAL_OID_THERMAL9 = ONLP_THERMAL_ID_CREATE(9), + THERMAL_OID_THERMAL10 = ONLP_THERMAL_ID_CREATE(10), + THERMAL_OID_THERMAL11 = ONLP_THERMAL_ID_CREATE(11), + THERMAL_OID_THERMAL12 = ONLP_THERMAL_ID_CREATE(12), + THERMAL_OID_THERMAL13 = ONLP_THERMAL_ID_CREATE(13), + THERMAL_OID_THERMAL14 = ONLP_THERMAL_ID_CREATE(14), + THERMAL_OID_THERMAL15 = ONLP_THERMAL_ID_CREATE(15), + THERMAL_OID_THERMAL16 = ONLP_THERMAL_ID_CREATE(16), +} thermal_oid_t; + +/** Enum names. */ +const char* thermal_oid_name(thermal_oid_t e); + +/** Enum values. */ +int thermal_oid_value(const char* str, thermal_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_oid_desc(thermal_oid_t e); + +/** Enum validator. */ +int thermal_oid_valid(thermal_oid_t e); + +/** validator */ +#define THERMAL_OID_VALID(_e) \ + (thermal_oid_valid((_e))) + +/** thermal_oid_map table. */ +extern aim_map_si_t thermal_oid_map[]; +/** thermal_oid_desc_map table. */ +extern aim_map_si_t thermal_oid_desc_map[]; + +/** psu_oid */ +typedef enum psu_oid_e { + PSU_OID_PSU1 = ONLP_PSU_ID_CREATE(1), + PSU_OID_PSU2 = ONLP_PSU_ID_CREATE(2), +} psu_oid_t; + +/** Enum names. */ +const char* psu_oid_name(psu_oid_t e); + +/** Enum values. */ +int psu_oid_value(const char* str, psu_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_oid_desc(psu_oid_t e); + +/** Enum validator. */ +int psu_oid_valid(psu_oid_t e); + +/** validator */ +#define PSU_OID_VALID(_e) \ + (psu_oid_valid((_e))) + +/** psu_oid_map table. */ +extern aim_map_si_t psu_oid_map[]; +/** psu_oid_desc_map table. */ +extern aim_map_si_t psu_oid_desc_map[]; + +/** thermal_id */ +typedef enum thermal_id_e { + THERMAL_ID_THERMAL1 = 1, + THERMAL_ID_THERMAL2 = 2, + THERMAL_ID_THERMAL3 = 3, + THERMAL_ID_THERMAL4 = 4, + THERMAL_ID_THERMAL5 = 5, + THERMAL_ID_THERMAL6 = 6, + THERMAL_ID_THERMAL7 = 7, + THERMAL_ID_THERMAL8 = 8, + THERMAL_ID_THERMAL9 = 9, + THERMAL_ID_THERMAL10 = 10, + THERMAL_ID_THERMAL11 = 11, + THERMAL_ID_THERMAL12 = 12, + THERMAL_ID_THERMAL13 = 13, + THERMAL_ID_THERMAL14 = 14, + THERMAL_ID_THERMAL15 = 15, + THERMAL_ID_THERMAL16 = 16, +} thermal_id_t; + +/** Enum names. */ +const char* thermal_id_name(thermal_id_t e); + +/** Enum values. */ +int thermal_id_value(const char* str, thermal_id_t* e, int substr); + +/** Enum descriptions. */ +const char* thermal_id_desc(thermal_id_t e); + +/** Enum validator. */ +int thermal_id_valid(thermal_id_t e); + +/** validator */ +#define THERMAL_ID_VALID(_e) \ + (thermal_id_valid((_e))) + +/** thermal_id_map table. */ +extern aim_map_si_t thermal_id_map[]; +/** thermal_id_desc_map table. */ +extern aim_map_si_t thermal_id_desc_map[]; + +/** fan_id */ +typedef enum fan_id_e { + FAN_ID_FAN1 = 1, + FAN_ID_FAN2 = 2, + FAN_ID_FAN3 = 3, + FAN_ID_FAN4 = 4, + FAN_ID_FAN5 = 5, + FAN_ID_FAN6 = 6, + FAN_ID_FAN7 = 7, + FAN_ID_FAN8 = 8, + FAN_ID_FAN9 = 9, + FAN_ID_FAN10 = 10, +} fan_id_t; + +/** Enum names. */ +const char* fan_id_name(fan_id_t e); + +/** Enum values. */ +int fan_id_value(const char* str, fan_id_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_id_desc(fan_id_t e); + +/** Enum validator. */ +int fan_id_valid(fan_id_t e); + +/** validator */ +#define FAN_ID_VALID(_e) \ + (fan_id_valid((_e))) + +/** fan_id_map table. */ +extern aim_map_si_t fan_id_map[]; +/** fan_id_desc_map table. */ +extern aim_map_si_t fan_id_desc_map[]; + +/** psu_id */ +typedef enum psu_id_e { + PSU_ID_PSU1 = 1, + PSU_ID_PSU2 = 2, +} psu_id_t; + +/** Enum names. */ +const char* psu_id_name(psu_id_t e); + +/** Enum values. */ +int psu_id_value(const char* str, psu_id_t* e, int substr); + +/** Enum descriptions. */ +const char* psu_id_desc(psu_id_t e); + +/** Enum validator. */ +int psu_id_valid(psu_id_t e); + +/** validator */ +#define PSU_ID_VALID(_e) \ + (psu_id_valid((_e))) + +/** psu_id_map table. */ +extern aim_map_si_t psu_id_map[]; +/** psu_id_desc_map table. */ +extern aim_map_si_t psu_id_desc_map[]; + +/** fan_oid */ +typedef enum fan_oid_e { + FAN_OID_FAN1 = ONLP_FAN_ID_CREATE(1), + FAN_OID_FAN2 = ONLP_FAN_ID_CREATE(2), + FAN_OID_FAN3 = ONLP_FAN_ID_CREATE(3), + FAN_OID_FAN4 = ONLP_FAN_ID_CREATE(4), + FAN_OID_FAN5 = ONLP_FAN_ID_CREATE(5), + FAN_OID_FAN6 = ONLP_FAN_ID_CREATE(6), + FAN_OID_FAN7 = ONLP_FAN_ID_CREATE(7), + FAN_OID_FAN8 = ONLP_FAN_ID_CREATE(8), + FAN_OID_FAN9 = ONLP_FAN_ID_CREATE(9), + FAN_OID_FAN10 = ONLP_FAN_ID_CREATE(10), +} fan_oid_t; + +/** Enum names. */ +const char* fan_oid_name(fan_oid_t e); + +/** Enum values. */ +int fan_oid_value(const char* str, fan_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* fan_oid_desc(fan_oid_t e); + +/** Enum validator. */ +int fan_oid_valid(fan_oid_t e); + +/** validator */ +#define FAN_OID_VALID(_e) \ + (fan_oid_valid((_e))) + +/** fan_oid_map table. */ +extern aim_map_si_t fan_oid_map[]; +/** fan_oid_desc_map table. */ +extern aim_map_si_t fan_oid_desc_map[]; +/* */ + +/* psu info table */ +struct psu_info_s { + char path[PATH_MAX]; + int present; + int busno; + int addr; +}; + +/** led_id */ +typedef enum led_id_e { + LED_ID_SYSTEM = 1, +} led_id_t; + +/** Enum names. */ +const char* led_id_name(led_id_t e); + +/** Enum values. */ +int led_id_value(const char* str, led_id_t* e, int substr); + +/** Enum descriptions. */ +const char* led_id_desc(led_id_t e); + +/** Enum validator. */ +int led_id_valid(led_id_t e); + +/** validator */ +#define LED_ID_VALID(_e) \ + (led_id_valid((_e))) + +/** led_id_map table. */ +extern aim_map_si_t led_id_map[]; +/** led_id_desc_map table. */ +extern aim_map_si_t led_id_desc_map[]; + +/** led_oid */ +typedef enum led_oid_e { + LED_OID_SYSTEM = ONLP_LED_ID_CREATE(LED_ID_SYSTEM), +} led_oid_t; + +/** Enum names. */ +const char* led_oid_name(led_oid_t e); + +/** Enum values. */ +int led_oid_value(const char* str, led_oid_t* e, int substr); + +/** Enum descriptions. */ +const char* led_oid_desc(led_oid_t e); + +/** Enum validator. */ +int led_oid_valid(led_oid_t e); + +/** validator */ +#define LED_OID_VALID(_e) \ + (led_oid_valid((_e))) + +/** led_oid_map table. */ +extern aim_map_si_t led_oid_map[]; +/** led_oid_desc_map table. */ +extern aim_map_si_t led_oid_desc_map[]; +/* */ + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c new file mode 100755 index 00000000..f1e92e8c --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_quanta_ly7_rglbmc_log.h" +/* + * x86_64_quanta_ly7_rglbmc log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_QUANTA_LY7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h new file mode 100755 index 00000000..6a5dc0ce --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __X86_64_QUANTA_LY7_RGLBMC_LOG_H__ +#define __X86_64_QUANTA_LY7_RGLBMC_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_quanta_ly7_rglbmc +#include + +#endif /* __X86_64_QUANTA_LY7_RGLBMC_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c new file mode 100755 index 00000000..7fbcc78e --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_quanta_ly7_rglbmc_log.h" + +static int +datatypes_init__(void) +{ +#define X86_64_QUANTA_LY7_RGLBMC_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_quanta_ly7_rglbmc_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c new file mode 100755 index 00000000..cf50c8f5 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/onlp/builds/src/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_QUANTA_LY7_RGLBMC_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_quanta_ly7_rglbmc_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ly7_rglbmc) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_quanta_ly7_rglbmc_ucli_module__ = + { + "x86_64_quanta_ly7_rglbmc_ucli", + NULL, + x86_64_quanta_ly7_rglbmc_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_quanta_ly7_rglbmc_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_quanta_ly7_rglbmc_ucli_module__); + n = ucli_node_create("x86_64_quanta_ly7_rglbmc", NULL, &x86_64_quanta_ly7_rglbmc_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ly7_rglbmc")); + return n; +} + +#else +void* +x86_64_quanta_ly7_rglbmc_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/Makefile new file mode 100755 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/PKG.yml new file mode 100755 index 00000000..25082e7d --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly7-rglbmc REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml new file mode 100755 index 00000000..8cf8da1f --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml @@ -0,0 +1,31 @@ +--- + +###################################################################### +# +# platform-config for LY7 +# +###################################################################### + +x86-64-quanta-ly7-rglbmc-r0: + + grub: + + serial: >- + --port=0x2f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + console=ttyS1,115200n8 + reboot=c,p + + ##network: + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py new file mode 100755 index 00000000..1cd8c645 --- /dev/null +++ b/packages/platforms/quanta/x86-64/x86-64-quanta-ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py @@ -0,0 +1,22 @@ +from onl.platform.base import * +from onl.platform.quanta import * + +class OnlPlatform_x86_64_quanta_ly7_rglbmc_r0(OnlPlatformQuanta, + OnlPlatformPortConfig_48x10_4x100): + PLATFORM='x86-64-quanta-ly7-rglbmc-r0' + MODEL="LY7" + """ Define Quanta SYS_OBJECT_ID rule. + + SYS_OBJECT_ID = .xxxx.ABCC + "xxxx" define QCT device mark. For example, LB9->1048, LY2->3048 + "A" define QCT switch series name: LB define 1, LY define 2, IX define 3 + "B" define QCT switch series number 1: For example, LB9->9, LY2->2 + "CC" define QCT switch series number 2: For example, LY2->00, LY4R->18(R is 18th english letter) + """ + SYS_OBJECT_ID=".3048.2700" + + def baseconfig(self): + self.insmod("qci_cpld_sfp28") + self.insmod("quanta_platform_ly7") + + return True diff --git a/sm/bigcode b/sm/bigcode index a8c72b6c..6a3c9705 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit a8c72b6c0553a3547be6be16b41fae2af5b38951 +Subproject commit 6a3c9705a418c419dbea2dc46c46fa2f00dcd6b2 diff --git a/sm/infra b/sm/infra index 2b72b5dc..34c433a3 160000 --- a/sm/infra +++ b/sm/infra @@ -1 +1 @@ -Subproject commit 2b72b5dce5e910f31e855eebbeb41a0e481e35d1 +Subproject commit 34c433a353012eddcfe596347f102f47ac72593f diff --git a/tools/sjson.py b/tools/sjson.py index 4c0543e9..4e3483b2 100755 --- a/tools/sjson.py +++ b/tools/sjson.py @@ -30,6 +30,7 @@ def setkeypath(d, kvt): ap=argparse.ArgumentParser(description="Simple JSON Generator.") +ap.add_argument("--in", metavar='FILENAME', help="Load json source data.", dest='_in') ap.add_argument("--kj", nargs=2, metavar=('KEY', 'FILE|STR'), help="Add json data.") ap.add_argument("--ky", nargs=2, metavar=('KEY', 'FILE|STR'), help="Add yaml jdata.") ap.add_argument("--kv", nargs=2, metavar=('KEY', 'VALUE'), help="Add key/value pair.") @@ -37,11 +38,18 @@ ap.add_argument("--kl", nargs='+', metavar=('KEY', 'ENTRY'), help="Add key/l ap.add_argument("--out", metavar='FILENAME', help="Write output to the given file. The default is stdout") ap.add_argument("--indent", nargs=1, help="Json output indentation value. Default is 2", default=2) ap.add_argument("--no-nl", action='store_true', help="No newline at the end of the output.") +ap.add_argument("--inout", metavar='FILENAME', help="Modify. Equivalent to --in FILENAME --out FILENAME") ops = ap.parse_args(); +if ops.inout: + ops._in = ops.inout + ops.out = ops.inout g_data={} +if ops._in: + g_data = json.load(open(ops._in)) + if ops.kj: (k, j) = ops.kj if os.path.exists(j):