Revert "sync delta Release 1.3 about ag6248c with ocp "

This commit is contained in:
Jeffrey Townsend
2017-12-29 08:58:44 -08:00
committed by GitHub
parent 26d0e49f11
commit 742bb5b8ca
69 changed files with 17 additions and 6562 deletions

View File

@@ -19,7 +19,6 @@ import zipfile
import onl.install.InstallUtils
MountContext = onl.install.InstallUtils.MountContext
BlkidParser = onl.install.InstallUtils.BlkidParser
UbinfoParser = onl.install.InstallUtils.UbinfoParser
ProcMountsParser = onl.install.InstallUtils.ProcMountsParser
import onl.mounts
@@ -248,14 +247,6 @@ class Runner(onl.install.InstallUtils.SubprocessMixin):
part = blkid[label]
except IndexError:
part = None
if part is None:
ubinfo = UbinfoParser(log=self.log)
part = {}
part = ubinfo[label]
device = "/dev/" + part['device'] + "_" + part['Volume ID']
return self.blockdevCopy(device, r, dir=mpt)
if part is not None:
return self.blockdevCopy(part.device, r, dir=mpt)

View File

@@ -11,7 +11,6 @@ import logging
import onl.install.InstallUtils
BlkidParser = onl.install.InstallUtils.BlkidParser
UbinfoParser = onl.install.InstallUtils.UbinfoParser
import onl.mounts
MountContext = onl.install.InstallUtils.MountContext
@@ -27,7 +26,6 @@ class Runner(onl.install.InstallUtils.SubprocessMixin):
self.log = log
self.blkid = BlkidParser(log=self.log)
self.ubinfo = UbinfoParser(log=self.log)
def mount(self, SWI):
@@ -127,13 +125,6 @@ class Runner(onl.install.InstallUtils.SubprocessMixin):
part = self.blkid[label]
except IndexError:
part = None
if part is None:
part = {}
part = self.ubinfo[label]
device = "/dev/" + part['device'] + "_" + part['Volume ID']
return self.blockdevMount(device, path, dir=mpt)
if part is not None:
return self.blockdevMount(part.device, path, dir=mpt)
@@ -150,12 +141,7 @@ class Runner(onl.install.InstallUtils.SubprocessMixin):
if not os.path.exists(dst):
self.log.error("missing SWI: %s", dst)
return None
p = dev.find('ubi')
if p < 0:
self.check_call(('mount', '-o', 'rw,remount', dst,))
else:
self.check_call(('mount', '-t', 'ubifs', '-o', 'rw,remount', dst,))
self.check_call(('mount', '-o', 'rw,remount', dst,))
return dst
with MountContext(device=dev, log=self.log) as ctx:
@@ -168,12 +154,7 @@ class Runner(onl.install.InstallUtils.SubprocessMixin):
# move to its proper location as per mtab
# XXX perms may not be right here
if dir is not None:
p = dev.find('ubi')
if p < 0:
self.check_call(('mount', '-o', 'rw,remount', ctx.dir,))
else:
self.check_call(('mount', '-t', 'ubifs', '-o', 'rw,remount', ctx.dir,))
self.check_call(('mount', '-o', 'rw,remount', ctx.dir,))
self.check_call(('mount', '--move', ctx.dir, dir,))
ctx.mounted = False
dst = dir

View File

@@ -15,8 +15,8 @@ if [ ! -d /mnt/onl/data ]; then
fi
# make sure it's mounted as per mtab.yml
d1=$(stat -f -c '%b' /mnt/onl)
d2=$(stat -f -c '%b' /mnt/onl/data)
d1=$(stat -f -c '%d' /mnt/onl)
d2=$(stat -f -c '%d' /mnt/onl/data)
if [ "$d1" -eq "$d2" ]; then
msg_error "Unmounted /mnt/onl/data, disk boot cannot continue"
exit 200

View File

@@ -129,13 +129,6 @@ default:
- ext2load mmc 0:1 $onl_loadaddr $onl_itb
- "bootm $onl_loadaddr#$onl_platform"
#ubifs to boot onl
flash_bootcmds: &flash_bootcmds
- ubi part open
- ubifsmount ONL-BOOT
- ubifsload $loadaddr $onl_itb
- "bootm $onl_loadaddr#$onl_platform"
nos_bootcmds: *ide_bootcmds
# Configure the fw_env.config file,

View File

@@ -17,7 +17,7 @@ import imp
import fnmatch, glob
from InstallUtils import SubprocessMixin
from InstallUtils import MountContext, BlkidParser, PartedParser, UbinfoParser
from InstallUtils import MountContext, BlkidParser, PartedParser
from InstallUtils import ProcMountsParser
from InstallUtils import GdiskParser
from InstallUtils import OnieSubprocess
@@ -83,7 +83,6 @@ class Base:
# keep track of next partition/next block
self.blkidParts = []
self.ubiParts = []
# current scan of partitions and labels
self.partedDevice = None
@@ -854,203 +853,7 @@ class GrubInstaller(SubprocessMixin, Base):
def shutdown(self):
Base.shutdown(self)
class UBIfsCreater(SubprocessMixin, Base):
def __init__(self, *args, **kwargs):
Base.__init__(self, *args, **kwargs)
self.log = logging.getLogger("ubinfo -a")
self.device = self.im.getDevice()
self.ubiParts = None
"""Set up an UBI file system."""
def ubifsinit(self):
UNITS = {
'GiB' : 1024 * 1024 * 1024,
'G' : 1000 * 1000 * 1000,
'MiB' : 1024 * 1024,
'M' : 1000 * 1000,
'KiB' : 1024,
'K' : 1000,
}
try:
code = 0
if not code:
mtd_num = self.device[-1]
cmd = ('ubiformat', '/dev/mtd' + mtd_num)
self.check_call(cmd, vmode=self.V2)
cmd = ('ubiattach', '-m', mtd_num, '-d', '0', '/dev/ubi_ctrl',)
self.check_call(cmd, vmode=self.V2)
for part in self.im.platformConf['installer']:
label, partData = list(part.items())[0]
if type(partData) == dict:
sz, fmt = partData['='], partData.get('format', 'ubifs')
else:
sz, fmt = partData, 'ubifs'
cnt = None
for ul, ub in UNITS.items():
if sz.endswith(ul):
cnt = int(sz[:-len(ul)], 10) * ub
break
if cnt is None:
self.log.error("invalid size (no units) for %s: %s",part, sz)
return 1
label = label.strip()
cmd = ('ubimkvol', '/dev/ubi0', '-N', label, '-s', bytes(cnt),)
self.check_call(cmd, vmode=self.V2)
except Exception:
self.log.exception("cannot create UBI file systemfrom %s",self.device)
return 0
def ubi_mount(self, dir, devpart):
if devpart is None:
self.log.error("Mount failed.no given mount device part")
return 1
if dir is None:
self.log.error("Mount failed.no given mount directory")
return 1
if self.ubiParts is None:
try:
self.ubiParts = UbinfoParser(log=self.log.getChild("ubinfo -a"))
except Exception:
self.log.exception("Mount failed.No UBIfs")
return 1
try:
dev = self.ubiParts[devpart]
except IndexError as ex:
self.log.error("Mount failed.cannot find %s partition", str(devpart))
return 1
self.makedirs(dir)
device = "/dev/" + dev['device'] + "_" + dev['Volume ID']
if dev['fsType']:
cmd = ('mount', '-t', dev['fsType'], device, dir,)
else:
cmd = ('mount', device, dir,)
code = self.check_call(cmd, vmode=self.V2)
if code:
self.log.error("Mount failed.mount command exect failed")
return 1
return 0
def ubi_unmount(self,dir=None):
if dir is None:
self.log.error("Unmount failed.no given unmount directory")
return 1
cmd = ('umount', dir)
code = self.check_call(cmd, vmode=self.V2)
if code:
self.log.error("Unmount failed.umount command exect failed")
return 1
return 0
def ubi_getinfo(self):
try:
self.ubiParts = UbinfoParser(log=self.log.getChild("ubinfo -a"))
except Exception:
self.log.exception("UBI info get failed.No UBIfs")
return 1
return 0
def ubi_installSwi(self):
files = os.listdir(self.im.installerConf.installer_dir) + self.zf.namelist()
swis = [x for x in files if x.endswith('.swi')]
if not swis:
self.log.warn("No ONL Software Image available for ubi installation.")
self.log.warn("Post-install ZTN installation will be required.")
if len(swis) > 1:
self.log.error("Multiple SWIs found in ubi installer: %s", " ".join(swis))
return 1
base = swis[0]
self.log.info("Installing ONL Software Image (%s)...", base)
dev = "ONL-IMAGES"
dstDir = "/tmp/ubifs"
code = self.ubi_mount(dstDir,dev)
if code :
return 1
dst = os.path.join(dstDir, base)
self.installerCopy(base, dst)
self.log.info("syncing block devices(%s)...",dev)
self.check_call(('sync',))
self.ubi_unmount(dstDir)
return 0
def ubi_installLoader(self):
loaderBasename = None
for c in sysconfig.installer.fit:
if self.installerExists(c):
loaderBasename = c
break
if not loaderBasename:
self.log.error("The platform loader file is missing.")
return 1
self.log.info("Installing the ONL loader from %s...", loaderBasename)
dev = "ONL-BOOT"
dstDir = "/tmp/ubiloader"
code = self.ubi_mount(dstDir,dev)
if code :
return 1
dst = os.path.join(dstDir, "%s.itb" % self.im.installerConf.installer_platform)
self.installerCopy(loaderBasename, dst)
self.log.info("syncing block devices(%s)...",dev)
self.check_call(('sync',))
self.ubi_unmount(dstDir)
return 0
def ubi_installBootConfig(self):
basename = 'boot-config'
self.log.info("Installing boot-config to ONL-BOOT partion")
dev = "ONL-BOOT"
dstDir = "/tmp/ubibootcon"
code = self.ubi_mount(dstDir,dev)
if code :
return 1
dst = os.path.join(dstDir, basename)
self.installerCopy(basename, dst, True)
with open(dst) as fd:
buf = fd.read()
ecf = buf.encode('base64', 'strict').strip()
if self.im.grub and self.im.grubEnv is not None:
setattr(self.im.grubEnv, 'boot_config_default', ecf)
if self.im.uboot and self.im.ubootEnv is not None:
setattr(self.im.ubootEnv, 'boot-config-default', ecf)
self.log.info("syncing block devices(%s)...",dev)
self.check_call(('sync',))
self.ubi_unmount(dstDir)
return 0
def ubi_installOnlConfig(self):
self.log.info("Installing onl-config to ONL-CONFIG partion")
dev = "ONL-CONFIG"
dstDir = "/tmp/ubionlconfig"
code = self.ubi_mount(dstDir,dev)
if code :
return 1
for f in self.zf.namelist():
d = 'config/'
if f.startswith(d) and f != d:
dst = os.path.join(dstDir, os.path.basename(f))
if not os.path.exists(dst):
self.installerCopy(f, dst)
self.log.info("syncing block devices(%s)...",dev)
self.check_call(('sync',))
self.ubi_unmount(dstDir)
return 0
class UbootInstaller(SubprocessMixin, UBIfsCreater):
class UbootInstaller(SubprocessMixin, Base):
class installmeta(Base.installmeta):
@@ -1071,16 +874,13 @@ class UbootInstaller(SubprocessMixin, UBIfsCreater):
cmds.append("setenv onl_itb %s" % itb)
for item in self.platformConf['loader']['setenv']:
k, v = list(item.items())[0]
device = self.getDevice()
if "mtdblock" in device:
cmds.append("setenv %s %s ${platformargs} ubi.mtd=%s root=/dev/ram ethaddr=$ethaddr" % (k, v, device[-1],))
else:
cmds.append("setenv %s %s" % (k, v,))
cmds.append("setenv %s %s" % (k, v,))
cmds.extend(self.platformConf['loader']['nos_bootcmds'])
return "; ".join(cmds)
def __init__(self, *args, **kwargs):
UBIfsCreater.__init__(self, *args, **kwargs)
Base.__init__(self, *args, **kwargs)
self.device = self.im.getDevice()
self.rawLoaderDevice = None
@@ -1214,24 +1014,6 @@ class UbootInstaller(SubprocessMixin, UBIfsCreater):
code = self.assertUnmounted()
if code: return code
if "mtdblock" in self.device:
code = self.ubifsinit()
if code: return code
code = self.ubi_getinfo()
if code: return code
code = self.ubi_installSwi()
if code: return code
code = self.ubi_installLoader()
if code: return code
code = self.ubi_installBootConfig()
if code: return code
code = self.ubi_installOnlConfig()
if code: return code
code = self.runPlugins(Plugin.PLUGIN_POSTINSTALL)
if code: return code
code = self.installUbootEnv()
return code
code = self.maybeCreateLabel()
if code: return code

View File

@@ -388,63 +388,6 @@ class BlkidParser(SubprocessMixin):
def __len__(self):
return len(self.parts)
class UbinfoParser(SubprocessMixin):
def __init__(self, log=None):
self.log = log or logging.getLogger("ubinfo -a")
self.parse()
def parse(self):
self.parts = []
lines = ''
try:
cmd = ('ubinfo', '-a',)
lines = self.check_output(cmd).splitlines()
except Exception as ex:
return self
dev = None
volId = None
name = None
attrs = {}
for line in lines:
line = line.strip()
p = line.find(':')
if p < 0: continue
name, value = line[:p], line[p+1:].strip()
if 'Volume ID' in name:
p = value.find('(')
if p < 0: continue
volumeId = value[:p].strip()
attrs['Volume ID'] = volumeId
p = value.find('on')
if p < 0: continue
dev = value[p+2:-1].strip()
attrs['device'] = dev
if 'Name' in name:
dev = "/dev/" + dev + "_" + volumeId
p = line.find(':')
if p < 0: continue
attrs['Name'] = line[p+1:].strip()
attrs['fsType'] = 'ubifs'
self.parts.append(attrs)
dev = None
volId = None
name = None
attrs = {}
def __getitem__(self, idxOrName):
if type(idxOrName) == int:
return self.parts[idxOrName]
for part in self.parts:
if part['Name'] == idxOrName: return part
raise IndexError("cannot find partition %s" % repr(idxOrName))
def __len__(self):
return len(self.parts)
class ProcMtdEntry:
def __init__(self,

View File

@@ -63,12 +63,7 @@ class MountManager(object):
self.logger.debug("%s not mounted @ %s. It will be mounted %s" % (device, directory, mode))
try:
p = device.find('ubi')
if p < 0:
cmd = "mount -o %s %s %s" % (','.join(mountargs), device, directory)
else:
cmd = "mount -o %s -t %s %s %s" % (','.join(mountargs), 'ubifs', device, directory)
cmd = "mount -o %s %s %s" % (','.join(mountargs), device, directory)
self.logger.debug("+ %s" % cmd)
subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError, e:
@@ -153,39 +148,12 @@ class OnlMountManager(object):
def _discover(k):
v = md[k]
lbl = v.get('label', k)
useUbiDev = False
try:
v['device'] = subprocess.check_output(('blkid', '-L', lbl,)).strip()
except subprocess.CalledProcessError:
useUbiDev = True
if useUbiDev == True:
if k == 'EFI-BOOT':
return False
output = subprocess.check_output("ubinfo -d 0 -N %s" % k, shell=True).splitlines()
volumeId = None
device = None
for line in output:
line = line.strip()
p = line.find(':')
if p < 0:
self.logger.debug("Invaild ubinfo output %s" % line)
name, value = line[:p], line[p+1:].strip()
if 'Volume ID' in name:
p = value.find('(')
if p < 0:
self.logger.debug("Invalid Volume ID %s" % value)
volumeId = value[:p].strip()
p = value.find('on')
if p < 0:
self.logger.debug("Invalid ubi devicde %s" % value)
device = value[p+2:-1].strip()
if 'Name' in name:
v['device'] = "/dev/" + device + "_" + volumeId
return False
if not os.path.isdir(v['dir']):
self.logger.debug("Make directory '%s'...", v['dir'])
os.makedirs(v['dir'])

View File

@@ -474,10 +474,6 @@ class OnlPlatformPortConfig_48x1_4x10(object):
PORT_COUNT=52
PORT_CONFIG="48x1 + 4x10"
class OnlPlatformPortConfig_48x1_2x10(object):
PORT_COUNT=50
PORT_CONFIG="48x1 + 2x10"
class OnlPlatformPortConfig_48x10_4x40(object):
PORT_COUNT=52
PORT_CONFIG="48x10 + 4x40"

View File

@@ -38,6 +38,6 @@ K_COPY_DST := kernel-3.2-lts-arm-iproc-all.bin.gz
endif
export ARCH=arm
DTS_LIST := accton_as4610_54 delta_ag6248c
DTS_LIST := accton_as4610_54
include $(ONL)/make/kbuild.mk

View File

@@ -289,7 +289,6 @@ CONFIG_BCM_RAM_START_RESERVED_SIZE=0x200000
# CONFIG_MACH_GH is not set
# CONFIG_MACH_DNI_3448P is not set
CONFIG_MACH_ACCTON_AS4610_54=y
CONFIG_MACH_DELTA_AG6248C=y
# CONFIG_MACH_IPROC_EMULATION is not set
#
@@ -1939,8 +1938,7 @@ CONFIG_IPROC_QSPI_SINGLE_MODE=y
# CONFIG_IPROC_QSPI_DUAL_MODE is not set
# CONFIG_IPROC_QSPI_QUAD_MODE is not set
CONFIG_IPROC_QSPI_MAX_HZ=62500000
CONFIG_IPROC_MTD_NAND=y
# CONFIG_IPROC_MTD_NAND_USE_JFFS2 is not set
# CONFIG_IPROC_MTD_NAND is not set
# CONFIG_IPROC_PWM is not set
CONFIG_IPROC_USB2H=y
CONFIG_USB_EHCI_BCM=y

View File

@@ -1,181 +0,0 @@
diff --git a/arch/arm/boot/dts/delta_ag6248c.dts b/arch/arm/boot/dts/delta_ag6248c.dts
new file mode 100755
index 0000000..f86c35b
--- /dev/null
+++ b/arch/arm/boot/dts/delta_ag6248c.dts
@@ -0,0 +1,78 @@
+/*
+ * Delta Networks, Inc. AG6248C Device Tree Source
+ *
+ * Copyright 2015, Cumulus Networks, 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.
+ *
+ */
+/dts-v1/;
+/include/ "helix4.dtsi"
+
+/ {
+ model = "delta,ag6248c";
+ compatible = "delta,ag6248c";
+
+ aliases {
+ serial0 = &uart0;
+ i2c-controller0 = &i2c0;
+ i2c-controller1 = &i2c1;
+ };
+
+ memory {
+ reg = <0x61000000 0x7f000000>;
+ };
+
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a9";
+ next-level-cache = <&L2>;
+ reg = <0x00>;
+ };
+ cpu@1 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a9";
+ next-level-cache = <&L2>;
+ reg = <0x01>;
+ };
+ };
+
+ localbus@1e000000{
+ address-cells = <0x2>;
+ #size-cells = <0x1>;
+ compatible = "simple-bus";
+ ranges = <0x0 0x0 0x1e000000 0x02000000>;
+
+ };
+
+ i2c0: i2c@18038000 {
+ compatible = "iproc-smb";
+ reg = <0x18038000 0x1000>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ interrupts = < 127 >;
+ clock-frequency = <400000>;
+ rtc@68 {
+ compatible = "m41st85";
+ reg = <0x68>;
+ };
+ };
+
+
+ i2c1: i2c@1803b000 {
+ compatible = "iproc-smb";
+ reg = <0x1803b000 0x1000>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ interrupts = < 128 >;
+ clock-frequency = <100000>;
+
+ };
+};
diff --git a/arch/arm/mach-iproc/Kconfig b/arch/arm/mach-iproc/Kconfig
index c77208d..c6a87fc 100644
--- a/arch/arm/mach-iproc/Kconfig
+++ b/arch/arm/mach-iproc/Kconfig
@@ -49,6 +49,12 @@ config MACH_ACCTON_AS4610_54
help
Support for Accton AS4610-54 POE and non -POE board.
+config MACH_DELTA_AG6248C
+ select ARM_L1_CACHE_SHIFT_6
+ bool "Support Delta AG6248C board"
+ help
+ Support for Delta AG6248C board.
+
config MACH_IPROC_P7
bool "Support iProc Profile 7 architecture"
depends on MACH_GH
diff --git a/arch/arm/mach-iproc/board_bu.c b/arch/arm/mach-iproc/board_bu.c
index 7e07ed1..5479020 100644
--- a/arch/arm/mach-iproc/board_bu.c
+++ b/arch/arm/mach-iproc/board_bu.c
@@ -1083,6 +1083,7 @@ MACHINE_END
static const char * helix4_dt_board_compat[] = {
"dni,dni_3448p",
"accton,as4610_54",
+ "delta,ag6248c",
NULL
};
diff --git a/arch/arm/mach-iproc/common.c b/arch/arm/mach-iproc/common.c
index b116ffc..e911a2b 100644
--- a/arch/arm/mach-iproc/common.c
+++ b/arch/arm/mach-iproc/common.c
@@ -187,7 +187,8 @@ static struct platform_device wdt_device =
enum {
HX4_NONE = 0,
HX4_DNI_3448P,
- HX4_ACCTON_AS4610_54
+ HX4_ACCTON_AS4610_54,
+ HX4_DELTA_AG6248C,
};
/*
@@ -212,6 +213,8 @@ int brcm_get_hx4_model(void)
return HX4_DNI_3448P;
else if (!strcmp(model, "accton,as4610_54"))
return HX4_ACCTON_AS4610_54;
+ else if (!strcmp(model, "delta,ag6248c"))
+ return HX4_DELTA_AG6248C;
printk( KERN_ERR "Unknown Model %s\n", model );
return HX4_NONE;
diff --git a/arch/arm/mach-iproc/include/mach/iproc_regs.h b/arch/arm/mach-iproc/include/mach/iproc_regs.h
index 460c436..50ea557 100644
--- a/arch/arm/mach-iproc/include/mach/iproc_regs.h
+++ b/arch/arm/mach-iproc/include/mach/iproc_regs.h
@@ -364,7 +364,11 @@
#define IPROC_GMAC3_INT 182
#elif (defined(CONFIG_MACH_HX4) || defined(CONFIG_MACH_KT2) || defined(CONFIG_MACH_DNI_3448P) || \
defined(CONFIG_MACH_ACCTON_AS4610_54))
+#if defined(CONFIG_MACH_DELTA_AG6248C)
+#define IPROC_NUM_GMACS 1
+#else
#define IPROC_NUM_GMACS 2
+#endif
#define IPROC_GMAC0_REG_BASE (GMAC0_DEVCONTROL) //(0x18022000)
#define IPROC_GMAC1_REG_BASE (GMAC1_DEVCONTROL) //(0x18023000)
#define IPROC_GMAC2_REG_BASE (0) // n/a
diff --git a/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c b/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c
index d5b400d..a823697 100644
--- a/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c
+++ b/drivers/bcmdrivers/gmac/src/shared/nvramstubs.c
@@ -143,7 +143,8 @@ __setup("envaddr=", envaddr_setup);
enum {
HX4_NONE = 0,
HX4_DNI_3448P,
- HX4_ACCTON_AS4610_54
+ HX4_ACCTON_AS4610_54,
+ HX4_DELTA_AG6248C
};
static void
@@ -158,7 +159,10 @@ setup_uboot_vars(void) {
} else if (modelnum == HX4_ACCTON_AS4610_54) {
env_offset = 0x000f0000;
uboot_vars_start = CONFIG_SPI_BASE + env_offset;
- }
+ }else if (modelnum == HX4_DELTA_AG6248C) {
+ env_offset = 0x00300000;
+ uboot_vars_start = CONFIG_NAND_BASE + env_offset;
+ }
}
/*
--
2.1.4

View File

@@ -506,4 +506,3 @@ scripts_package_Makefile.patch
tools_include_tools_be_byteshift.h.patch
tools_include_tools_le_byteshift.h.patch
platform-accton-as4610-device-drivers.patch
platform-delta-ag6248c-device-drivers.patch

View File

@@ -1 +0,0 @@
include $(ONL)/make/pkg.mk

View File

@@ -1 +0,0 @@
include $(ONL)/make/pkg.mk

View File

@@ -1,25 +0,0 @@
#How to run ONL in DELTA AG6248C board
For the first step, it only support install the ONL to the USB and boot up.
It will be support to install the ONL to NandFlash next step.
Build the ONL
--------------------------------------------------------------------------
Please refer the $ONL/docs/Building.md
Install the ONL through ONIE
--------------------------------------------------------------------------
```
ONIE:/ # onie-discovery-stop
discover: installer mode detected.
Stopping: discover... done.
ONIE:/ #
ONIE:/ # ifconfig eth0 192.168.1.1 #configure the DUT IP address
ONIE:/ # tftp -r ONL-2.*_ARMEL_INSTALLED_INSTALLER -g 192.168.1.99 -b 10240
ONIE:/ # onie-nos-install ONL-2.*_ARMEL_INSTALLED_INSTALLER
```
Boot the ONL
--------------------------------------------------------------------------
Device will reboot automatically after install the ONL installer successfull.
Now it will start the ONL boot progress.

View File

@@ -1,2 +0,0 @@
*x86*64*cel*redstone*xp*.mk
onlpdump.mk

View File

@@ -1 +0,0 @@
include $(ONL)/make/pkg.mk

View File

@@ -1 +0,0 @@
include $(ONL)/make/pkg.mk

View File

@@ -1 +0,0 @@
!include $ONL_TEMPLATES/platform-modules.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c KERNELS="onl-kernel-3.2-lts-arm-iproc-all:armel"

View File

@@ -1,6 +0,0 @@
KERNELS := onl-kernel-3.2-lts-arm-iproc-all:armel
KMODULES := $(wildcard *.c)
VENDOR := delta
BASENAME := arm-delta-ag6248c
ARCH := arm
include $(ONL)/make/kmodule.mk

View File

@@ -1,242 +0,0 @@
/*
* An I2C multiplexer dirver for delta as5812 CPLD
*
* Copyright (C) 2017 Delta Networks, Inc.
* Brandon Chuang <brandon_chuang@delta.com.tw>
*
* This module supports the delta cpld that hold the channel select
* mechanism for other i2c slave devices, such as SFP.
* This includes the:
* Delta ag7648c CPLD1/CPLD2/CPLD3
*
* Based on:
* pca954x.c from Kumar Gala <galak@kernel.crashing.org>
* Copyright (C) 2006
*
* Based on:
* pca954x.c from Ken Harrenstien
* Copyright (C) 2004 Google, Inc. (Ken Harrenstien)
*
* Based on:
* i2c-virtual_cb.c from Brian Kuschak <bkuschak@yahoo.com>
* and
* pca9540.c from Jean Delvare <khali@linux-fr.org>.
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/i2c-mux.h>
#include <linux/version.h>
#define CTRL_CPLD_BUS 0x0
#define CTRL_CPLD_I2C_ADDR 0x28
#define PARENT_CHAN 0x0
#define NUM_OF_CPLD_CHANS 0x2
#define CPLD_CHANNEL_SELECT_REG 0x19
#define CPLD_CHANNEL_SELECT_MASK 0x3
#define CPLD_CHANNEL_SELECT_OFFSET 0x0
#define CPLD_DESELECT_CHANNEL 0xff
#define CPLD_MUX_MAX_NCHANS 0x2
enum cpld_mux_type {
delta_cpld_mux
};
struct delta_i2c_cpld_mux {
enum cpld_mux_type type;
struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS];
u8 last_chan; /* last register value */
};
struct chip_desc {
u8 nchans;
u8 deselectChan;
};
/* Provide specs for the PCA954x types we know about */
static const struct chip_desc chips[] = {
[delta_cpld_mux] = {
.nchans = NUM_OF_CPLD_CHANS,
.deselectChan = CPLD_DESELECT_CHANNEL,
}
};
static struct delta_i2c_cpld_mux *cpld_mux_data;
static struct device dump_dev;
/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer()
for this as they will try to lock adapter a second time */
static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap,
struct i2c_client *client, u8 val)
{
unsigned long orig_jiffies;
unsigned short flags;
union i2c_smbus_data data;
struct i2c_adapter *ctrl_adap;
int try;
s32 res = -EIO;
u8 reg_val = 0;
data.byte = val;
flags = 0;
ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS);
if (!ctrl_adap)
return res;
// try to lock it
if (ctrl_adap->algo->smbus_xfer) {
/* Retry automatically on arbitration loss */
orig_jiffies = jiffies;
for (res = 0, try = 0; try <= ctrl_adap->retries; try++) {
// read first
res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags,
I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG,
I2C_SMBUS_BYTE_DATA, &data);
if (res && res != -EAGAIN)
break;
// modify the field we wanted
data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET);
reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET);
data.byte |= reg_val;
// modify the register
res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags,
I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG,
I2C_SMBUS_BYTE_DATA, &data);
if (res && res != -EAGAIN)
break;
if (time_after(jiffies,
orig_jiffies + ctrl_adap->timeout))
break;
}
}
return res;
}
static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap,
void *client, u32 chan)
{
u8 regval;
int ret = 0;
regval = chan;
/* Only select the channel if its different from the last channel */
if (cpld_mux_data->last_chan != regval) {
ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval);
cpld_mux_data->last_chan = regval;
}
return ret;
}
static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap,
void *client, u32 chan)
{
/* Deselect active channel */
cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan;
return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan);
}
/*
* I2C init/probing/exit functions
*/
static int __delta_i2c_cpld_mux_init(void)
{
struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN);
int chan=0;
int ret = -ENODEV;
memset (&dump_dev, 0, sizeof(dump_dev));
if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE))
goto err;
if (!adap)
goto err;
cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL);
if (!cpld_mux_data) {
ret = -ENOMEM;
goto err;
}
cpld_mux_data->type = delta_cpld_mux;
cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */
/* Now create an adapter for each channel */
for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) {
cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0,
chan,
delta_i2c_cpld_mux_select_chan,
delta_i2c_cpld_mux_deselect_mux);
if (cpld_mux_data->virt_adaps[chan] == NULL) {
ret = -ENODEV;
printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN);
goto virt_reg_failed;
}
}
printk("registered %d multiplexed busses for I2C mux bus %d\n",
chan, PARENT_CHAN);
return 0;
virt_reg_failed:
for (chan--; chan >= 0; chan--) {
i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]);
}
kfree(cpld_mux_data);
err:
return ret;
}
static int __delta_i2c_cpld_mux_remove(void)
{
const struct chip_desc *chip = &chips[cpld_mux_data->type];
int chan;
for (chan = 0; chan < chip->nchans; ++chan) {
if (cpld_mux_data->virt_adaps[chan]) {
i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]);
cpld_mux_data->virt_adaps[chan] = NULL;
}
}
kfree(cpld_mux_data);
return 0;
}
static int __init delta_i2c_cpld_mux_init(void)
{
return __delta_i2c_cpld_mux_init ();
}
static void __exit delta_i2c_cpld_mux_exit(void)
{
__delta_i2c_cpld_mux_remove ();
}
MODULE_AUTHOR("Dave Hu <dave.hu@deltasystems.com>");
MODULE_DESCRIPTION("Delta I2C CPLD mux driver");
MODULE_LICENSE("GPL");
module_init(delta_i2c_cpld_mux_init);
module_exit(delta_i2c_cpld_mux_exit);

View File

@@ -1,243 +0,0 @@
/*
* An I2C multiplexer dirver for delta as5812 CPLD
*
* Copyright (C) 2017 Delta Networks, Inc.
* Brandon Chuang <brandon_chuang@delta.com.tw>
*
* This module supports the delta cpld that hold the channel select
* mechanism for other i2c slave devices, such as SFP.
* This includes the:
* Delta ag7648c CPLD1/CPLD2/CPLD3
*
* Based on:
* pca954x.c from Kumar Gala <galak@kernel.crashing.org>
* Copyright (C) 2006
*
* Based on:
* pca954x.c from Ken Harrenstien
* Copyright (C) 2004 Google, Inc. (Ken Harrenstien)
*
* Based on:
* i2c-virtual_cb.c from Brian Kuschak <bkuschak@yahoo.com>
* and
* pca9540.c from Jean Delvare <khali@linux-fr.org>.
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/i2c-mux.h>
#include <linux/version.h>
#define CTRL_CPLD_BUS 0x0
#define CTRL_CPLD_I2C_ADDR 0x28
#define PARENT_CHAN 0x1
#define NUM_OF_CPLD_CHANS 0x2
#define CPLD_CHANNEL_SELECT_REG 0x19
#define CPLD_CHANNEL_SELECT_MASK 0x3
#define CPLD_CHANNEL_SELECT_OFFSET 0x5
#define CPLD_DESELECT_CHANNEL 0xff
#define CPLD_MUX_MAX_NCHANS 0x2
enum cpld_mux_type {
delta_cpld_mux
};
struct delta_i2c_cpld_mux {
enum cpld_mux_type type;
struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS];
u8 last_chan; /* last register value */
};
struct chip_desc {
u8 nchans;
u8 deselectChan;
};
/* Provide specs for the PCA954x types we know about */
static const struct chip_desc chips[] = {
[delta_cpld_mux] = {
.nchans = NUM_OF_CPLD_CHANS,
.deselectChan = CPLD_DESELECT_CHANNEL,
}
};
static struct delta_i2c_cpld_mux *cpld_mux_data;
static struct device dump_dev;
/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer()
for this as they will try to lock adapter a second time */
static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap,
struct i2c_client *client, u8 val)
{
unsigned long orig_jiffies;
unsigned short flags;
union i2c_smbus_data data;
struct i2c_adapter *ctrl_adap;
int try;
s32 res = -EIO;
u8 reg_val = 0;
data.byte = val;
flags = 0;
ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS);
if (!ctrl_adap)
return res;
// try to lock it
if (ctrl_adap->algo->smbus_xfer) {
/* Retry automatically on arbitration loss */
orig_jiffies = jiffies;
for (res = 0, try = 0; try <= ctrl_adap->retries; try++) {
// read first
res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags,
I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG,
I2C_SMBUS_BYTE_DATA, &data);
if (res && res != -EAGAIN)
break;
// modify the field we wanted
data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET);
reg_val |= ((val & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET);
data.byte |= reg_val;
// modify the register
res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags,
I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG,
I2C_SMBUS_BYTE_DATA, &data);
if (res != -EAGAIN)
break;
if (time_after(jiffies,
orig_jiffies + ctrl_adap->timeout))
break;
}
}
return res;
}
static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap,
void *client, u32 chan)
{
u8 regval;
int ret = 0;
regval = chan;
/* Only select the channel if its different from the last channel */
if (cpld_mux_data->last_chan != regval) {
ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval);
cpld_mux_data->last_chan = regval;
}
return ret;
}
static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap,
void *client, u32 chan)
{
/* Deselect active channel */
cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan;
return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan);
}
/*
* I2C init/probing/exit functions
*/
static int __delta_i2c_cpld_mux_init(void)
{
struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN);
int chan=0;
int ret = -ENODEV;
memset (&dump_dev, 0, sizeof(dump_dev));
if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE))
goto err;
if (!adap)
goto err;
cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL);
if (!cpld_mux_data) {
ret = -ENOMEM;
goto err;
}
cpld_mux_data->type = delta_cpld_mux;
cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */
/* Now create an adapter for each channel */
for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) {
cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0,
chan,
delta_i2c_cpld_mux_select_chan,
delta_i2c_cpld_mux_deselect_mux);
if (cpld_mux_data->virt_adaps[chan] == NULL) {
ret = -ENODEV;
printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN);
goto virt_reg_failed;
}
}
printk("registered %d multiplexed busses for I2C mux bus %d\n",
chan, PARENT_CHAN);
return 0;
virt_reg_failed:
for (chan--; chan >= 0; chan--) {
i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]);
}
kfree(cpld_mux_data);
err:
return ret;
}
static int __delta_i2c_cpld_mux_remove(void)
{
const struct chip_desc *chip = &chips[cpld_mux_data->type];
int chan;
for (chan = 0; chan < chip->nchans; ++chan) {
if (cpld_mux_data->virt_adaps[chan]) {
i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]);
cpld_mux_data->virt_adaps[chan] = NULL;
}
}
kfree(cpld_mux_data);
return 0;
}
static int __init delta_i2c_cpld_mux_init(void)
{
return __delta_i2c_cpld_mux_init ();
}
static void __exit delta_i2c_cpld_mux_exit(void)
{
__delta_i2c_cpld_mux_remove ();
}
MODULE_AUTHOR("Dave Hu <dave.hu@deltasystems.com>");
MODULE_DESCRIPTION("Delta I2C CPLD mux driver");
MODULE_LICENSE("GPL");
module_init(delta_i2c_cpld_mux_init);
module_exit(delta_i2c_cpld_mux_exit);

View File

@@ -1 +0,0 @@
include $(ONL)/make/pkg.mk

View File

@@ -1 +0,0 @@
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=arm-delta-ag6248c ARCH=armel TOOLCHAIN=arm-linux-gnueabi

View File

@@ -1,2 +0,0 @@
FILTER=src
include $(ONL)/make/subdirs.mk

View File

@@ -1,44 +0,0 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# 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.
#
# </bsn.cl>
############################################################
#
#
############################################################
include $(ONL)/make/config.armel.mk
MODULE := libonlp-arm-delta-ag6248c
include $(BUILDER)/standardinit.mk
DEPENDMODULES := AIM IOF arm_delta_ag6248c onlplib
DEPENDMODULE_HEADERS := sff
include $(BUILDER)/dependmodules.mk
SHAREDLIB := libonlp-arm-delta-ag6248c.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

View File

@@ -1,10 +0,0 @@
###############################################################################
#
# Inclusive Makefile for the libonlp-arm-delta-ag6248c module.
#
# Autogenerated 2016-07-20 18:27:47.344268
#
###############################################################################
libonlp-arm-delta-ag6248c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))

View File

@@ -1,45 +0,0 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# 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.
#
# </bsn.cl>
############################################################
#
#
#
############################################################
include $(ONL)/make/config.armel.mk
.DEFAULT_GOAL := onlpdump
MODULE := onlpdump
include $(BUILDER)/standardinit.mk
DEPENDMODULES := AIM IOF onlp arm_delta_ag6248c 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

View File

@@ -1 +0,0 @@
!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=armel VENDOR=delta BASENAME=arm-delta-ag6248c REVISION=r0

View File

@@ -1,43 +0,0 @@
---
######################################################################
#
# platform-config for AG6248C
#
######################################################################
arm-delta-ag6248c-r0:
flat_image_tree:
kernel:
<<: *arm-iproc-kernel
dtb:
=: delta_ag6248c.dtb
<<: *arm-iproc-kernel-package
itb:
<<: *arm-itb
loader:
device: /dev/mtdblock4
loadaddr: 0x70000000
nos_bootcmds: *flash_bootcmds
environment:
- device: /dev/mtd2
env_offset: 0x00000000
env_size: 0x00002000
sector_size: 0x00010000
installer:
- ONL-BOOT:
=: 128MiB
format: ubifs
- ONL-CONFIG:
=: 128MiB
format: ubifs
- ONL-IMAGES:
=: 1024MiB
format: ubifs
- ONL-DATA:
=: 2048MiB
format: ubifs

View File

@@ -1,23 +0,0 @@
from onl.platform.base import *
from onl.platform.delta import *
class OnlPlatform_arm_delta_ag6248c_r0(OnlPlatformDelta,OnlPlatformPortConfig_48x1_2x10):
PLATFORM='arm-delta-ag6248c-r0'
MODEL="AG6248C"
SYS_OBJECT_ID=".6248.2"
def baseconfig(self):
self.insmod('arm-delta-ag6248c-cpld-mux-1.ko')
self.insmod('arm-delta-ag6248c-cpld-mux-2.ko')
self.new_i2c_devices(
[
# initiate lm75
('tmp75', 0x49, 0),
('tmp75', 0x4a, 0),
]
)
return True

View File

@@ -1,2 +0,0 @@
/arm_delta_ag6248c_poe.mk
/doc

View File

@@ -1 +0,0 @@
name: arm_delta_ag6248c

View File

@@ -1,28 +0,0 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch Networks, Inc.
#
# Licensed under the Eclipse Public License, Version 1.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.eclipse.org/legal/epl-v10.html
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the
# License.
#
# </bsn.cl>
############################################################
#
#
#
############################################################
include $(ONL)/make/config.mk
MODULE := arm_delta_ag6248c
AUTOMODULE := arm_delta_ag6248c
include $(BUILDER)/definemodule.mk

View File

@@ -1,13 +0,0 @@
###############################################################################
#
# Inclusive Makefile for the arm_delta_ag6248c module.
#
# Autogenerated 2017-02-16 14:19:33.628446
#
###############################################################################
arm_delta_ag6248c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(arm_delta_ag6248c_BASEDIR)module/make.mk
include $(arm_delta_ag6248c_BASEDIR)module/auto/make.mk
include $(arm_delta_ag6248c_BASEDIR)module/src/make.mk

View File

@@ -1,67 +0,0 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch Networks, Inc.
#
# Licensed under the Eclipse Public License, Version 1.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.eclipse.org/legal/epl-v10.html
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the
# License.
#
# </bsn.cl>
############################################################
#
#
############################################################
cdefs: &cdefs
- ONLPSIM_CONFIG_INCLUDE_LOGGING:
doc: "Include or exclude logging."
default: 1
- ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT:
doc: "Default enabled log options."
default: AIM_LOG_OPTIONS_DEFAULT
- ONLPSIM_CONFIG_LOG_BITS_DEFAULT:
doc: "Default enabled log bits."
default: AIM_LOG_BITS_DEFAULT
- ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
doc: "Default enabled custom log bits."
default: 0
- ONLPSIM_CONFIG_PORTING_STDLIB:
doc: "Default all porting macros to use the C standard libraries."
default: 1
- ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
doc: "Include standard library headers for stdlib porting macros."
default: ONLPSIM_CONFIG_PORTING_STDLIB
- ONLPSIM_CONFIG_INCLUDE_UCLI:
doc: "Include generic uCli support."
default: 0
- ONLPSIM_CONFIG_SFP_COUNT:
doc: "SFP Count."
default: 0
definitions:
cdefs:
ONLPSIM_CONFIG_HEADER:
defs: *cdefs
basename: arm_delta_ag6248c_config
portingmacro:
ONLPSIM:
macros:
- malloc
- free
- memset
- memcpy
- strncpy
- vsnprintf
- snprintf
- strlen

View File

@@ -1,28 +0,0 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch Networks, Inc.
#
# Licensed under the Eclipse Public License, Version 1.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.eclipse.org/legal/epl-v10.html
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the
# License.
#
# </bsn.cl>
############################################################
#
#
############################################################
arm_delta_ag6248c_AUTO_DEFS := module/auto/arm_delta_ag6248c.yml
arm_delta_ag6248c_AUTO_DIRS := module/inc/arm_delta_ag6248c module/src
include $(BUILDER)/auto.mk

View File

@@ -1,34 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <arm_delta_ag6248c/arm_delta_ag6248c_config.h>
/* <--auto.start.xmacro(ALL).define> */
/* <auto.end.xmacro(ALL).define> */
/* <--auto.start.xenum(ALL).define> */
/* <auto.end.xenum(ALL).define> */

View File

@@ -1,162 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
/**************************************************************************//**
*
* @file
* @brief arm_delta_ag6248c Configuration Header
*
* @addtogroup arm_delta_ag6248c-config
* @{
*
*****************************************************************************/
#ifndef __ONLPSIM_CONFIG_H__
#define __ONLPSIM_CONFIG_H__
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
#include <global_custom_config.h>
#endif
#ifdef ONLPSIM_INCLUDE_CUSTOM_CONFIG
#include <arm_delta_ag6248c_custom_config.h>
#endif
/* <auto.start.cdefs(ONLPSIM_CONFIG_HEADER).header> */
#include <AIM/aim.h>
/**
* ONLPSIM_CONFIG_INCLUDE_LOGGING
*
* Include or exclude logging. */
#ifndef ONLPSIM_CONFIG_INCLUDE_LOGGING
#define ONLPSIM_CONFIG_INCLUDE_LOGGING 1
#endif
/**
* ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT
*
* Default enabled log options. */
#ifndef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT
#define ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
#endif
/**
* ONLPSIM_CONFIG_LOG_BITS_DEFAULT
*
* Default enabled log bits. */
#ifndef ONLPSIM_CONFIG_LOG_BITS_DEFAULT
#define ONLPSIM_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
#endif
/**
* ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT
*
* Default enabled custom log bits. */
#ifndef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT
#define ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
#endif
/**
* ONLPSIM_CONFIG_PORTING_STDLIB
*
* Default all porting macros to use the C standard libraries. */
#ifndef ONLPSIM_CONFIG_PORTING_STDLIB
#define ONLPSIM_CONFIG_PORTING_STDLIB 1
#endif
/**
* ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
*
* Include standard library headers for stdlib porting macros. */
#ifndef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
#define ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS ONLPSIM_CONFIG_PORTING_STDLIB
#endif
/**
* ONLPSIM_CONFIG_INCLUDE_UCLI
*
* Include generic uCli support. */
#ifndef ONLPSIM_CONFIG_INCLUDE_UCLI
#define ONLPSIM_CONFIG_INCLUDE_UCLI 0
#endif
/**
* ONLPSIM_CONFIG_SFP_COUNT
*
* SFP Count. */
#ifndef ONLPSIM_CONFIG_SFP_COUNT
#define ONLPSIM_CONFIG_SFP_COUNT 0
#endif
/**
* All compile time options can be queried or displayed
*/
/** Configuration settings structure. */
typedef struct arm_delta_ag6248c_config_settings_s {
/** name */
const char* name;
/** value */
const char* value;
} arm_delta_ag6248c_config_settings_t;
/** Configuration settings table. */
/** arm_delta_ag6248c_config_settings table. */
extern arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[];
/**
* @brief Lookup a configuration setting.
* @param setting The name of the configuration option to lookup.
*/
const char* arm_delta_ag6248c_config_lookup(const char* setting);
/**
* @brief Show the compile-time configuration.
* @param pvs The output stream.
*/
int arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs);
/* <auto.end.cdefs(ONLPSIM_CONFIG_HEADER).header> */
#include "arm_delta_ag6248c_porting.h"
#endif /* __ONLPSIM_CONFIG_H__ */
/* @} */

View File

@@ -1,51 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
/********************************************************//**
*
* arm_delta_ag6248c Doxygen Header
*
***********************************************************/
#ifndef __ONLPSIM_DOX_H__
#define __ONLPSIM_DOX_H__
/**
* @defgroup arm_delta_ag6248c arm_delta_ag6248c - onlpsim Description
*
The documentation overview for this module should go here.
*
* @{
*
* @defgroup arm_delta_ag6248c-arm_delta_ag6248c Public Interface
* @defgroup arm_delta_ag6248c-config Compile Time Configuration
* @defgroup arm_delta_ag6248c-porting Porting Macros
*
* @}
*
*/
#endif /* __ONLPSIM_DOX_H__ */

View File

@@ -1,132 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
/********************************************************//**
*
* @file
* @brief arm_delta_ag6248c Porting Macros.
*
* @addtogroup arm_delta_ag6248c-porting
* @{
*
***********************************************************/
#ifndef __ONLPSIM_PORTING_H__
#define __ONLPSIM_PORTING_H__
/* <auto.start.portingmacro(ALL).define> */
#if ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <memory.h>
#endif
#ifndef ONLPSIM_MALLOC
#if defined(GLOBAL_MALLOC)
#define ONLPSIM_MALLOC GLOBAL_MALLOC
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_MALLOC malloc
#else
#error The macro ONLPSIM_MALLOC is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_FREE
#if defined(GLOBAL_FREE)
#define ONLPSIM_FREE GLOBAL_FREE
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_FREE free
#else
#error The macro ONLPSIM_FREE is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_MEMSET
#if defined(GLOBAL_MEMSET)
#define ONLPSIM_MEMSET GLOBAL_MEMSET
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_MEMSET memset
#else
#error The macro ONLPSIM_MEMSET is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_MEMCPY
#if defined(GLOBAL_MEMCPY)
#define ONLPSIM_MEMCPY GLOBAL_MEMCPY
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_MEMCPY memcpy
#else
#error The macro ONLPSIM_MEMCPY is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_STRNCPY
#if defined(GLOBAL_STRNCPY)
#define ONLPSIM_STRNCPY GLOBAL_STRNCPY
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_STRNCPY strncpy
#else
#error The macro ONLPSIM_STRNCPY is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_VSNPRINTF
#if defined(GLOBAL_VSNPRINTF)
#define ONLPSIM_VSNPRINTF GLOBAL_VSNPRINTF
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_VSNPRINTF vsnprintf
#else
#error The macro ONLPSIM_VSNPRINTF is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_SNPRINTF
#if defined(GLOBAL_SNPRINTF)
#define ONLPSIM_SNPRINTF GLOBAL_SNPRINTF
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_SNPRINTF snprintf
#else
#error The macro ONLPSIM_SNPRINTF is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_STRLEN
#if defined(GLOBAL_STRLEN)
#define ONLPSIM_STRLEN GLOBAL_STRLEN
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_STRLEN strlen
#else
#error The macro ONLPSIM_STRLEN is required but cannot be defined.
#endif
#endif
/* <auto.end.portingmacro(ALL).define> */
#endif /* __ONLPSIM_PORTING_H__ */
/* @} */

View File

@@ -1,29 +0,0 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch Networks, Inc.
#
# Licensed under the Eclipse Public License, Version 1.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.eclipse.org/legal/epl-v10.html
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the
# License.
#
# </bsn.cl>
############################################################
#
#
#
############################################################
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
arm_delta_ag6248c_INCLUDES := -I $(THIS_DIR)inc
arm_delta_ag6248c_INTERNAL_INCLUDES := -I $(THIS_DIR)src
arm_delta_ag6248c_DEPENDMODULE_ENTRIES := init:arm_delta_ag6248c ucli:arm_delta_ag6248c

View File

@@ -1,30 +0,0 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch Networks, Inc.
#
# Licensed under the Eclipse Public License, Version 1.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.eclipse.org/legal/epl-v10.html
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the
# License.
#
# </bsn.cl>
############################################################
#
# Local source generation targets.
#
############################################################
include ../../../../init.mk
ucli:
$(SUBMODULE_BIGCODE)/tools/uclihandlers.py arm_delta_ag6248c_ucli.c

View File

@@ -1,101 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <arm_delta_ag6248c/arm_delta_ag6248c_config.h>
/* <auto.start.cdefs(ONLPSIM_CONFIG_HEADER).source> */
#define __arm_delta_ag6248c_config_STRINGIFY_NAME(_x) #_x
#define __arm_delta_ag6248c_config_STRINGIFY_VALUE(_x) __arm_delta_ag6248c_config_STRINGIFY_NAME(_x)
arm_delta_ag6248c_config_settings_t arm_delta_ag6248c_config_settings[] =
{
#ifdef ONLPSIM_CONFIG_INCLUDE_LOGGING
{ __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_LOGGING), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_LOGGING) },
#else
{ ONLPSIM_CONFIG_INCLUDE_LOGGING(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT
{ __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT) },
#else
{ ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_LOG_BITS_DEFAULT
{ __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_BITS_DEFAULT) },
#else
{ ONLPSIM_CONFIG_LOG_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT
{ __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
#else
{ ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_PORTING_STDLIB
{ __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_STDLIB), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_STDLIB) },
#else
{ ONLPSIM_CONFIG_PORTING_STDLIB(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
{ __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
#else
{ ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_INCLUDE_UCLI
{ __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_UCLI), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_UCLI) },
#else
{ ONLPSIM_CONFIG_INCLUDE_UCLI(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_SFP_COUNT
{ __arm_delta_ag6248c_config_STRINGIFY_NAME(ONLPSIM_CONFIG_SFP_COUNT), __arm_delta_ag6248c_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_SFP_COUNT) },
#else
{ ONLPSIM_CONFIG_SFP_COUNT(__arm_delta_ag6248c_config_STRINGIFY_NAME), "__undefined__" },
#endif
{ NULL, NULL }
};
#undef __arm_delta_ag6248c_config_STRINGIFY_VALUE
#undef __arm_delta_ag6248c_config_STRINGIFY_NAME
const char*
arm_delta_ag6248c_config_lookup(const char* setting)
{
int i;
for(i = 0; arm_delta_ag6248c_config_settings[i].name; i++) {
if(strcmp(arm_delta_ag6248c_config_settings[i].name, setting)) {
return arm_delta_ag6248c_config_settings[i].value;
}
}
return NULL;
}
int
arm_delta_ag6248c_config_show(struct aim_pvs_s* pvs)
{
int i;
for(i = 0; arm_delta_ag6248c_config_settings[i].name; i++) {
aim_printf(pvs, "%s = %s\n", arm_delta_ag6248c_config_settings[i].name, arm_delta_ag6248c_config_settings[i].value);
}
return i;
}
/* <auto.end.cdefs(ONLPSIM_CONFIG_HEADER).source> */

View File

@@ -1,30 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <arm_delta_ag6248c/arm_delta_ag6248c_config.h>
/* <--auto.start.enum(ALL).source> */
/* <auto.end.enum(ALL).source> */

View File

@@ -1,32 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#ifndef __ONLPSIM_INT_H__
#define __ONLPSIM_INT_H__
#include <arm_delta_ag6248c/arm_delta_ag6248c_config.h>
#endif /* __ONLPSIM_INT_H__ */

View File

@@ -1,38 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <arm_delta_ag6248c/arm_delta_ag6248c_config.h>
#include "arm_delta_ag6248c_log.h"
/*
* arm_delta_ag6248c log struct.
*/
AIM_LOG_STRUCT_DEFINE(
ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT,
ONLPSIM_CONFIG_LOG_BITS_DEFAULT,
NULL, /* Custom log map */
ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT
);

View File

@@ -1,32 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#ifndef __ONLPSIM_LOG_H__
#define __ONLPSIM_LOG_H__
#define AIM_LOG_MODULE_NAME arm_delta_ag6248c
#include <AIM/aim_log.h>
#endif /* __ONLPSIM_LOG_H__ */

View File

@@ -1,44 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <arm_delta_ag6248c/arm_delta_ag6248c_config.h>
#include "arm_delta_ag6248c_log.h"
static int
datatypes_init__(void)
{
#define ONLPSIM_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
#include <arm_delta_ag6248c/arm_delta_ag6248c.x>
return 0;
}
void __arm_delta_ag6248c_module_init__(void)
{
AIM_LOG_STRUCT_REGISTER();
datatypes_init__();
}
int __onlp_platform_version__ = 1;

View File

@@ -1,82 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <arm_delta_ag6248c/arm_delta_ag6248c_config.h>
#if ONLPSIM_CONFIG_INCLUDE_UCLI == 1
#include <uCli/ucli.h>
#include <uCli/ucli_argparse.h>
#include <uCli/ucli_handler_macros.h>
static ucli_status_t
arm_delta_ag6248c_ucli_ucli__config__(ucli_context_t* uc)
{
UCLI_HANDLER_MACRO_MODULE_CONFIG(arm_delta_ag6248c)
}
/* <auto.ucli.handlers.start> */
/******************************************************************************
*
* These handler table(s) were autogenerated from the symbols in this
* source file.
*
*****************************************************************************/
static ucli_command_handler_f arm_delta_ag6248c_ucli_ucli_handlers__[] =
{
arm_delta_ag6248c_ucli_ucli__config__,
NULL
};
/******************************************************************************/
/* <auto.ucli.handlers.end> */
static ucli_module_t
arm_delta_ag6248c_ucli_module__ =
{
"arm_delta_ag6248c_ucli",
NULL,
arm_delta_ag6248c_ucli_ucli_handlers__,
NULL,
NULL,
};
ucli_node_t*
arm_delta_ag6248c_ucli_node_create(void)
{
ucli_node_t* n;
ucli_module_init(&arm_delta_ag6248c_ucli_module__);
n = ucli_node_create("arm_delta_ag6248c", NULL, &arm_delta_ag6248c_ucli_module__);
ucli_node_subnode_add(n, ucli_module_log_node_create("arm_delta_ag6248c"));
return n;
}
#else
void*
arm_delta_ag6248c_ucli_node_create(void)
{
return NULL;
}
#endif

View File

@@ -1,141 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta Networks, Inc
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include "arm_delta_ag6248c_log.h"
#include "arm_delta_i2c.h"
#include <onlplib/i2c.h>
struct i2c_device_info i2c_device_list[]={
{"RTC",0X0,0X68},
{"TMP1_CLOSE_TO_MAC",0X0,0X49},
{"TMP2_CLOSE_TO_PHY",0X0,0X4a},
{"CPLD",0X0,0X28},
{"FAN_ON_BOARD",0X1,0X2C},
{"CURT_MONTOR",0X1,0X40},
{"SFP1",0X2,0X50},
{"SFP2",0X3,0X50},
// -------------------------
{"PSU1_PMBUS",0X4,0X58},
{"PSU2_PMBUS",0X5,0X59},
{"PSU1_EEPROM",0X4,0X50},
{"PSU2_EEPROM",0X5,0X51},
// -------------------------
{"PSU1_PMBUS_POE",0X4,0X58},
{"PSU2_PMBUS_POE",0X5,0X58},
{"PSU1_EEPROM_POE",0X4,0X52},
{"PSU2_EEPROM_POE",0X5,0X52},
{NULL, -1,-1},
};
uint32_t i2c_flag=ONLP_I2C_F_FORCE;
i2c_device_info_t *i2c_dev_find_by_name (char *name)
{
i2c_device_info_t *i2c_dev = i2c_device_list;
if (name == NULL) return NULL;
while (i2c_dev->name) {
if (strcmp (name, i2c_dev->name) == 0) break;
++ i2c_dev;
}
if (i2c_dev->name == NULL) return NULL;
return i2c_dev;
}
int i2c_devname_read_byte (char *name, int reg)
{
int ret=-1;
i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name);
if(i2c_dev==NULL) return -1;
ret=onlp_i2c_readb (i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag);
return ret;
}
int i2c_devname_write_byte (char *name, int reg, int value)
{
int ret=-1;
i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name);
if(i2c_dev==NULL) return -1;
ret=onlp_i2c_writeb (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag);
return ret;
}
int i2c_devname_read_word (char *name, int reg)
{
int ret=-1;
i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name);
if(i2c_dev==NULL) return -1;
ret=onlp_i2c_readw (i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag);
return ret;
}
int i2c_devname_write_word (char *name, int reg, int value)
{
int ret=-1;
i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name);
if(i2c_dev==NULL) return -1;
ret=onlp_i2c_writew (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag);
return ret;
}
int i2c_devname_read_block (char *name, int reg, uint8_t *buff, int buff_size)
{
int ret = -1;
i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name);
if(i2c_dev==NULL) return -1;
ret = onlp_i2c_block_read (i2c_dev->i2cbus, i2c_dev->addr, reg, buff_size, buff, i2c_flag);
return ret;
}

View File

@@ -1,54 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************/
/* the i2c struct header*/
#ifndef __ARM_DELTA_I2C_H__
#define __ARM_DELTA_I2C_H__
#include "arm_delta_ag6248c_log.h"
struct i2c_device_info {
/*i2c device name*/
char *name;
char i2cbus;
char addr;
};
typedef struct i2c_device_info i2c_device_info_t;
extern struct i2c_device_info i2c_device_list[];
extern int i2c_devname_read_byte(char *name, int reg);
extern int i2c_devname_write_byte(char *name, int reg, int value);
extern int i2c_devname_read_word(char *name, int reg);
extern int i2c_devname_write_word(char *name, int reg, int value);
extern int i2c_devname_read_block (char *name, int reg, uint8_t *buff, int buff_size);
#endif

View File

@@ -1,470 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************
*
* Fan Platform Implementation Defaults.
*
***********************************************************/
#include <onlp/platformi/fani.h>
#include <unistd.h>
#include <fcntl.h>
#include "platform_lib.h"
#include "arm_delta_ag6248c_int.h"
#include "arm_delta_i2c.h"
#include <onlp/platformi/psui.h>
#define MAX_FAN_SPEED 12000
#define MAX_PSU_FAN_SPEED 23000
#define FILE_NAME_LEN 80
/* The MAX6639 registers, valid channel numbers: 0, 1 */
#define MAX6639_REG_STATUS 0x02
#define MAX6639_REG_FAN_CONFIG1(ch) (0x10 + 4*(ch-1))
#define MAX6639_REG_FAN_CNT(ch) (0x20 + (ch-1))
#define MAX6639_REG_TARGET_CNT(ch) (0x22 + (ch-1))
/*define the reg bit mask*/
#define MAX6639_REG_FAN_STATUS_BIT(ch) (0X02>>(ch-1))
#define MAX6639_FAN_CONFIG1_RPM_RANGE 0x03
#define MAX6639_FAN_PRESENT_REG (0x0c)
#define MAX6639_FAN_PRESENT_BIT (0x2)
#define MAX6639_FAN_GOOD_BIT (0x1)
#define FAN_FROM_REG(val) ((480000.0) / (val))
static int fan_initd=0;
enum onlp_fan_id
{
FAN_RESERVED = 0,
FAN_1_ON_MAIN_BOARD,
FAN_2_ON_MAIN_BOARD,
FAN_1_ON_PSU1,
FAN_1_ON_PSU2
};
#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \
{ \
{ ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \
ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \
(ONLP_FAN_CAPS_SET_PERCENTAGE |ONLP_FAN_CAPS_SET_RPM| 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 }, \
ONLP_FAN_STATUS_B2F | ONLP_FAN_STATUS_PRESENT, \
(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_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_psu_fan_val_to_rpm (int v)
{
int lf = (v & 0xffff);
int y, n;
y = lf & 0x7ff;
n = ((lf >> 11) & 0x1f);
return (y * (1 << n));
}
static int
_onlp_fan_board_init(void)
{
i2c_devname_write_byte("FAN_ON_BOARD", 0x03,0xfc);
i2c_devname_write_byte("FAN_ON_BOARD", 0x04,0x30);
i2c_devname_write_byte("FAN_ON_BOARD", 0x10,0x23);
i2c_devname_write_byte("FAN_ON_BOARD", 0x11,0x00);
i2c_devname_write_byte("FAN_ON_BOARD", 0x12,0x00);
i2c_devname_write_byte("FAN_ON_BOARD", 0x13,0x21);
i2c_devname_write_byte("FAN_ON_BOARD", 0x24,0xe8);
i2c_devname_write_byte("FAN_ON_BOARD", 0x14,0x23);
i2c_devname_write_byte("FAN_ON_BOARD", 0x15,0x00);
i2c_devname_write_byte("FAN_ON_BOARD", 0x16,0x00);
i2c_devname_write_byte("FAN_ON_BOARD", 0x17,0x21);
i2c_devname_write_byte("FAN_ON_BOARD", 0x25,0xe8);
fan_initd=1;
return ONLP_STATUS_OK;
}
static int
_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
{
int r_data,fan_good,fan_present,fan_fault;
/* init the fan on the board*/
if(fan_initd==0)
_onlp_fan_board_init();
/* get fan fault status (turn on when any one fails)*/
r_data= i2c_devname_read_byte("CPLD",MAX6639_FAN_PRESENT_REG);
if(r_data<0)
return ONLP_STATUS_E_INVALID;
fan_present = r_data & MAX6639_FAN_PRESENT_BIT;
if(!fan_present){
info->status |= ONLP_FAN_STATUS_PRESENT;
fan_good=r_data&MAX6639_FAN_GOOD_BIT;
if(fan_good)
info->status&=~ONLP_FAN_STATUS_FAILED;
else{
r_data = i2c_devname_read_byte("FAN_ON_BOARD", MAX6639_REG_STATUS);
if(r_data<0)
return ONLP_STATUS_E_INVALID;
fan_fault=r_data & MAX6639_REG_FAN_STATUS_BIT(local_id);
if(!fan_fault)
info->status &=~ ONLP_FAN_STATUS_FAILED;
else{
info->status |=ONLP_FAN_STATUS_FAILED;
info->rpm=0;
info->percentage=0;
goto mode;
}
}
}
else{
info->status &= ~ONLP_FAN_STATUS_PRESENT;
return ONLP_STATUS_OK;
}
/* get fan speed */
r_data = i2c_devname_read_byte("FAN_ON_BOARD", MAX6639_REG_FAN_CNT(local_id));
if(r_data<0)
return ONLP_STATUS_E_INVALID;
info->rpm = FAN_FROM_REG(r_data);
/* get speed percentage from rpm */
info->percentage = (info->rpm * 100.0) / MAX_FAN_SPEED;
mode:
if(info->percentage>100)
strcpy(info->model,"ONLP_FAN_MODE_LAST");
else if(info->percentage==100)
strcpy(info->model,"ONLP_FAN_MODE_MAX");
else if(info->percentage>=75&&info->percentage<100)
strcpy(info->model,"ONLP_FAN_MODE_FAST");
else if(info->percentage>=35&&info->percentage<75)
strcpy(info->model,"ONLP_FAN_MODE_NORMAL");
else if(info->percentage>0&&info->percentage<35)
strcpy(info->model,"ONLP_FAN_MODE_SLOW");
else if(info->percentage<=0)
strcpy(info->model,"ONLP_FAN_MODE_OFF");
else{ }
return ONLP_STATUS_OK;
}
static int
_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
{
int psu_id;
int r_data,fan_rpm;
int psu_present;
int psu_good;
psu_type_t psu_type;
enum ag6248c_product_id pid = get_product_id();
/* get fan fault status
*/
psu_id = (local_id - FAN_1_ON_PSU1) + 1;
DEBUG_PRINT("[Debug][%s][%d][psu_id: %d]\n", __FUNCTION__, __LINE__, psu_id);
psu_type = get_psu_type(psu_id); /* psu_id = 1 , present PSU1. pus_id =2 , present PSU2 */
DEBUG_PRINT("[Debug][%s][%d][psu_type: %d]\n", __FUNCTION__, __LINE__, psu_type);
psu_present=psu_status_info_get(psu_id, "present");
psu_good=psu_status_info_get(psu_id, "good");
if((psu_present<=0)||(psu_good<=0)){
info->status &= ~ONLP_FAN_STATUS_PRESENT;
return ONLP_STATUS_OK;
}
switch (psu_type) {
case PSU_TYPE_AC_F2B:
info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B);
break;
case PSU_TYPE_AC_B2F:
info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F);
break;
default:
return ONLP_STATUS_E_UNSUPPORTED;
}
/* get fan speed*/
if(pid == PID_AG6248C_48){
if(psu_id==1)
r_data=i2c_devname_read_word("PSU1_PMBUS", 0x90);
else
r_data=i2c_devname_read_word("PSU2_PMBUS", 0x90);
}
else{
if(psu_id==1)
r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x90);
else
r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x90);
}
if(r_data<0)
return ONLP_STATUS_E_INVALID;
fan_rpm=_onlp_psu_fan_val_to_rpm(r_data);
info->rpm = fan_rpm;
/* get speed percentage from rpm */
info->percentage = (info->rpm * 100.0) / MAX_PSU_FAN_SPEED;
if(info->percentage>100)
strcpy(info->model,"ONLP_FAN_MODE_LAST");
else if(info->percentage==100)
strcpy(info->model,"ONLP_FAN_MODE_MAX");
else if(info->percentage>=75&&info->percentage<100)
strcpy(info->model,"ONLP_FAN_MODE_FAST");
else if(info->percentage>=35&&info->percentage<75)
strcpy(info->model,"ONLP_FAN_MODE_NORMAL");
else if(info->percentage>0&&info->percentage<35)
strcpy(info->model,"ONLP_FAN_MODE_SLOW");
else if(info->percentage<=0)
strcpy(info->model,"ONLP_FAN_MODE_OFF");
else{}
return ONLP_STATUS_OK;
}
/*
* This function will be called prior to all of onlp_fani_* functions.
*/
int
onlp_fani_init(void)
{
int rc;
rc=_onlp_fan_board_init();
return rc;
}
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);
if (chassis_fan_count() == 0) {
local_id += 1;
}
*info = linfo[local_id];
switch (local_id)
{
case FAN_1_ON_PSU1:
case FAN_1_ON_PSU2:
rc = _onlp_fani_info_get_fan_on_psu(local_id, info);
break;
case FAN_1_ON_MAIN_BOARD:
case FAN_2_ON_MAIN_BOARD:
rc =_onlp_fani_info_get_fan(local_id, info);
break;
default:
rc = ONLP_STATUS_E_INVALID;
break;
}
return rc;
}
/*
* This function sets the speed of the given fan in RPM.
*
* This function will only be called if the fan supprots the RPM_SET
* capability.
*
* It is optional if you have no fans at all with this feature.
*/
int
onlp_fani_rpm_set(onlp_oid_t id, int rpm)
{ /*
the rpm is the actual rpm/1000. so 16 represents the 16000(max spd)
*/
int fan_set_rpm_cont,rc;
int local_id;
int actual_rpm=rpm;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2))
return ONLP_STATUS_E_UNSUPPORTED;
if (chassis_fan_count() == 0) {
return ONLP_STATUS_E_INVALID;
}
/* init the fan on the board*/
if(fan_initd==0)
_onlp_fan_board_init();
/* reject rpm=0 (rpm=0, stop fan) */
if (actual_rpm == 0)
return ONLP_STATUS_E_INVALID;
/*get ret value for the speed set*/
fan_set_rpm_cont=FAN_FROM_REG(actual_rpm);
/*set the rpm speed */
rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont);
if(rc<0)
return ONLP_STATUS_E_INVALID;
return ONLP_STATUS_OK;
}
/*set the percentage for the psu fan*/
/*
* 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)
{
/*
p is between 0 and 100 ,p=100 represents 16000(max spd)
*/
int rpm_val,fan_set_rpm_cont,rc;
int local_id;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2))
return ONLP_STATUS_E_UNSUPPORTED;
if (chassis_fan_count() == 0) {
return ONLP_STATUS_E_INVALID;
}
/* init the fan on the board*/
if(fan_initd==0)
_onlp_fan_board_init();
/* reject p=0 (p=0, stop fan) */
if (p == 0){
return ONLP_STATUS_E_INVALID;
}
rpm_val=p*(MAX_FAN_SPEED/100);
/*get ret value for the speed set*/
fan_set_rpm_cont=FAN_FROM_REG(rpm_val);
/*set the rpm speed */
rc=i2c_devname_write_byte("FAN_ON_BOARD", MAX6639_REG_TARGET_CNT(local_id), fan_set_rpm_cont);
if(rc<0)
return ONLP_STATUS_E_INVALID;
return ONLP_STATUS_OK;
}
/*
* This function sets the fan speed of the given OID as per
* the predefined ONLP fan speed modes: off, slow, normal, fast, max.
*
* Interpretation of these modes is up to the platform.
*
*/
int
onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
/*
* This function sets the fan direction of the given OID.
*
* This function is only relevant if the fan OID supports both direction
* capabilities.
*
* This function is optional unless the functionality is available.
*/
int
onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
/*
* Generic fan ioctl. Optional.
*/
int
onlp_fani_ioctl(onlp_oid_t id, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -1,352 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <onlp/platformi/ledi.h>
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <onlplib/mmap.h>
#include "platform_lib.h"
#include "arm_delta_ag6248c_int.h"
#include "arm_delta_i2c.h"
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_LED(_id)) { \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
#define CPLD_LED_MODE_REG (0X0A)
#define CPLD_LED_MODE_TEMP_REG (0X0B)
#define CPLD_LED_MODE_REG_BIT(ch) (0x3<<2*((ch)-1))
#define CPLD_LED_MODE_TEMP_REG_BIT (0x0C)
#define CPLD_LED_MODE_MASTER_REG_BIT (0x02)
#define CPLD_LED_MODE_REG_OFFSET(ch) (2*((ch)-1))
#define CPLD_LED_MODE_TEMP_REG_OFFSET (2)
#define CPLD_LED_MODE_MASTER_REG_OFFSET (1)
/*
* Get the information for the given LED OID.
*/
static onlp_led_info_t linfo[] =
{
{ }, /* Not used */
{
{ ONLP_LED_ID_CREATE(LED_SYS), "sys", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_GREEN_BLINKING |ONLP_LED_CAPS_GREEN |
ONLP_LED_CAPS_RED_BLINKING | ONLP_LED_CAPS_RED ,
},
{
{ ONLP_LED_ID_CREATE(LED_FAN), "fan", 0 },
ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_ON_OFF |
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED,
},
{
{ ONLP_LED_ID_CREATE(LED_PSU2), "psu2", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_GREEN ,
},
{
{ ONLP_LED_ID_CREATE(LED_PSU1), "psu1", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_GREEN ,
},
{
{ ONLP_LED_ID_CREATE(LED_TEMP), "temp", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN |
ONLP_LED_CAPS_RED ,
},
{
{ ONLP_LED_ID_CREATE(LED_MASTER), "master", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN ,
},
};
static int conver_led_light_mode_to_onl(uint32_t id, int led_ligth_mode)
{
switch (id) {
case LED_SYS:
switch (led_ligth_mode) {
case SYS_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING;
case SYS_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN;
case SYS_LED_MODE_RED: return ONLP_LED_MODE_RED;
case SYS_LED_MODE_RED_BLINKING: return ONLP_LED_MODE_RED_BLINKING;
default: return ONLP_LED_MODE_OFF;
}
case LED_PSU1:
case LED_PSU2:
switch (led_ligth_mode) {
case PSU_LED_MODE_OFF: return ONLP_LED_MODE_OFF;
case PSU_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN;
case PSU_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING;
default: return ONLP_LED_MODE_OFF;
}
case LED_FAN:
switch (led_ligth_mode) {
case FAN_LED_MODE_OFF: return ONLP_LED_MODE_OFF;
case FAN_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN;
case FAN_LED_MODE_RED: return ONLP_LED_MODE_RED;
default: return ONLP_LED_MODE_OFF;
}
case LED_TEMP:
switch (led_ligth_mode) {
case TEMP_LED_MODE_OFF: return ONLP_LED_MODE_OFF;
case TEMP_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN;
case TEMP_LED_MODE_RED: return ONLP_LED_MODE_RED;
default: return ONLP_LED_MODE_OFF;
}
case LED_MASTER:
switch (led_ligth_mode) {
case MASTER_LED_MODE_OFF: return ONLP_LED_MODE_OFF;
case MASTER_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN;
default: return ONLP_LED_MODE_OFF;
}
}
return ONLP_LED_MODE_OFF;
}
static int conver_onlp_led_light_mode_to_driver(uint32_t id, int led_ligth_mode)
{
switch (id) {
case LED_SYS:
switch (led_ligth_mode) {
case ONLP_LED_MODE_GREEN_BLINKING: return SYS_LED_MODE_GREEN_BLINKING;
case ONLP_LED_MODE_GREEN: return SYS_LED_MODE_GREEN;
case ONLP_LED_MODE_RED: return SYS_LED_MODE_RED ;
case ONLP_LED_MODE_RED_BLINKING: return SYS_LED_MODE_RED_BLINKING;
default: return SYS_LED_MODE_UNKNOWN;
}
case LED_PSU1:
case LED_PSU2:
switch (led_ligth_mode) {
case ONLP_LED_MODE_OFF: return PSU_LED_MODE_OFF;
case ONLP_LED_MODE_GREEN: return PSU_LED_MODE_GREEN;
case ONLP_LED_MODE_GREEN_BLINKING: return PSU_LED_MODE_GREEN_BLINKING;
default: return PSU_LED_MODE_UNKNOWN;
}
case LED_FAN:
switch (led_ligth_mode) {
case ONLP_LED_MODE_OFF: return FAN_LED_MODE_OFF;
case ONLP_LED_MODE_GREEN: return FAN_LED_MODE_GREEN ;
case ONLP_LED_MODE_RED: return FAN_LED_MODE_RED;
default: return FAN_LED_MODE_UNKNOWN;
}
case LED_TEMP:
switch (led_ligth_mode) {
case ONLP_LED_MODE_OFF: return TEMP_LED_MODE_OFF;
case ONLP_LED_MODE_GREEN: return TEMP_LED_MODE_GREEN;
case ONLP_LED_MODE_RED: return TEMP_LED_MODE_RED;
default: return TEMP_LED_MODE_UNKNOWN;
}
case LED_MASTER:
switch (led_ligth_mode) {
case ONLP_LED_MODE_OFF: return MASTER_LED_MODE_OFF;
case ONLP_LED_MODE_GREEN: return MASTER_LED_MODE_GREEN;
default: return TEMP_LED_MODE_UNKNOWN;
}
}
return ONLP_LED_MODE_OFF;
}
/*
* This function will be called prior to any other onlp_ledi_* functions.
*/
int
onlp_ledi_init(void)
{
return ONLP_STATUS_OK;
}
static int
onlp_ledi_oid_to_internal_id(onlp_oid_t id)
{
enum ag6248c_product_id pid = get_product_id();
int lid = ONLP_OID_ID_GET(id);
if ((pid != PID_AG6248C_48P)||(pid != PID_AG6248C_48)) {
return lid;
}
switch (lid) {
case 1: return LED_SYS;
case 2: return LED_FAN;
case 3: return LED_PSU2;
case 4: return LED_PSU1;
case 5: return LED_TEMP;
case 6: return LED_MASTER;
}
return lid;
}
int
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
int r_data,m_data;
int lid = onlp_ledi_oid_to_internal_id(id);
VALIDATE(id);
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[lid];
if((lid==LED_TEMP)||(lid==LED_MASTER))
r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_TEMP_REG);
else
r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_REG);
if(r_data<0)
return ONLP_STATUS_E_INTERNAL;
if(lid==LED_TEMP)
m_data=(r_data & CPLD_LED_MODE_TEMP_REG_BIT);
else if(lid==LED_MASTER)
m_data=(r_data & CPLD_LED_MODE_MASTER_REG_BIT);
else
m_data=(r_data & CPLD_LED_MODE_REG_BIT(lid));
if(lid==LED_TEMP)
m_data=(m_data>> CPLD_LED_MODE_TEMP_REG_OFFSET);
else if(lid==LED_MASTER)
m_data=(m_data>> CPLD_LED_MODE_MASTER_REG_OFFSET);
else
m_data=(m_data>>CPLD_LED_MODE_REG_OFFSET(lid));
info->mode = conver_led_light_mode_to_onl(lid, m_data);
/* Set the on/off status */
if (info->mode != ONLP_LED_MODE_OFF) {
info->status |= ONLP_LED_STATUS_ON;
}
return ONLP_STATUS_OK;
}
/*
* 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 r_data,driver_mode, rc;
int lid = onlp_ledi_oid_to_internal_id(id);
VALIDATE(id);
driver_mode = conver_onlp_led_light_mode_to_driver(lid, mode);
if((driver_mode==SYS_LED_MODE_UNKNOWN)||(driver_mode==PSU_LED_MODE_UNKNOWN)||\
(driver_mode==FAN_LED_MODE_UNKNOWN)||(driver_mode==TEMP_LED_MODE_UNKNOWN)||\
(driver_mode==MASTER_LED_MODE_UNKNOWN))
return ONLP_STATUS_E_UNSUPPORTED;
if((lid==LED_TEMP)||(lid==LED_MASTER))
r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_TEMP_REG);
else
r_data=i2c_devname_read_byte("CPLD",CPLD_LED_MODE_REG);
if(r_data<0)
return ONLP_STATUS_E_INTERNAL;
if(lid==LED_TEMP)
r_data=r_data&(~CPLD_LED_MODE_TEMP_REG_BIT);
else if(lid==LED_MASTER)
r_data=r_data&(~CPLD_LED_MODE_MASTER_REG_BIT);
else
r_data=r_data&(~CPLD_LED_MODE_REG_BIT(lid));
if(lid==LED_TEMP)
driver_mode=(driver_mode<<CPLD_LED_MODE_TEMP_REG_OFFSET);
else if(lid==LED_MASTER)
driver_mode=(driver_mode<<CPLD_LED_MODE_MASTER_REG_OFFSET);
else
driver_mode=(driver_mode<<CPLD_LED_MODE_REG_OFFSET(lid));
driver_mode=driver_mode| r_data;
if((lid==LED_TEMP)||(lid==LED_MASTER))
rc=i2c_devname_write_byte("CPLD", CPLD_LED_MODE_TEMP_REG, driver_mode);
else
rc=i2c_devname_write_byte("CPLD", CPLD_LED_MODE_REG, driver_mode);
if(rc<0){
return ONLP_STATUS_E_INTERNAL;
}
return ONLP_STATUS_OK;
}
/*
* Turn an LED on or off.
*
* This function will only be called if the LED OID supports the ONOFF
* capability.
*
* What 'on' means in terms of colors or modes for multimode LEDs is
* up to the platform to decide. This is intended as baseline toggle mechanism.
*/
int
onlp_ledi_set(onlp_oid_t id, int on_or_off)
{
if (!on_or_off) {
return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF);
}
return ONLP_STATUS_E_UNSUPPORTED;
}
/*
* Generic LED ioctl interface.
*/
int
onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -1,29 +0,0 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch Networks, Inc.
#
# Licensed under the Eclipse Public License, Version 1.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.eclipse.org/legal/epl-v10.html
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
# either express or implied. See the License for the specific
# language governing permissions and limitations under the
# License.
#
# </bsn.cl>
############################################################
#
#
#
############################################################
LIBRARY := arm_delta_ag6248c
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
#$(LIBRARY)_LAST := 1
include $(BUILDER)/lib.mk

View File

@@ -1,85 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <sys/mman.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <AIM/aim.h>
#include "platform_lib.h"
#include "arm_delta_i2c.h"
psu_type_t get_psu_type(int id)
{
if ((id == PSU1_ID)||(id == PSU2_ID))
return PSU_TYPE_AC_B2F;
return PSU_TYPE_UNKNOWN;
}
enum ag6248c_product_id get_product_id(void)
{
int ret;
int pid = PID_UNKNOWN;
ret = i2c_devname_read_byte("CPLD", 0X01);
if(ret<0)
return PID_UNKNOWN;
pid = ((ret&0xf0)>>4);
if (pid >= PID_UNKNOWN || pid < PID_AG6248C_48) {
return PID_UNKNOWN;
}
return pid;
}
int chassis_fan_count(void)
{
enum ag6248c_product_id pid = get_product_id();
if ((pid == PID_AG6248C_48P)||(pid == PID_AG6248C_48)) {
return 4;
}
return 0 ;
}
int chassis_led_count(void)
{
enum ag6248c_product_id pid = get_product_id();
if (pid == PID_AG6248C_48P)
return 5;
else if(pid == PID_AG6248C_48)
return 6;
else
return 0;
}

View File

@@ -1,135 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#ifndef __PLATFORM_LIB_H__
#define __PLATFORM_LIB_H__
#include "arm_delta_ag6248c_log.h"
#define CHASSIS_THERMAL_COUNT 4
#define CHASSIS_PSU_COUNT 2
#define PSU1_ID 1
#define PSU2_ID 2
typedef enum psu_type {
PSU_TYPE_UNKNOWN,
PSU_TYPE_AC_F2B,
PSU_TYPE_AC_B2F
} psu_type_t;
psu_type_t get_psu_type(int id);
#define DEBUG_MODE 0
#if (DEBUG_MODE == 1)
#define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__)
#else
#define DEBUG_PRINT(format, ...)
#endif
enum onlp_fan_duty_cycle_percentage
{
FAN_IDLE_RPM = 5500,
FAN_LEVEL1_RPM = 7000,
FAN_LEVEL2_RPM = 9000,
FAN_LEVEL3_RPM = 12000,
};
enum ag6248c_product_id {
PID_AG6248C_48= 2,
PID_AG6248C_48P=4,
PID_UNKNOWN
};
/* LED related data */
enum sys_led_light_mode {
SYS_LED_MODE_GREEN_BLINKING = 0,
SYS_LED_MODE_GREEN,
SYS_LED_MODE_RED,
SYS_LED_MODE_RED_BLINKING,
SYS_LED_MODE_AUTO,
SYS_LED_MODE_UNKNOWN
};
enum fan_led_light_mode {
FAN_LED_MODE_OFF=0,
FAN_LED_MODE_GREEN,
FAN_LED_MODE_RED,
FAN_LED_MODE_RESERVERD,
FAN_LED_MODE_AUTO,
FAN_LED_MODE_UNKNOWN
};
enum psu_led_light_mode {
PSU_LED_MODE_OFF =0,
PSU_LED_MODE_GREEN,
PSU_LED_MODE_GREEN_BLINKING,
PSU_LED_MODE_RESERVERD,
PSU_LED_MODE_UNKNOWN
};
enum temp_led_light_mode {
TEMP_LED_MODE_OFF =0,
TEMP_LED_MODE_GREEN,
TEMP_LED_MODE_RED,
TEMP_LED_MODE_RESERVERD,
TEMP_LED_MODE_UNKNOWN
};
enum master_led_light_mode {
MASTER_LED_MODE_OFF =0,
MASTER_LED_MODE_GREEN,
MASTER_LED_MODE_OFF1,
MASTER_LED_MODE_RESERVERD,
MASTER_LED_MODE_UNKNOWN
};
typedef enum onlp_led_id
{
LED_RESERVED = 0,
LED_SYS,
LED_FAN,
LED_PSU2,
LED_PSU1,
LED_TEMP,
LED_MASTER
} onlp_led_id_t;
enum ag6248c_product_id get_product_id(void);
int chassis_fan_count(void);
int chassis_led_count(void);
typedef enum platform_id_e {
PLATFORM_ID_UNKNOWN,
PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0,
PLATFORM_ID_POWERPC_DELTA_AG6248C_R0,
} platform_id_t;
extern platform_id_t platform_id;
extern int psu_status_info_get(int id, char *node);
#endif /* __PLATFORM_LIB_H__ */

View File

@@ -1,381 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <onlp/platformi/psui.h>
#include <onlplib/mmap.h>
#include <stdio.h>
#include <string.h>
#include "platform_lib.h"
#include "arm_delta_ag6248c_int.h"
#include "arm_delta_i2c.h"
#define PSU_STATUS_PRESENT 1
#define PSU_STATUS_POWER_GOOD 1
#define PSU_STATUS_REG (0X08)
#define PSU_STATUS_PRESENT_BIT(ch) (0x8<<4*(ch-1))
#define PSU_STATUS_GOOD_BIT(ch) (0x4<<4*(ch-1))
#define PSU_STATUS_PRESENT_OFFSET(ch) (4*ch-1)
#define PSU_STATUS_GOOD_OFFSET(ch) (0x2+4*(ch-1))
#define PSU_PNBUS_VIN_REG (0x88)
#define PSU_PNBUS_IIN_REG (0x89)
#define PSU_PNBUS_PIN_REG (0x97)
#define PSU_PNBUS_VOUT_REG (0x8b)
#define PSU_PNBUS_IOUT_REG (0x8c)
#define PSU_PNBUS_POUT_REG (0x96)
#define PSU_PNBUS_SERIAL_REG (0x39)
#define PSU_PNBUS_MODEL_REG (0xc)
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_PSU(_id)) { \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
static long psu_data_convert(unsigned int d, int mult)
{
long X, Y, N, n;
Y = d & 0x07FF;
N = (d >> 11) & 0x0f;
n = d & 0x8000 ? 1 : 0;
if (n)
X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ;
else
X = (Y * mult) * (N=(1<<(N&0xf)));
return X;
}
static long psu_data_convert_16(unsigned int d, int mult)
{
long X;
X = (d * mult) / (1 << 9);
return X;
}
int
psu_status_info_get(int id, char *node)
{
int ret;
int r_data;
ret=i2c_devname_read_byte("CPLD",PSU_STATUS_REG);
if(ret<0)
return -1;
if (PSU1_ID == id) {
if(!strcmp("present",node))
r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id));
else if(!strcmp("good",node))
r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id));
else
r_data=-1;
}
else if (PSU2_ID == id) {
if(!strcmp("present",node))
r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id));
else if(!strcmp("good",node))
r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id));
else
r_data=-1;
}
else{
r_data=-1;
}
return r_data;
}
static int
psu_value_info_get(int id, char *type)
{
int ret;
char *dev_name;
int reg_offset;
enum ag6248c_product_id pid = get_product_id();
if(pid == PID_AG6248C_48){
if(PSU1_ID == id)
dev_name="PSU1_PMBUS";
else
dev_name="PSU2_PMBUS";
}
else{
if(PSU1_ID == id)
dev_name="PSU1_PMBUS_POE";
else
dev_name="PSU2_PMBUS_POE";
}
if(!strcmp(type,"vin"))
reg_offset=PSU_PNBUS_VIN_REG;
else if(!strcmp(type,"iin"))
reg_offset=PSU_PNBUS_IIN_REG;
else if(!strcmp(type,"pin"))
reg_offset=PSU_PNBUS_PIN_REG;
else if(!strcmp(type,"vout"))
reg_offset=PSU_PNBUS_VOUT_REG;
else if(!strcmp(type,"iout"))
reg_offset=PSU_PNBUS_IOUT_REG;
else
reg_offset=PSU_PNBUS_POUT_REG;
ret=i2c_devname_read_word(dev_name,reg_offset);
if(ret<0)
return -1;
return ret;
}
static int
psu_serial_model_info_get(int id,char *type,char*data,int data_len)
{
int i,r_data,re_cnt;
char *dev_name;
int reg_offset;
enum ag6248c_product_id pid = get_product_id();
if(pid == PID_AG6248C_48){
if(PSU1_ID == id)
dev_name="PSU1_EEPROM";
else
dev_name="PSU2_EEPROM";
}
else{
if(PSU1_ID == id)
dev_name="PSU1_EEPROM_POE";
else
dev_name="PSU2_EEPROM_POE";
}
if(!strcmp(type,"serial"))
reg_offset=PSU_PNBUS_SERIAL_REG;
else
reg_offset=PSU_PNBUS_MODEL_REG;
for(i=0;i<data_len;i++){
re_cnt=3;
while(re_cnt){
r_data=i2c_devname_read_byte(dev_name,reg_offset+i);
if(r_data<0){
re_cnt--;
continue;
}
data[i]=r_data;
break;
}
if(re_cnt==0){
AIM_LOG_ERROR("Unable to read the %d reg \r\n",i);
return ONLP_STATUS_E_INTERNAL;
}
}
return ONLP_STATUS_OK;
}
int
onlp_psui_init(void)
{
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;
int r_data;
char sn_data[15]={0};
char model_data[17]={0};
VALIDATE(id);
memset(info, 0, sizeof(onlp_psu_info_t));
*info = pinfo[index]; /* Set the onlp_oid_hdr_t */
/* Get the present state */
val=psu_status_info_get(index, "present");
if (val<0) {
AIM_LOG_INFO("Unable to read PSU %d present value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
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 */
val=psu_status_info_get(index,"good");
if (val<0) {
AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
if (val != PSU_STATUS_POWER_GOOD) {
info->status |= ONLP_PSU_STATUS_FAILED;
return ONLP_STATUS_OK;
}
/* Get PSU type
*/
psu_type = get_psu_type(index);
switch (psu_type) {
case PSU_TYPE_AC_F2B:
case PSU_TYPE_AC_B2F:
info->caps = ONLP_PSU_CAPS_AC;
ret = ONLP_STATUS_OK;
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;
}
/* Get PSU vin,vout*/
r_data=psu_value_info_get(index,"vin");
if (r_data<0) {
AIM_LOG_INFO("Unable to read PSU %d Vin value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
info->mvin=psu_data_convert(r_data,1000);
r_data=psu_value_info_get(index,"vout");
if (r_data<0) {
AIM_LOG_INFO("Unable to read PSU %d Vout value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
info->mvout=psu_data_convert_16(r_data,1000);
/* Get PSU iin, iout
*/
r_data=psu_value_info_get(index,"iin");
if (r_data<0) {
AIM_LOG_INFO("Unable to read PSU %d Iin value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
info->miin=psu_data_convert(r_data,1000);
r_data=psu_value_info_get(index,"iout");
if (r_data<0) {
AIM_LOG_INFO("Unable to read PSU %d Iout value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
info->miout=psu_data_convert(r_data,1000);
/* Get PSU pin, pout
*/
r_data=psu_value_info_get(index,"pin");
if (r_data<0) {
AIM_LOG_INFO("Unable to read PSU %d Pin value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
info->mpin=psu_data_convert(r_data,1000);
r_data=psu_value_info_get(index,"pout");
if (r_data<0) {
AIM_LOG_INFO("Unable to read PSU %d Pout value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
info->mpout=psu_data_convert(r_data,1000);
/* Get PSU serial
*/
ret=psu_serial_model_info_get(index,"serial",sn_data,14);
if (ret!=ONLP_STATUS_OK) {
AIM_LOG_INFO("Unable to read PSU %d SN value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
strcpy(info->serial,sn_data);
/* Get PSU model
*/
ret=psu_serial_model_info_get(index,"model",model_data,16);
if (ret!=ONLP_STATUS_OK) {
AIM_LOG_INFO("Unable to read PSU %d model value)\r\n", index);
return ONLP_STATUS_E_INVALID;
}
strcpy(info->model,model_data);
return ONLP_STATUS_OK;
}
int
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -1,364 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <onlp/platformi/sfpi.h>
#include "platform_lib.h"
#include <arm_delta_ag6248c/arm_delta_ag6248c_config.h>
#include "arm_delta_ag6248c_log.h"
#include "arm_delta_i2c.h"
#define SFP_PRESENT_REG (0X14)
#define SFP_RX_LOS_REG (0X11)
#define SFP_TX_DISABLE_REG (0X17)
#define SFP_PRESENT_PORT47_BIT (0X40)
#define SFP_PRESENT_PORT48_BIT (0X80)
#define SFP_PRESENT_PORT47_OFFSET (0X06)
#define SFP_PRESENT_PORT48_OFFSET (0X07)
/************************************************************
*
* 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)
{
int p;
int start_port, end_port;
if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)||
(platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0))
{
start_port = 47;
end_port = 48;
}
else /*reserved*/
{
AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id);
return ONLP_STATUS_E_UNSUPPORTED;
}
for(p = start_port; p <=end_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,r_data;
if((port==47)||(port==48))
r_data=i2c_devname_read_byte("CPLD", SFP_PRESENT_REG);
else{
AIM_LOG_ERROR("The port %d is invalid \r\n", port);
return ONLP_STATUS_E_UNSUPPORTED;
}
if(r_data<0){
AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
if(port==47){
r_data&=SFP_PRESENT_PORT47_BIT;
present=!(r_data>>SFP_PRESENT_PORT47_OFFSET);
}
else{
r_data&=SFP_PRESENT_PORT48_BIT;
present=!(r_data>>SFP_PRESENT_PORT48_OFFSET);
}
return present;
}
int
onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
{
int status;
int port, i = 0;
uint64_t presence_all=0;
AIM_BITMAP_CLR_ALL(dst);
if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| \
(platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)){
port=47;
}
else{
AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id);
return ONLP_STATUS_E_UNSUPPORTED;
}
status=i2c_devname_read_byte("CPLD", SFP_PRESENT_REG);
if(status<0){
AIM_LOG_ERROR("Unable to read the sfp_is_present_all value. \r\n");
return ONLP_STATUS_E_INTERNAL;
}
status=~status;
status>>=6;
/* Convert to 64 bit integer in port order */
presence_all = status & 0x3;
presence_all <<= port;
/* 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_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
{
int status;
int port,i = 0;
uint64_t rx_los_all = 0;
AIM_BITMAP_CLR_ALL(dst);
if((platform_id == PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0)|| \
(platform_id ==PLATFORM_ID_POWERPC_DELTA_AG6248C_R0)){
port=47;
}
else{
AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id);
return ONLP_STATUS_E_UNSUPPORTED;
}
status=i2c_devname_read_byte("CPLD", SFP_RX_LOS_REG);
if(status<0){
AIM_LOG_ERROR("Unable to read the rx loss reg value. \r\n");
return ONLP_STATUS_E_INTERNAL;
}
status>>=6;
/* Convert to 64 bit integer in port order */
rx_los_all = status & 0x3;
rx_los_all <<= port;
/* Populate bitmap */
for(i = 0; rx_los_all; i++) {
AIM_BITMAP_MOD(dst, i, (rx_los_all & 1));
rx_los_all >>= 1;
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
{
/*
* Read the SFP eeprom into data[]
*
* Return MISSING if SFP is missing.
* Return OK if eeprom is read
*/
int i, r_data, re_cnt;
char* sfp_name;
memset(data, 0, 256);
if(port==47)
sfp_name="SFP1";
else
sfp_name="SFP2";
for(i=0;i<256;i++){
re_cnt=3;
while(re_cnt){
r_data=i2c_devname_read_byte(sfp_name,i);
if(r_data<0){
re_cnt--;
continue;
}
data[i]=r_data;
break;
}
if(re_cnt==0){
AIM_LOG_ERROR("Unable to read the %d reg \r\n",i);
return ONLP_STATUS_E_INTERNAL;
}
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_dom_read(int port, uint8_t data[256])
{
return onlp_sfpi_eeprom_read( port, data);
}
int
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
/*value is 1 if the tx disable
value is 0 if the tx enable
*/
int rc,r_data,dis_value,present;
present=onlp_sfpi_is_present(port);
if(present==0){
AIM_LOG_INFO("The port %d is not present and can not set tx disable\r\n",port);
return ONLP_STATUS_E_UNSUPPORTED;
}
r_data=i2c_devname_read_byte("CPLD", SFP_TX_DISABLE_REG);
if(r_data<0){
AIM_LOG_INFO("Unable to read sfp tx disable reg value\r\n");
return ONLP_STATUS_E_INTERNAL;
}
if(port==47){
r_data&=~(0x1<<SFP_PRESENT_PORT47_OFFSET);
dis_value=value<<SFP_PRESENT_PORT47_OFFSET;
}
else{
r_data&=~(0x1<<SFP_PRESENT_PORT48_OFFSET);
dis_value=value<<SFP_PRESENT_PORT48_OFFSET;
}
dis_value|=r_data;
switch(control)
{
case ONLP_SFP_CONTROL_TX_DISABLE:
{
rc = i2c_devname_write_byte("CPLD", SFP_TX_DISABLE_REG, dis_value);
if (rc<0) {
AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
break;
}
default:
return ONLP_STATUS_E_UNSUPPORTED;
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
{
int r_data,present;
present=onlp_sfpi_is_present(port);
if(present==0){
AIM_LOG_INFO("The port %d is not present\r\n",port);
return ONLP_STATUS_E_UNSUPPORTED;
}
switch(control)
{
case ONLP_SFP_CONTROL_RX_LOS:
{
r_data=i2c_devname_read_byte("CPLD", SFP_RX_LOS_REG);
if (r_data<0) {
AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
break;
}
case ONLP_SFP_CONTROL_TX_DISABLE:
{
r_data=i2c_devname_read_byte("CPLD", SFP_TX_DISABLE_REG);
if (r_data<0) {
AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
break;
}
default:
return ONLP_STATUS_E_UNSUPPORTED;
}
if(port==47){
r_data&=(0x1<<SFP_PRESENT_PORT47_OFFSET);
*value=(r_data >>SFP_PRESENT_PORT47_OFFSET);
}
else{
r_data&=(0x1<<SFP_PRESENT_PORT48_OFFSET);
*value=(r_data >>SFP_PRESENT_PORT48_OFFSET);
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_denit(void)
{
return ONLP_STATUS_OK;
}

View File

@@ -1,290 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <onlplib/file.h>
#include <onlp/platformi/sysi.h>
#include <onlp/platformi/ledi.h>
#include <onlp/platformi/thermali.h>
#include <onlp/platformi/fani.h>
#include <onlp/platformi/psui.h>
#include "arm_delta_ag6248c_int.h"
#include "arm_delta_ag6248c_log.h"
#include "platform_lib.h"
#include "arm_delta_i2c.h"
platform_id_t platform_id = PLATFORM_ID_UNKNOWN;
#define ONIE_PLATFORM_NAME "arm-delta-ag6248c-r0"
const char*
onlp_sysi_platform_get(void)
{
enum ag6248c_product_id pid = get_product_id();
if (pid == PID_AG6248C_48)
return "arm-delta-ag6248c";
else if(pid == PID_AG6248C_48P)
return "arm-delta-ag6248c-poe";
else
return "unknow";
}
int
onlp_sysi_platform_set(const char* platform)
{
if(strstr(platform,"arm-delta-ag6248c-r0")) {
platform_id = PLATFORM_ID_POWERPC_DELTA_AG6248C_R0;
return ONLP_STATUS_OK;
}
if(strstr(platform,"arm-delta-ag6248c-poe-r0")) {
platform_id = PLATFORM_ID_POWERPC_DELTA_AG6248C_POE_R0;
return ONLP_STATUS_OK;
}
AIM_LOG_ERROR("No support for platform '%s'", platform);
return ONLP_STATUS_E_UNSUPPORTED;
}
int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
int v;
v = i2c_devname_read_byte("CPLD", 0X07);
pi->cpld_versions = aim_fstrdup("%d", v);
return 0;
}
int
onlp_sysi_onie_data_get(uint8_t** data, int* size)
{
uint8_t* rdata = aim_zmalloc(256);
int fd,rc_size;
char fullpath[20] = {0};
sprintf(fullpath, "/dev/mtd7");
fd=open(fullpath,O_RDWR);
if(fd<0){
aim_free(rdata);
return ONLP_STATUS_E_INTERNAL ;
}
rc_size=read(fd,rdata,256);
if(rc_size<0||rc_size!=256){
aim_free(rdata);
return ONLP_STATUS_E_INTERNAL ;
}
*data = rdata;
return ONLP_STATUS_OK;
}
void
onlp_sysi_onie_data_free(uint8_t* data)
{
aim_free(data);
}
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));
/* 1 Thermal sensors on the chassis */
for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) {
*e++ = ONLP_THERMAL_ID_CREATE(i);
}
/* LEDs on the chassis */
for (i = 1; i <= chassis_led_count(); i++) {
*e++ = ONLP_LED_ID_CREATE(i);
}
/* 1 Fans on the chassis */
for (i = 1; i <= chassis_fan_count(); i++) {
*e++ = ONLP_FAN_ID_CREATE(i);
}
/* 2 PSUs on the chassis */
for (i = 1; i <= CHASSIS_PSU_COUNT; i++) {
*e++ = ONLP_PSU_ID_CREATE(i);
}
return 0;
}
int
onlp_sysi_platform_manage_fans(void)
{
int rc;
onlp_thermal_info_t ti1;
onlp_thermal_info_t ti2;
int mtemp=0;
int new_rpm=0;
if (chassis_fan_count() == 0) {
return ONLP_STATUS_E_UNSUPPORTED;
}
/* Get temperature */
rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1);
if (rc != ONLP_STATUS_OK) {
return rc;
}
rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2);
if (rc != ONLP_STATUS_OK) {
return rc;
}
mtemp=(ti1.mcelsius+ti2.mcelsius)/2;
/* Bring fan speed according the temp
*/
if(mtemp<50000)
new_rpm=FAN_IDLE_RPM;
else if((mtemp>=55000)&&(mtemp<60000))
new_rpm=FAN_LEVEL1_RPM;
else if((mtemp>=65000)&&(mtemp<70000))
new_rpm=FAN_LEVEL2_RPM;
else if(mtemp>=75000)
new_rpm=FAN_LEVEL3_RPM;
else{
return ONLP_STATUS_OK;
}
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm);
onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm);
return ONLP_STATUS_OK;
}
int
onlp_sysi_platform_manage_leds(void)
{
int rc,rc1;
onlp_fan_info_t info1,info2;
onlp_led_mode_t fan_new_mode;
onlp_thermal_info_t ti;
onlp_led_mode_t temp_new_mode;
onlp_psu_info_t psu1;
onlp_led_mode_t psu1_new_mode;
onlp_psu_info_t psu2;
onlp_led_mode_t psu2_new_mode;
onlp_led_mode_t sys_new_mode;
/*fan led */
rc=onlp_fani_info_get(ONLP_FAN_ID_CREATE(1), &info1);
rc1=onlp_fani_info_get(ONLP_FAN_ID_CREATE(2), &info2);
if ((rc != ONLP_STATUS_OK)||(rc1 != ONLP_STATUS_OK)){
fan_new_mode=ONLP_LED_MODE_RED;
goto temp_led;
}
if(((info1.status&0x3)==1)&&((info2.status&0x3)==1))
fan_new_mode=ONLP_LED_MODE_GREEN;
else
fan_new_mode=ONLP_LED_MODE_RED;
temp_led:
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN),fan_new_mode);
/*temperature led */
rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti);
if (rc != ONLP_STATUS_OK) {
temp_new_mode=ONLP_LED_MODE_OFF;
goto psu1_led;
}
if(ti.mcelsius >= 75000)
temp_new_mode=ONLP_LED_MODE_RED;
else
temp_new_mode=ONLP_LED_MODE_GREEN;
psu1_led:
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_TEMP),temp_new_mode);
/*psu1 and psu2 led */
rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(1),&psu1);
if (rc != ONLP_STATUS_OK) {
psu1_new_mode=ONLP_LED_MODE_OFF;
goto psu2_led;
}
if((psu1.status&0x1)&&!(psu1.status&0x2))
psu1_new_mode=ONLP_LED_MODE_GREEN;
else
psu1_new_mode=ONLP_LED_MODE_OFF;
psu2_led:
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU1),psu1_new_mode);
//psu2 led ----------------
rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(2),&psu2);
if (rc != ONLP_STATUS_OK) {
psu2_new_mode=ONLP_LED_MODE_OFF;
goto sys_led;
}
if((psu2.status&0x1)&&!(psu2.status&0x2))
psu2_new_mode=ONLP_LED_MODE_GREEN;
else
psu2_new_mode=ONLP_LED_MODE_OFF;
sys_led :
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU2),psu2_new_mode);
//sys led ----------------
if((fan_new_mode!=ONLP_LED_MODE_GREEN)||((psu2_new_mode!=ONLP_LED_MODE_GREEN)&& \
(psu1_new_mode!=ONLP_LED_MODE_GREEN)))
sys_new_mode=ONLP_LED_MODE_RED_BLINKING;
else
sys_new_mode=ONLP_LED_MODE_GREEN;
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS),sys_new_mode);
return ONLP_STATUS_OK;
}

View File

@@ -1,208 +0,0 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2016 Accton Technology Corporation.
* Copyright 2017 Delta 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.
*
* </bsn.cl>
************************************************************
*
* Thermal Sensor Platform Implementation.
*
***********************************************************/
#include <unistd.h>
#include <onlplib/mmap.h>
#include <onlplib/file.h>
#include <onlp/platformi/thermali.h>
#include <fcntl.h>
#include "platform_lib.h"
#include "arm_delta_ag6248c_log.h"
#include <stdio.h>
#include "arm_delta_i2c.h"
#define prefix_path "/sys/bus/i2c/devices/"
#define LOCAL_DEBUG 0
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_THERMAL(_id)) { \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
enum onlp_thermal_id
{
THERMAL_RESERVED = 0,
THERMAL_1_CLOSE_TO_MAC,
THERMAL_2_CLOSE_TO_PHY,
THERMAL_1_ON_PSU1,
THERMAL_1_ON_PSU2,
};
static char* last_path[] = /* must map with onlp_thermal_id */
{
"reserved",
"0-0049/temp1_input",
"0-004a/temp1_input",
};
/* Static values */
static onlp_thermal_info_t linfo[] = {
{ }, /* Not used */
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_CLOSE_TO_MAC), "Thermal Sensor 1- close to mac", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_CLOSE_TO_PHY), "Thermal Sensor 2- close to phy", 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(1)},
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(2)},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
}
};
static int
_onlp_psu_thermali_val_to_temperature (int v,int mult)
{
long X, Y, N, n;
Y = v & 0x07FF;
N = (v >> 11) & 0x0f;
n = v & 0x8000 ? 1 : 0;
if (n)
X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ;
else
X = Y * mult * (N=(1<<(N&0xf)));
return X;
}
/*
* 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.
*/
static int
_onlp_thermali_info_get(int id, onlp_thermal_info_t* info)
{
int len, nbytes = 10, temp_base=1, local_id;
uint8_t r_data[10] = {0};
char fullpath[50] = {0};
local_id = id;
DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id);
/* get fullpath */
sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]);
onlp_file_read(r_data,nbytes,&len, fullpath);
info->mcelsius =ONLPLIB_ATOI((char*)r_data) / temp_base;
DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius);
return ONLP_STATUS_OK;
}
static int
_onlp_thermali_psu_info_get(int id, onlp_thermal_info_t* info)
{
int psu_present,psu_good;
int psu_id,local_id;
int r_data,temperature_v;
enum ag6248c_product_id pid;
local_id=id;
DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id);
psu_id=(local_id-THERMAL_1_ON_PSU1)+1;
pid=get_product_id();
//if the psu is not, directly to return
psu_present=psu_status_info_get(psu_id, "present");
psu_good=psu_status_info_get(psu_id, "good");
if((psu_present<=0)||(psu_good<=0)){
info->status &= ~ONLP_THERMAL_STATUS_PRESENT;
return ONLP_STATUS_OK;
}
//read the pus temperture register value
if(pid == PID_AG6248C_48){
if(psu_id==1)
r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d);
else
r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d);
}
else{
if(psu_id==1)
r_data=i2c_devname_read_word("PSU1_PMBUS_POE", 0x8d);
else
r_data=i2c_devname_read_word("PSU2_PMBUS_POE", 0x8d);
}
if(r_data<0)
return ONLP_STATUS_E_INVALID;
//get the real temperture value
temperature_v=_onlp_psu_thermali_val_to_temperature(r_data,1000);
info->mcelsius=temperature_v;
DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius);
return ONLP_STATUS_OK;
}
int
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
int rc;
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_1_CLOSE_TO_MAC) || (local_id==THERMAL_2_CLOSE_TO_PHY))
rc= _onlp_thermali_info_get(local_id,info);
else if((local_id==THERMAL_1_ON_PSU1) || (local_id==THERMAL_1_ON_PSU2))
rc=_onlp_thermali_psu_info_get(local_id,info);
else{
rc=ONLP_STATUS_E_INVALID;
}
return rc;
}

View File

@@ -1 +0,0 @@
include $(ONL)/make/pkg.mk

View File

@@ -1 +0,0 @@
!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=armel VENDOR=delta

View File

@@ -1,3 +1,2 @@
*x86*64*delta_agc7648a*.mk
*x86*64*delta*ag5648*.mk
onlpdump.mk

View File

@@ -1,2 +1 @@
include $(ONL)/make/pkg.mk
include $(ONL)/make/pkg.mk