From 0bd13c1ee4b6d7d3df5ac732804c67e9a2d91053 Mon Sep 17 00:00:00 2001 From: "shaohua.xiong" Date: Thu, 5 Jul 2018 09:33:23 +0800 Subject: [PATCH] support the ag7648c platform --- .../x86-64/x86-64-delta-ag7648c/Makefile | 1 + .../x86-64-delta-ag7648c/modules/Makefile | 1 + .../x86-64-delta-ag7648c/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-delta-ag7648c-cpld-mux.c | 315 ++++++++++ .../x86-64/x86-64-delta-ag7648c/onlp/Makefile | 1 + .../x86-64/x86-64-delta-ag7648c/onlp/PKG.yml | 1 + .../x86-64-delta-ag7648c/onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++ .../lib/libonlp-x86-64-delta-ag7648c.mk | 10 + .../onlp/builds/onlpdump/Makefile | 46 ++ .../onlp/builds/onlpdump/onlpdump.mk | 10 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../src/module/auto/x86_64_delta_ag7648c.yml | 50 ++ .../x86_64_delta_ag7648c.x | 14 + .../x86_64_delta_ag7648c_config.h | 137 ++++ .../x86_64_delta_ag7648c_dox.h | 26 + .../x86_64_delta_ag7648c_porting.h | 107 ++++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/debug.c | 44 ++ .../onlp/builds/src/module/src/eeprom_info.c | 118 ++++ .../onlp/builds/src/module/src/eeprom_info.h | 36 ++ .../onlp/builds/src/module/src/fani.c | 590 ++++++++++++++++++ .../onlp/builds/src/module/src/ledi.c | 443 +++++++++++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 58 ++ .../onlp/builds/src/module/src/platform_lib.h | 141 +++++ .../onlp/builds/src/module/src/psui.c | 344 ++++++++++ .../onlp/builds/src/module/src/sfpi.c | 439 +++++++++++++ .../onlp/builds/src/module/src/sysi.c | 300 +++++++++ .../onlp/builds/src/module/src/thermali.c | 229 +++++++ .../module/src/x86_64_delta_ag7648c_config.c | 81 +++ .../module/src/x86_64_delta_ag7648c_enums.c | 10 + .../src/module/src/x86_64_delta_ag7648c_int.h | 12 + .../src/module/src/x86_64_delta_ag7648c_log.c | 18 + .../src/module/src/x86_64_delta_ag7648c_log.h | 12 + .../module/src/x86_64_delta_ag7648c_module.c | 24 + .../module/src/x86_64_delta_ag7648c_ucli.c | 50 ++ .../builds/src/module/src/x86_64_delta_i2c.c | 148 +++++ .../builds/src/module/src/x86_64_delta_i2c.h | 49 ++ .../onlp/builds/src/x86_64_delta_ag7648c.mk | 13 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../r0/src/lib/x86-64-delta-ag7648c-r0.yml | 32 + .../x86_64_delta_ag7648c_r0/__init__.py | 28 + 51 files changed, 4049 insertions(+) create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/PKG.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/x86-64-delta-ag7648c-cpld-mux.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/PKG.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/libonlp-x86-64-delta-ag7648c.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/onlpdump.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/.module create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/README create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/x86_64_delta_ag7648c.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c.x create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_config.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_dox.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_porting.h create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/debug.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/fani.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/psui.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sfpi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sysi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/thermali.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_config.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_enums.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_int.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_module.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_ucli.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/x86_64_delta_ag7648c.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/PKG.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/lib/x86-64-delta-ag7648c-r0.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/python/x86_64_delta_ag7648c_r0/__init__.py diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/PKG.yml new file mode 100644 index 00000000..ef383e5a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=delta BASENAME=x86-64-delta-ag7648c ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/Makefile new file mode 100644 index 00000000..151ad4c1 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := delta +BASENAME := x86-64-delta-ag7648c +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/x86-64-delta-ag7648c-cpld-mux.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/x86-64-delta-ag7648c-cpld-mux.c new file mode 100755 index 00000000..00137d80 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/x86-64-delta-ag7648c-cpld-mux.c @@ -0,0 +1,315 @@ +/* + * An I2C multiplexer dirver for delta ag7648c CPLD + * + * Copyright (C) 2018 Delta Technology Corporation. + * Shaohua Xiong + * + * This module supports the delta cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * + * Based on: + * pca954x.c from Kumar Gala + * 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 + * and + * pca9540.c from Jean Delvare . + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#define CTRL_CPLD_BUS 0x2 +#define CTRL_CPLD_I2C_ADDR 0x32 +#define PARENT_CHAN 0x5 +#define NUM_OF_CPLD_CHANS 0x6 + +#define CPLD_CHANNEL_SELECT_REG 0xa +#define CPLD_CHANNEL_SELECT_MASK 0x3f +#define CPLD_CHANNEL_SELECT_OFFSET 0x0 +#define CPLD_QSFP_INTR_STATUS_REG 0xe +#define CPLD_QSFP_INTR_STATUS_OFFSET 0x0 +#define CPLD_QSFP_RESET_CTRL_REG 0xd +#define CPLD_QSFL_RESET_CTRL_OFFSET 0x0 + +#define CPLD_DESELECT_CHANNEL 0xff + +#define CPLD_MUX_MAX_NCHANS 0x6 +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,change=0; + s32 res = -EIO; + u8 reg_val = 0; + int intr, reset_ctrl; + int i; + + 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++) { + // workaround + data.byte = 0; + 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) + continue; + //read the interrupt status + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_QSFP_INTR_STATUS_REG, + I2C_SMBUS_BYTE_DATA, &data); + if ( res == -EAGAIN) + continue; + + intr = data.byte; + + //read the reset control + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_QSFP_RESET_CTRL_REG, + I2C_SMBUS_BYTE_DATA, &data); + if ( res == -EAGAIN) + continue; + + reset_ctrl = data.byte; + + /* there is an interrupt for QSFP port, including failure/plugin/un-plugin + * try to reset it. + * + */ + for (i = 0 ; i < NUM_OF_CPLD_CHANS; i ++) + { + if((reset_ctrl & ( 1 << i )) == 0){ + change=1; + } + if ((intr & ( 1 << i )) == 0 ) + { + + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_QSFP_RESET_CTRL_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res == -EAGAIN) + continue; + data.byte &= ~(1 << i); + + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_QSFP_RESET_CTRL_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res == -EAGAIN) + continue; + change=1; + } + } + if(change){ + msleep(10); + data.byte=CPLD_DESELECT_CHANNEL; + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_QSFP_RESET_CTRL_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res == -EAGAIN) + continue; + msleep(200); + } + + + // 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 |= (((~(1 << val)) & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); + data.byte = (~(1 << val)) & 0xff; + + // 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, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) + 0, +#endif + 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("Shao Hua "); +MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); +MODULE_LICENSE("GPL"); + +module_init(delta_i2c_cpld_mux_init); +module_exit(delta_i2c_cpld_mux_exit); + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/PKG.yml new file mode 100644 index 00000000..85b82886 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-delta-ag7648c ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/Makefile new file mode 100644 index 00000000..1cfcb406 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +MODULE := libonlp-x86-64-delta-ag7648c +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_delta_ag7648c onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-delta-ag7648c.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/libonlp-x86-64-delta-ag7648c.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/libonlp-x86-64-delta-ag7648c.mk new file mode 100755 index 00000000..bfea1e0b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/libonlp-x86-64-delta-ag7648c.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-x86-64-delta-ag7648c module. +# +# Autogenerated 2017-03-20 15:05:28.120004 +# +############################################################################### +libonlp-x86-64-delta-ag7648c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..bc539466 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# Copyright 2014 BigSwitch Networks, Inc. +# +# Licensed under the Eclipse Public License, Version 1.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.eclipse.org/legal/epl-v10.html +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the +# License. +# +# +############################################################ +# +# +# +############################################################ +include $(ONL)/make/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_delta_ag7648c onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/onlpdump.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/onlpdump.mk new file mode 100644 index 00000000..1a687b68 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/onlpdump.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the onlpdump module. +# +# Autogenerated 2018-02-27 06:23:08.553582 +# +############################################################################### +onlpdump_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/.module b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/.module new file mode 100644 index 00000000..aee4b16a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_delta_ag7648c diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/Makefile new file mode 100644 index 00000000..5722a637 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_delta_ag7648c +AUTOMODULE := x86_64_delta_ag7648c +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/README b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/README new file mode 100644 index 00000000..b0f9c718 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_delta_ag7648c README +# +############################################################################### + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..e903383a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_delta_ag7648c Autogeneration +# +############################################################################### +x86_64_delta_ag7648c_AUTO_DEFS := module/auto/x86_64_delta_ag7648c.yml +x86_64_delta_ag7648c_AUTO_DIRS := module/inc/x86_64_delta_ag7648c module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/x86_64_delta_ag7648c.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/x86_64_delta_ag7648c.yml new file mode 100755 index 00000000..b2beca64 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/x86_64_delta_ag7648c.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_delta_ag7648c Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB +- X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_DELTA_AG7648C_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_delta_ag7648c_config + + portingmacro: + x86_64_delta_ag7648c: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c.x b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c.x new file mode 100755 index 00000000..6f87e11b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_config.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_config.h new file mode 100755 index 00000000..78b58be0 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_ag7648c Configuration Header + * + * @addtogroup x86_64_delta_ag7648c-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG7648C_CONFIG_H__ +#define __X86_64_DELTA_AG7648C_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_DELTA_AG7648C_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING +#define X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT +#define X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI +#define X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_delta_ag7648c_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_delta_ag7648c_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_delta_ag7648c_config_settings table. */ +extern x86_64_delta_ag7648c_config_settings_t x86_64_delta_ag7648c_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_delta_ag7648c_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_delta_ag7648c_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_delta_ag7648c_porting.h" + +#endif /* __X86_64_DELTA_AG7648C_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_dox.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_dox.h new file mode 100755 index 00000000..e2b308bf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_delta_ag7648c Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG7648C_DOX_H__ +#define __X86_64_DELTA_AG7648C_DOX_H__ + +/** + * @defgroup x86_64_delta_ag7648c x86_64_delta_ag7648c - x86_64_delta_ag7648c Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_delta_ag7648c-x86_64_delta_ag7648c Public Interface + * @defgroup x86_64_delta_ag7648c-config Compile Time Configuration + * @defgroup x86_64_delta_ag7648c-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_DELTA_AG7648C_DOX_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_porting.h new file mode 100755 index 00000000..c47d5e94 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_ag7648c Porting Macros. + * + * @addtogroup x86_64_delta_ag7648c-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG7648C_PORTING_H__ +#define __X86_64_DELTA_AG7648C_PORTING_H__ + + +/* */ +#if X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_delta_ag7648c_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_delta_ag7648c_MALLOC GLOBAL_MALLOC + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_MALLOC malloc + #else + #error The macro x86_64_delta_ag7648c_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_FREE + #if defined(GLOBAL_FREE) + #define x86_64_delta_ag7648c_FREE GLOBAL_FREE + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_FREE free + #else + #error The macro x86_64_delta_ag7648c_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_delta_ag7648c_MEMSET GLOBAL_MEMSET + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_MEMSET memset + #else + #error The macro x86_64_delta_ag7648c_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_delta_ag7648c_MEMCPY GLOBAL_MEMCPY + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_MEMCPY memcpy + #else + #error The macro x86_64_delta_ag7648c_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_delta_ag7648c_STRNCPY GLOBAL_STRNCPY + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_STRNCPY strncpy + #else + #error The macro x86_64_delta_ag7648c_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_delta_ag7648c_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_VSNPRINTF vsnprintf + #else + #error The macro x86_64_delta_ag7648c_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_delta_ag7648c_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_SNPRINTF snprintf + #else + #error The macro x86_64_delta_ag7648c_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_delta_ag7648c_STRLEN GLOBAL_STRLEN + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_STRLEN strlen + #else + #error The macro x86_64_delta_ag7648c_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_DELTA_AG7648C_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..7c39db80 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_delta_ag7648c_INCLUDES := -I $(THIS_DIR)inc +x86_64_delta_ag7648c_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_delta_ag7648c_DEPENDMODULE_ENTRIES := init:x86_64_delta_ag7648c ucli:x86_64_delta_ag7648c + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..845b434b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_delta_ag7648c_ucli.c + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/debug.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/debug.c new file mode 100755 index 00000000..8c7d2a94 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/debug.c @@ -0,0 +1,44 @@ + +#if X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEBUG == 1 + +#include + +static char help__[] = + "Usage: debug [options]\n" + " -c CPLD Versions\n" + " -h Help\n" + ; + +int +x86_64_delta_ag7648c_debug_main(int argc, char* argv[]) +{ + int c = 0; + int help = 0; + int rv = 0; + + while( (c = getopt(argc, argv, "ch")) != -1) { + switch(c) + { + case 'c': c = 1; break; + case 'h': help = 1; rv = 0; break; + default: help = 1; rv = 1; break; + } + + } + + if(help || argc == 1) { + printf("%s", help__); + return rv; + } + + if(c) { + printf("Not implemented.\n"); + } + + + return 0; +} + +#endif + + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.c new file mode 100755 index 00000000..ffec5ee6 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.c @@ -0,0 +1,118 @@ + +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 (C) 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include "eeprom_info.h" +#include + +#define PSU_MODEL_LEN 11 +#define PSU_SERIES_LEN 14 + +/* + function: + search the eeprom with the key + variables: + eeprom: the eeprom data; + key : the searching key string + mode : 1 means model search, 0 means series search + return: + success, return index which points to the finding string + failed, return -1 +*/ + +int eeprom_info_find(char *eeprom, int len, const char *key,int mode) +{ + int index=0; + int found=0; + int key_len=0; + if(!eeprom || !key) + return -1; + + key_len=strlen(key); + + while(index < len-key_len){ + if (!strncmp(&eeprom[index], key, key_len)){ + found=1; + break; + } + index++; + } + if(found){ + /*mode is 1 means the model search and mode is 0 means the series search*/ + if((mode == 1) && (index < len-PSU_MODEL_LEN)) + return index; + else if ((mode == 0) && (index < len-PSU_SERIES_LEN)) + return index; + else + return -1; + } + + return -1; + +} + +int eeprom_info_get(uint8_t *eeprom, int len, char *type, char *v) +{ + const char psu_model_key[]="DPS"; + const char psu_460_series_key[]="DZRD"; + const char psu_550_series_key[]="GVVD"; + int index=0; + char model[PSU_MODEL_LEN+1]={'\0'}; + char * eep=NULL; + if(!eeprom || !type ||!v) + return -1; + eep=(char *)eeprom; + /*fan eeprom is not now*/ + if((strcmp(type, "fan_model")==0) ||(strcmp(type,"fan_series"))==0) + return 0; + /*first get the psu tpye*/ + index = eeprom_info_find(eep,len,psu_model_key,1); + if(index <0) + return -1; + strncpy(model,&eep[index],PSU_MODEL_LEN); + + if((strcmp(type,"psu_model"))==0){ + strncpy(v,model,PSU_MODEL_LEN); + } + else if ((strcmp(type,"psu_series"))==0){ + if(strstr(model,"460")){ + index = eeprom_info_find(eep,len,psu_460_series_key,0); + if(index <0) + return -1; + strncpy(v,&eep[index],PSU_SERIES_LEN); + } + else if(strstr(model,"550")){ + index = eeprom_info_find(eep,len,psu_550_series_key,0); + if(index <0) + return -1; + strncpy(v,&eep[index],PSU_SERIES_LEN); + } + } + else{ + return -1; + } + return 0; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.h new file mode 100755 index 00000000..8a370f6f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.h @@ -0,0 +1,36 @@ + +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 (C) 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#ifndef __EEPROM_INFO__ +#define __EEPROM_INFO__ + +#include "onlp/onlp_config.h" + +extern int eeprom_info_get(uint8_t *eeprom, int len, char *type, char *v); + +#endif // __EEPROM_INFO__ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/fani.c new file mode 100755 index 00000000..84c47bb7 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/fani.c @@ -0,0 +1,590 @@ +/************************************************************ + * + * + * 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. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_delta_ag7648c_int.h" +#include "x86_64_delta_i2c.h" + + +#define MAX_FAN_SPEED 19000 +#define MAX_PSU_FAN_SPEED 18000 + +#define FILE_NAME_LEN 80 + +#define CPLD_FAN_NAME "MASTERCPLD" + +#define CPLD_FAN_TRAY0_PRESENT_REG (0x8) +#define CPLD_FAN_TRAY0_PRESENT_REG_OFFSET (0x6) +#define CPLD_FAN_TRAY1_PRESENT_REG (0x8) +#define CPLD_FAN_TRAY1_PRESENT_REG_OFFSET (0x7) +#define CPLD_FAN_TRAY2_PRESENT_REG (0x9) +#define CPLD_FAN_TRAY2_PRESENT_REG_OFFSET (0x0) + + +/* The MAX6620 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(d1, d2) \ + { \ + int tech = (d1 << 3) | ((d2 >> 5) & 0x07);\ + rpm = (491520 * 4) / (2 * tech);\ + } + +#define FAN_TO_REG(rpm) \ +{ \ + float ftech; \ + uint32_t tech; \ + ftech = (491520.0 * 4)/ (2.0 * rpm); \ + ftech = ftech + 0.3; \ + tech = (uint32_t) ftech; \ + d1 = (uint8_t)(tech >> 3); \ + d2 = (uint8_t)((tech << 5) & 0xe0);\ +} +static int fan_initd=0; + +enum onlp_fan_id +{ + FAN_RESERVED = 0, + FAN_1_ON_MAIN_BOARD, /*fan tray 0*/ + FAN_2_ON_MAIN_BOARD, /*fan tray 0*/ + FAN_3_ON_MAIN_BOARD, /*fan tray 1*/ + FAN_4_ON_MAIN_BOARD, /*fan tray 1*/ + FAN_5_ON_MAIN_BOARD, /*fan tray 2*/ + FAN_6_ON_MAIN_BOARD, /*fan tray 2*/ + FAN_1_ON_PSU1, + FAN_1_ON_PSU2 +}; + +enum onlp_fan_tray_id +{ + FAN_TRAY_0 = 0, + FAN_TRAY_1 = 1, + FAN_TRAY_2 = 2 +}; + +#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_F2B | 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_F2B | 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_MAIN_BOARD(3), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(5), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(6), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1), +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_get_fan_tray(int fanId) +{ + int tray_id; + if((fanId==5) || (fanId==6)) + tray_id=0; + else if((fanId==3) || (fanId==4)) + tray_id=1; + else + tray_id=2; + return tray_id; +} +#if 1 +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)); +} +#endif + +static int +_onlp_fan_board_init(void) +{ + int i = 0; + int d1,d2; + int rpm = 8000; + i2c_devname_write_byte("FANCTRL1", 0x00,0x10); + i2c_devname_write_byte("FANCTRL2", 0x00,0x10); + + i2c_devname_write_byte("FANCTRL1", 0x01,0x00); + i2c_devname_write_byte("FANCTRL2", 0x01,0x00); + + for (i = FAN_1_ON_MAIN_BOARD; i <= FAN_4_ON_MAIN_BOARD; i ++) + { + int offset = i - FAN_1_ON_MAIN_BOARD; + + i2c_devname_write_byte("FANCTRL2", 0x02 + offset ,0xc0); + + FAN_TO_REG(rpm); + + i2c_devname_write_byte("FANCTRL2", 0x20 + 2 * offset, d1); + i2c_devname_write_byte("FANCTRL2", 0x21 + 2 * offset, d2); + + } + for (i = FAN_5_ON_MAIN_BOARD; i <= FAN_6_ON_MAIN_BOARD; i ++) + { + int offset = i - FAN_5_ON_MAIN_BOARD; + + i2c_devname_write_byte("FANCTRL1", 0x02 + offset ,0xc0); + + FAN_TO_REG(rpm); + + i2c_devname_write_byte("FANCTRL1", 0x20 + 2 * offset, d1); + i2c_devname_write_byte("FANCTRL1", 0x21 + 2 * offset, d2); + } + + 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_present; + int fan_tray = 0; + int reg, offset; + int d1, d2; + int rpm; + + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + + fan_tray = _onlp_get_fan_tray(local_id); + if (fan_tray == 0) + { + reg = CPLD_FAN_TRAY0_PRESENT_REG; + offset = CPLD_FAN_TRAY0_PRESENT_REG_OFFSET; + }else if (fan_tray == 1) + { + reg = CPLD_FAN_TRAY1_PRESENT_REG; + offset = CPLD_FAN_TRAY1_PRESENT_REG_OFFSET; + }else if (fan_tray == 2) + { + reg = CPLD_FAN_TRAY2_PRESENT_REG; + offset = CPLD_FAN_TRAY2_PRESENT_REG_OFFSET; + }else + { + return ONLP_STATUS_E_INVALID; + } + + /* get fan fault status (turn on when any one fails)*/ + r_data = i2c_devname_read_byte(CPLD_FAN_NAME, reg); + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_present = (r_data >> offset ) & 0x1; + + if(!fan_present){ + + info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B); + + if (fan_tray == 0) + { + d1 = i2c_devname_read_byte("FANCTRL1", 0x10 + 2 * (local_id - FAN_5_ON_MAIN_BOARD)); + d2 = i2c_devname_read_byte("FANCTRL1", 0x11 + 2 * (local_id - FAN_5_ON_MAIN_BOARD)); + }else + { + d1 = i2c_devname_read_byte("FANCTRL2", 0x10 + 2 * (local_id - FAN_1_ON_MAIN_BOARD) ); + d2 = i2c_devname_read_byte("FANCTRL2", 0x11 + 2 * (local_id - FAN_1_ON_MAIN_BOARD) ); + } + + if (d1 < 0 || d2 < 0) + { + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_E_INVALID; + } + + } + else{ + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_E_UNSUPPORTED; + } + DEBUG_PRINT("d1 %d, d2 %d\r\n", d1, d2); + + FAN_FROM_REG(d1,d2); + + info->rpm = rpm; + + DEBUG_PRINT("rpm %d\r\n", rpm); + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100.0) / MAX_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; +} + +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,psu_good; + enum ag7648c_product_id pid; + + /* 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); + + //if the psu is not present, directly to return + psu_present=psu_status_info_get(psu_id, "present"); + if(psu_present != 1){ + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + /*if the psu power failed , directly to return*/ + psu_good= psu_status_info_get(psu_id,"good"); + if(psu_good != 0){ + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_OK; + } + info->status &= ~ONLP_FAN_STATUS_FAILED; + + /* get fan speed*/ + pid=get_product_id(); + if(pid == PID_AG7648C){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x90); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x90); + } + else{ + DEBUG_PRINT("\n[Debug][%s][%d][unsupported board:%d]", __FUNCTION__, __LINE__, pid); + return ONLP_STATUS_E_UNSUPPORTED; + } + + 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: + case FAN_3_ON_MAIN_BOARD: + case FAN_4_ON_MAIN_BOARD: + case FAN_5_ON_MAIN_BOARD: + case FAN_6_ON_MAIN_BOARD: + rc =_onlp_fani_info_get_fan(local_id, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the 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 rc1, rc2; + int local_id; + int d1, d2; + int fan_tray; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + DEBUG_PRINT("local id %d, rpm %d\n", local_id, rpm); + + 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 (rpm == 0) + return ONLP_STATUS_E_INVALID; + + + /*get ret value for the speed set*/ + FAN_TO_REG(rpm); + DEBUG_PRINT("local id %d, rpm %d(d1: %d, d2: %d)\n", local_id, rpm, d1, d2); + + /*set the rpm speed */ + fan_tray = _onlp_get_fan_tray(local_id); + if (fan_tray < 0 || fan_tray > 2) + return ONLP_STATUS_E_INVALID; + + if (fan_tray == 0) + { + rc1 = i2c_devname_write_byte("FANCTRL1", 0x20 + 2 * (local_id - FAN_5_ON_MAIN_BOARD), d1); + rc2 = i2c_devname_write_byte("FANCTRL1", 0x21 + 2 * (local_id - FAN_5_ON_MAIN_BOARD), d2); + }else + { + rc1 = i2c_devname_write_byte("FANCTRL2", 0x20 + 2 * (local_id - FAN_1_ON_MAIN_BOARD), d1); + rc2 = i2c_devname_write_byte("FANCTRL2", 0x21 + 2 * (local_id - FAN_1_ON_MAIN_BOARD), d2); + } + + if (rc1 < 0 || rc2 < 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; + int local_id; + int d1, d2; + int rc1, rc2; + int fan_tray; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + DEBUG_PRINT("local_id %d, percentage %d", local_id, p); + 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_TO_REG(rpm_val); + + DEBUG_PRINT("local_id %d, p %d, rpm_val %d(d1:%d, d2:%d)", local_id, p, rpm_val, d1, d2); + /*set the rpm speed */ + fan_tray = _onlp_get_fan_tray(local_id); + if (fan_tray < 0 || fan_tray > 2) + return ONLP_STATUS_E_INVALID; + + if (fan_tray == 0) + { + rc1 = i2c_devname_write_byte("FANCTRL1", 0x20 + 2 * (local_id - FAN_5_ON_MAIN_BOARD), d1); + rc2 = i2c_devname_write_byte("FANCTRL1", 0x21 + 2 * (local_id - FAN_5_ON_MAIN_BOARD), d2); + }else + { + rc1 = i2c_devname_write_byte("FANCTRL2", 0x20 + 2 * (local_id - FAN_1_ON_MAIN_BOARD) , d1); + rc2 = i2c_devname_write_byte("FANCTRL2", 0x21 + 2 * (local_id - FAN_1_ON_MAIN_BOARD) , d2); + } + + if (rc1 < 0 || rc2 < 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; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/ledi.c new file mode 100755 index 00000000..888b5ee6 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,443 @@ +/************************************************************ + * + * + * 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include + +#include +#include "platform_lib.h" +#include "x86_64_delta_ag7648c_int.h" +#include "x86_64_delta_i2c.h" +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +#define CPLD_NAME1 "SYSCPLD" +#define CPLD_NAME2 "MASTERCPLD" +#define CPLD_NAME3 "SLAVECPLD" + +#define CPLD_LED_REG_BITS (0X3) //the reg bits + +#define CPLD_LED_FAN_TRAY_REG (0X8) +#define CPLD_LED_FAN_TRAY0_REG_OFFSET (0X0) +#define CPLD_LED_FAN_TRAY1_REG_OFFSET (0X2) +#define CPLD_LED_FAN_TRAY2_REG_OFFSET (0X4) + +#define CPLD_LED_POWER_REG (0X7) +#define CPLD_LED_POWER_REG_OFFSET (0X5) + +#define CPLD_LED_SYS_REG (0X7) +#define CPLD_LED_SYS_REG_OFFSET (0X1) +#define CPLD_LED_LOCATOR_REG_OFFSET (0X3) + +#define CPLD_LED_FAN_REG (0X9) +#define CPLD_LED_FAN_REG_OFFSET (0X3) + + +/* + * 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_YELLOW_BLINKING | ONLP_LED_CAPS_YELLOW , + }, + + { + { ONLP_LED_ID_CREATE(LED_FAN), "fan", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_YELLOW_BLINKING | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_YELLOW, + }, + + { + { ONLP_LED_ID_CREATE(LED_LOCATOR), "locator", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE | + ONLP_LED_CAPS_BLUE_BLINKING , + }, + + { + { ONLP_LED_ID_CREATE(LED_POWER), "power", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW_BLINKING | ONLP_LED_CAPS_YELLOW, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY2), "fan_tray1", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY1), "fan_tray2", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY0), "fan_tray3", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW, + }, +}; + +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_YELLOW: return ONLP_LED_MODE_YELLOW; + case SYS_LED_MODE_YELLOW_BLINKING: return ONLP_LED_MODE_YELLOW_BLINKING; + default: return ONLP_LED_MODE_GREEN_BLINKING; + } + + 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_YELLOW: return ONLP_LED_MODE_YELLOW; + case FAN_LED_MODE_YELLOW_BLINKING: return ONLP_LED_MODE_YELLOW_BLINKING; + default: return ONLP_LED_MODE_OFF; + } + case LED_LOCATOR: + switch (led_ligth_mode) { + case LOCATOR_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case LOCATOR_LED_MODE_BLUE: return ONLP_LED_MODE_BLUE; + case LOCATOR_LED_MODE_BLUE_BLINKING: return ONLP_LED_MODE_BLUE_BLINKING; + default: return ONLP_LED_MODE_OFF; + } + case LED_POWER: + switch (led_ligth_mode) { + case POWER_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case POWER_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case POWER_LED_MODE_YELLOW_BLINKING: return ONLP_LED_MODE_YELLOW_BLINKING; + case POWER_LED_MODE_YELLOW: return ONLP_LED_MODE_YELLOW; + default: return ONLP_LED_MODE_OFF; + } + case LED_FAN_TRAY0: + case LED_FAN_TRAY1: + case LED_FAN_TRAY2: + switch (led_ligth_mode) { + case FAN_TRAY_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case FAN_TRAY_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case FAN_TRAY_LED_MODE_YELLOW: return ONLP_LED_MODE_YELLOW; + 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_YELLOW: return SYS_LED_MODE_YELLOW ; + case ONLP_LED_MODE_YELLOW_BLINKING: return SYS_LED_MODE_YELLOW_BLINKING; + default: return SYS_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_YELLOW: return FAN_LED_MODE_YELLOW; + case ONLP_LED_MODE_YELLOW_BLINKING: return FAN_LED_MODE_YELLOW_BLINKING; + default: return FAN_LED_MODE_UNKNOWN; + } + case LED_LOCATOR: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return LOCATOR_LED_MODE_OFF; + case ONLP_LED_MODE_BLUE: return LOCATOR_LED_MODE_BLUE; + case ONLP_LED_MODE_BLUE_BLINKING: return LOCATOR_LED_MODE_BLUE_BLINKING; + default: return LOCATOR_LED_MODE_UNKNOWN; + } + case LED_POWER: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return POWER_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return POWER_LED_MODE_GREEN; + case ONLP_LED_MODE_YELLOW_BLINKING: return POWER_LED_MODE_YELLOW_BLINKING; + case ONLP_LED_MODE_YELLOW: return POWER_LED_MODE_YELLOW; + default: return POWER_LED_MODE_UNKNOWN; + } + case LED_FAN_TRAY0: + case LED_FAN_TRAY1: + case LED_FAN_TRAY2: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return FAN_TRAY_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return FAN_TRAY_LED_MODE_GREEN; + case ONLP_LED_MODE_YELLOW: return FAN_TRAY_LED_MODE_YELLOW; + default: return FAN_TRAY_LED_MODE_UNKNOWN; + } + } + + return 0xff; +} + +/* + * 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 ag7648c_product_id pid = get_product_id(); + int lid = ONLP_OID_ID_GET(id); + + if (pid != PID_AG7648C) { + return lid; + } + + switch (lid) { + case 1: return LED_SYS; + case 2: return LED_FAN; + case 3: return LED_LOCATOR; + case 4: return LED_POWER; + case 5: return LED_FAN_TRAY2; + case 6: return LED_FAN_TRAY1; + case 7: return LED_FAN_TRAY0; + } + + return lid; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int r_data,m_data; + + VALIDATE(id); + int lid = onlp_ledi_oid_to_internal_id(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[lid]; + + DEBUG_PRINT("id %u lid %d\n", id, lid); + + switch (lid) + { + case LED_POWER: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_POWER_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_POWER_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_SYS: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_SYS_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_SYS_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_LOCATOR: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_SYS_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_LOCATOR_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + + case LED_FAN: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_FAN_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_FAN_TRAY0: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_FAN_TRAY0_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_FAN_TRAY1: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_FAN_TRAY1_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_FAN_TRAY2: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_FAN_TRAY2_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + default: + return ONLP_STATUS_E_INTERNAL; + } + + 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 reg; + + VALIDATE(id); + int lid = onlp_ledi_oid_to_internal_id(id); + + driver_mode = conver_onlp_led_light_mode_to_driver(lid, mode); + + if((driver_mode==SYS_LED_MODE_UNKNOWN)||(driver_mode==FAN_LED_MODE_UNKNOWN)||(driver_mode==FAN_TRAY_LED_MODE_UNKNOWN) ||\ + (driver_mode==POWER_LED_MODE_UNKNOWN)||(driver_mode==LOCATOR_LED_MODE_UNKNOWN)) + return ONLP_STATUS_E_UNSUPPORTED; + + switch (lid) + { + case LED_POWER: + reg = CPLD_LED_POWER_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_POWER_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_POWER_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_POWER_REG_OFFSET; + break; + case LED_SYS: + reg = CPLD_LED_SYS_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_SYS_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_SYS_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_SYS_REG_OFFSET; + break; + case LED_LOCATOR: + reg = CPLD_LED_SYS_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_SYS_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_LOCATOR_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_LOCATOR_REG_OFFSET; + break; + + case LED_FAN: + reg = CPLD_LED_FAN_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_FAN_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_FAN_REG_OFFSET; + break; + case LED_FAN_TRAY0: + reg = CPLD_LED_FAN_TRAY_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_FAN_TRAY0_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_FAN_TRAY0_REG_OFFSET; + break; + case LED_FAN_TRAY1: + reg = CPLD_LED_FAN_TRAY_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_FAN_TRAY1_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_FAN_TRAY1_REG_OFFSET; + break; + case LED_FAN_TRAY2: + reg = CPLD_LED_FAN_TRAY_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_FAN_TRAY2_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_FAN_TRAY2_REG_OFFSET; + break; + default: + return ONLP_STATUS_E_INTERNAL; + } + + rc=i2c_devname_write_byte(CPLD_NAME2, reg, r_data); + + 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; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..b68adf14 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_delta_ag7648c +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.c new file mode 100755 index 00000000..2a0eb3f7 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,58 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2015 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define I2C_PSU_MODEL_NAME_LEN 13 + +psu_type_t get_psu_type(int id) +{ + if ((id == PSU1_ID)||(id == PSU2_ID)) + return PSU_TYPE_AC_F2B; + return PSU_TYPE_UNKNOWN; +} + +enum ag7648c_product_id get_product_id(void) +{ + return PID_AG7648C; +} + +int chassis_fan_count(void) +{ + return 8 ; +} + +int chassis_led_count(void) +{ + return 7; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.h new file mode 100755 index 00000000..cc376207 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2015 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_delta_ag7648c_log.h" + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 6 +#define CHASSIS_PSU_COUNT 2 + + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F, + PSU_TYPE_DC_48V_F2B, + PSU_TYPE_DC_48V_B2F +} psu_type_t; + + +psu_type_t get_psu_type(int id); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) \ + {\ + printf("[%s:%d] ", __FUNCTION__, __LINE__);\ + printf(format, __VA_ARGS__); \ + } +#else + #define DEBUG_PRINT(format, ...) +#endif + +enum onlp_fan_duty_cycle_percentage +{ + FAN_IDLE_RPM = 7500, + FAN_LEVEL1_RPM = 10000, + FAN_LEVEL2_RPM = 13000, + FAN_LEVEL3_RPM = 16000, + FAN_LEVEL4_RPM = 19000, +}; + +enum ag7648c_product_id { + PID_AG7648C= 2, + PID_UNKNOWN +}; +/* LED related data */ +enum sys_led_light_mode { + SYS_LED_MODE_GREEN_BLINKING = 0, + SYS_LED_MODE_GREEN, + SYS_LED_MODE_YELLOW, + SYS_LED_MODE_YELLOW_BLINKING, + SYS_LED_MODE_UNKNOWN +}; + +enum fan_led_light_mode { + FAN_LED_MODE_OFF = 0, + FAN_LED_MODE_YELLOW, + FAN_LED_MODE_GREEN, + FAN_LED_MODE_YELLOW_BLINKING, + FAN_LED_MODE_UNKNOWN +}; + + +enum locator_led_light_mode { + LOCATOR_LED_MODE_OFF = 0, + LOCATOR_LED_MODE_BLUE_BLINKING, + LOCATOR_LED_MODE_BLUE, + LOCATOR_LED_MODE_RESERVERD, + LOCATOR_LED_MODE_UNKNOWN +}; + +enum power_led_light_mode { + POWER_LED_MODE_OFF = 0, + POWER_LED_MODE_YELLOW, + POWER_LED_MODE_YELLOW_BLINKING, + POWER_LED_MODE_GREEN, + POWER_LED_MODE_UNKNOWN +}; + +enum fan_tray_led_light_mode { + FAN_TRAY_LED_MODE_OFF = 0, + FAN_TRAY_LED_MODE_GREEN, + FAN_TRAY_LED_MODE_YELLOW, + FAN_TRAY_LED_MODE_RESERVERD, + FAN_TRAY_LED_MODE_UNKNOWN +}; + +typedef enum onlp_led_id +{ + LED_RESERVED = 0, + LED_SYS, + LED_FAN, + LED_LOCATOR, + LED_POWER, + LED_FAN_TRAY2, + LED_FAN_TRAY1, + LED_FAN_TRAY0, +} onlp_led_id_t; + +enum ag7648c_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_DELTA_AG7648C_R0, +} platform_id_t; + +extern platform_id_t platform_id; +extern int psu_status_info_get(int id, char *node); +#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/psui.c new file mode 100755 index 00000000..4dd63133 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/psui.c @@ -0,0 +1,344 @@ +/************************************************************ + * + * + * 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_delta_ag7648c_int.h" +#include "x86_64_delta_i2c.h" +#include "eeprom_info.h" +#define CPLD_PSU_NAME "MASTERCPLD" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 0 +#define PSU_STATUS_REG (0X03) +#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; + char r_data; + ret=i2c_devname_read_byte(CPLD_PSU_NAME,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; + + if(PSU1_ID == id) + dev_name="PSU1_PMBUS"; + else + dev_name="PSU2_PMBUS"; + + 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 i,r_data,re_cnt; + uint8_t eeprom[256]={0}; + char *dev_name; + + if(PSU1_ID == id) + dev_name="PSU1_EEPROM"; + else + dev_name="PSU2_EEPROM"; + + for(i=0;istatus &= ~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,"psu_series",info->serial); + if (ret <0) { + strcpy(info->serial,"Unknown"); + } + + /* Get PSU model + */ + ret=psu_serial_model_info_get(index,"psu_model",info->model); + if (ret <0) { + strcpy(info->model,"Unknown"); + } + + return ONLP_STATUS_OK; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sfpi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sfpi.c new file mode 100755 index 00000000..ae77cc62 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,439 @@ +/************************************************************ + * + * + * 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "platform_lib.h" + +#include +#include "x86_64_delta_ag7648c_log.h" +#include "x86_64_delta_i2c.h" + +#define QSFP_MIN_PORT 49 +#define QSFP_MAX_PORT 54 + +#define QSFP_49_54_PRESENT_REG (0xC) +#define QSFP_49_54_LP_MODE_REG (0xB) +#define QSFP_49_54_RESET_REG (0xD) +#define INVALID_REG (0xFF) +#define INVALID_REG_BIT (0xFF) + + +struct portCtrl{ + int portId; + char cpldName[32]; + int presentReg; + int presentRegBit; + int lpModeReg; + int lpModeRegBit; + int resetReg; + int resetRegBit; + +}; + +#define CPLD_NAME1 "SYSCPLD" +#define CPLD_NAME2 "MASTERCPLD" +#define CPLD_NAME3 "SLAVECPLD" + +static struct portCtrl gPortCtrl[] = +{ + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {49, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 0, QSFP_49_54_LP_MODE_REG, 1, QSFP_49_54_RESET_REG, 0}, + {50, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 1, QSFP_49_54_LP_MODE_REG, 0, QSFP_49_54_RESET_REG, 1}, + {51, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 2, QSFP_49_54_LP_MODE_REG, 3, QSFP_49_54_RESET_REG, 2}, + {52, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 3, QSFP_49_54_LP_MODE_REG, 2, QSFP_49_54_RESET_REG, 3}, + {53, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 4, QSFP_49_54_LP_MODE_REG, 5, QSFP_49_54_RESET_REG, 4}, + {54, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 5, QSFP_49_54_LP_MODE_REG, 4, QSFP_49_54_RESET_REG, 5}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG_BIT, 0}, + + +}; + +/************************************************************ + * + * 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_DELTA_AG7648C_R0) + { + start_port = QSFP_MIN_PORT; + end_port = QSFP_MAX_PORT; + } + 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 >= QSFP_MIN_PORT) && (port <= QSFP_MAX_PORT)){ + r_data=i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].presentReg); + } + 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; + } + r_data = (~r_data) & 0xFF; + + present = (r_data >> gPortCtrl[port - 1].presentRegBit) & 0x1; + + 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_DELTA_AG7648C_R0) + { + port = QSFP_MIN_PORT; + + } + else{ + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + /*read 8 ports present status once*/ + for (i = port; i <= QSFP_MAX_PORT;) + { + /* + AIM_LOG_ERROR("port %d, cpldname %s, reg %d\r\n", i, gPortCtrl[i - 1].cpldName, \ + gPortCtrl[i - 1].presentReg); + */ + status = i2c_devname_read_byte(gPortCtrl[i - 1].cpldName, gPortCtrl[i - 1].presentReg); + + if(status<0){ + AIM_LOG_ERROR("Unable to read presence from the port %d to %d value(status %d) \r\n", i, i + 8, status); + return ONLP_STATUS_E_INTERNAL; + } + status = ~(status) & 0xFF; + presence_all |= (uint64_t)(status); + + i += 8; + } + + /* Populate bitmap */ + for(i = port; 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) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +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[32]; + + //int i,re_cnt;uint8_t r_data; + memset(data, 0, 256); + memset(sfp_name, 0x0, sizeof(sfp_name)); + + if (port < QSFP_MIN_PORT || port > QSFP_MAX_PORT) + { + AIM_LOG_ERROR("port %d is not invalid\r\n", port); + return ONLP_STATUS_E_INVALID; + } + if (onlp_sfpi_is_present(port) <= 0) + { + AIM_LOG_WARN("port %d is note present or error\r\n", port); + return ONLP_STATUS_E_MISSING; + } + + sprintf(sfp_name, "QSFP%d", port); + for(i=0;i<8;i++){ + if (i2c_devname_read_block(sfp_name, (32*i), (uint8_t*)(data+32*i), 32) < 0) + { + AIM_LOG_ERROR("Unable to read the port %d eeprom\r\n", port); + 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_supported(int port, onlp_sfp_control_t control, int* rv) +{ + *rv = 0; + + if (port < QSFP_MIN_PORT || port > QSFP_MAX_PORT) + { + AIM_LOG_ERROR("port %d is not invalid\r\n", port); + return ONLP_STATUS_E_INVALID; + } + + if (control > ONLP_SFP_CONTROL_LAST) + return ONLP_STATUS_E_UNSUPPORTED; + + switch (control) { + case ONLP_SFP_CONTROL_LP_MODE: + *rv = 1; + break; + + case ONLP_SFP_CONTROL_RESET_STATE: + case ONLP_SFP_CONTROL_RESET: + *rv = 1; + break; + default: + break; + } + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int r_data,dis_value,rc; + + if (port < QSFP_MIN_PORT || port > QSFP_MAX_PORT) + { + AIM_LOG_ERROR("port %d is not invalid\r\n", port); + return ONLP_STATUS_E_INVALID; + } + + if (control > ONLP_SFP_CONTROL_LAST) + return ONLP_STATUS_E_UNSUPPORTED; + + switch(control) + { + case ONLP_SFP_CONTROL_LP_MODE: + { + r_data = i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].lpModeReg); + if(r_data<0){ + AIM_LOG_INFO("Unable to read sfp lp mode reg value\r\n"); + return ONLP_STATUS_E_INTERNAL; + } + + r_data &= ~(0x1 << gPortCtrl[port - 1].lpModeRegBit); + dis_value = value << gPortCtrl[port - 1].lpModeRegBit; + dis_value |= r_data; + rc = i2c_devname_write_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].lpModeReg, dis_value); + + if (rc<0) { + AIM_LOG_ERROR("Unable to set lp_mode status to port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_RESET: + { + r_data = i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].resetReg); + if(r_data<0){ + AIM_LOG_INFO("Unable to read sfp reset reg value\r\n"); + return ONLP_STATUS_E_INTERNAL; + } + + r_data &= ~(0x1 << gPortCtrl[port - 1].resetRegBit); + dis_value = (~value) << gPortCtrl[port - 1].resetRegBit; + dis_value |= r_data; + rc = i2c_devname_write_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].resetReg, dis_value); + + if (rc<0) { + AIM_LOG_ERROR("Unable to reset 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; + + if (port < QSFP_MIN_PORT || port > QSFP_MAX_PORT) + { + AIM_LOG_ERROR("port %d is not invalid\r\n", port); + return ONLP_STATUS_E_INVALID; + } + if (control > ONLP_SFP_CONTROL_LAST) + return ONLP_STATUS_E_UNSUPPORTED; + + switch(control) + { + case ONLP_SFP_CONTROL_LP_MODE: + { + r_data=i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].lpModeReg); + + if (r_data<0) { + AIM_LOG_ERROR("Unable to read lp_mode status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + r_data &= (0x1 << gPortCtrl[port - 1].lpModeRegBit); + *value = (r_data >> gPortCtrl[port - 1].lpModeRegBit); + break; + } + + case ONLP_SFP_CONTROL_RESET_STATE: + case ONLP_SFP_CONTROL_RESET: + { + r_data=i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].resetReg); + + if (r_data<0) { + AIM_LOG_ERROR("Unable to read reset status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + r_data = (~r_data) & 0xFF; + *value = (r_data >> gPortCtrl[port - 1].presentRegBit) & 0x1; + break; + } + + default: + return ONLP_STATUS_E_UNSUPPORTED; + } + + + return ONLP_STATUS_OK; +} + + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sysi.c new file mode 100755 index 00000000..49af2088 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,300 @@ +/************************************************************ + * + * + * 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "x86_64_delta_ag7648c_int.h" +#include "x86_64_delta_ag7648c_log.h" + +#include "platform_lib.h" +#include "x86_64_delta_i2c.h" +platform_id_t platform_id = PLATFORM_ID_UNKNOWN; + +#define ONIE_PLATFORM_NAME "x86-64-delta-ag7648c-r0" +const char* +onlp_sysi_platform_get(void) +{ + enum ag7648c_product_id pid = get_product_id(); + + if (pid == PID_AG7648C) + return "x86-64-delta-ag7648c"; + else + return "unknow"; +} + +int +onlp_sysi_platform_set(const char* platform) +{ + if(strstr(platform,"x86-64-delta-ag7648c-r0")) { + platform_id = PLATFORM_ID_DELTA_AG7648C_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("SYSCPLD", 0X0); + + pi->cpld_versions = aim_fstrdup("%d", v & 0xf); + + return 0; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + int i,re_cnt; + uint8_t* rdata = aim_zmalloc(256); + if(!rdata){ + AIM_LOG_ERROR("Unable to malloc memory \r\n"); + return ONLP_STATUS_E_INTERNAL; + } + for(i=0;i<8;i++){ + re_cnt=3; + while(re_cnt){ + if (i2c_devname_read_block("ID_EEPROM", i * 32, (rdata + i * 32), 32) < 0) + { + re_cnt--; + continue; + } + break; + } + if(re_cnt==0){ + AIM_LOG_ERROR("Unable to read the %d reg \r\n",i); + break; + } + + } + + *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_onie_info_get(onlp_onie_info_t* onie) +{ + if(onie){ + onie->platform_name = aim_strdup(ONIE_PLATFORM_NAME); + } + return ONLP_STATUS_OK; +} + + + +int +onlp_sysi_platform_manage_fans(void) +{ + + int rc; + onlp_thermal_info_t ti2, ti3, ti4; + int mtemp=0; + int new_rpm=0; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* Get temperature */ + /*rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1); + + if (rc != ONLP_STATUS_OK) { + return rc; + }*/ + + rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(3), &ti3); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + + rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(4), &ti4); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + + mtemp=(ti2.mcelsius+ti3.mcelsius + ti4.mcelsius) / 3; + + DEBUG_PRINT("mtemp %d\n", mtemp); + + /* Bring fan speed according the temp + */ + + if(mtemp<25000) + new_rpm=FAN_IDLE_RPM; + else if((mtemp>=30000)&&(mtemp<40000)) + new_rpm=FAN_LEVEL1_RPM; + else if((mtemp>=45000)&&(mtemp<55000)) + new_rpm=FAN_LEVEL2_RPM; + else if((mtemp>=60000)&&(mtemp<75000)) + new_rpm=FAN_LEVEL3_RPM; + else if(mtemp>=80000) + new_rpm=FAN_LEVEL4_RPM; + else{ + return ONLP_STATUS_OK; + } + + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(3),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(4),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(5),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(6),new_rpm); + + return ONLP_STATUS_OK; +} + + +int +onlp_sysi_platform_manage_leds(void) +{ + int i,tray_i,rc; + onlp_fan_info_t info; + onlp_led_mode_t fan_new_mode; + onlp_led_mode_t fan_tray_new_mode[3]; + onlp_psu_info_t psu; + onlp_led_mode_t psu_new_mode; + onlp_led_mode_t sys_new_mode; + onlp_led_mode_t locator_new_mode; + /*fan led */ + /*fan led */ + for(tray_i=0;tray_i<3;tray_i++){ + for(i=CHASSIS_FAN_COUNT-2*tray_i;i>=CHASSIS_FAN_COUNT-2*tray_i-1;i--){ + rc=onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &info); + if ((rc != ONLP_STATUS_OK) ||((info.status&0x1)!=1)){ + fan_tray_new_mode[tray_i]=ONLP_LED_MODE_OFF; + goto tray_next; + } + else{ + if((info.status&0x2)==1){ + fan_tray_new_mode[tray_i]=ONLP_LED_MODE_YELLOW; + goto tray_next; + } + } + } + fan_tray_new_mode[tray_i]=ONLP_LED_MODE_GREEN; +tray_next: continue; + } + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY0),fan_tray_new_mode[0]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY1),fan_tray_new_mode[1]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY2),fan_tray_new_mode[2]); + + if((fan_tray_new_mode[0]==ONLP_LED_MODE_GREEN)&&(fan_tray_new_mode[1]==ONLP_LED_MODE_GREEN)&& + (fan_tray_new_mode[2]==ONLP_LED_MODE_GREEN)) + fan_new_mode=ONLP_LED_MODE_GREEN; + else if((fan_tray_new_mode[0]==ONLP_LED_MODE_OFF)||(fan_tray_new_mode[1]==ONLP_LED_MODE_OFF)|| + (fan_tray_new_mode[2]==ONLP_LED_MODE_OFF)) + fan_new_mode=ONLP_LED_MODE_YELLOW; + else + fan_new_mode=ONLP_LED_MODE_YELLOW_BLINKING; + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN),fan_new_mode); + /*psu1 and psu2 led */ + for(i=1;i<=CHASSIS_PSU_COUNT;i++){ + rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(i),&psu); + + if (rc != ONLP_STATUS_OK) { + continue; + } + if((psu.status&0x1)&&!(psu.status&0x2)){ + psu_new_mode=ONLP_LED_MODE_GREEN; + goto sys_led; + } + } + psu_new_mode=ONLP_LED_MODE_YELLOW_BLINKING; + +sys_led : + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_POWER),psu_new_mode); + //sys led ---------------- + if((fan_new_mode!=ONLP_LED_MODE_GREEN)||(psu_new_mode!=ONLP_LED_MODE_GREEN)) + sys_new_mode=ONLP_LED_MODE_YELLOW_BLINKING; + else + sys_new_mode=ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS),sys_new_mode); + + locator_new_mode=ONLP_LED_MODE_BLUE; + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOCATOR),locator_new_mode); + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/thermali.c new file mode 100755 index 00000000..8e18624a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,229 @@ +/************************************************************ + * + * + * 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. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_delta_ag7648c_log.h" +#include +#include "x86_64_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_CPU, + THERMAL_1_CLOSE_TO_MAC, + THERMAL_2_CLOSE_TO_PHY_SFP_PLUS, + THERMAL_3_CLOSE_TO_PHY_QSFP, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* last_path[] = /* must map with onlp_thermal_id */ +{ + "reserved", + "2-004d/hwmon/hwmon1/temp1_input", + "3-004c/hwmon/hwmon2/temp1_input", + "3-004d/hwmon/hwmon3/temp1_input", + "3-004e/hwmon/hwmon4/temp1_input", +}; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_CLOSE_TO_CPU), "Thermal Sensor 1- close to cpu", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_CLOSE_TO_MAC), "Thermal Sensor 2- 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_SFP_PLUS), "Thermal Sensor 3- close to sfp+ phy", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_CLOSE_TO_PHY_QSFP), "Thermal Sensor 4- close to qsfp 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 5", 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 6", ONLP_PSU_ID_CREATE(2)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/*thermali val to real tempeture*/ +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. + */ +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); + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + /* get fullpath */ + sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]); + + //OPEN_READ_FILE(fd, fullpath, r_data, nbytes, len); + 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; +} + +/*psu temperture info get*/ +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 ag7648c_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"); + if(psu_present != 1){ + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + psu_good= psu_status_info_get(psu_id,"good"); + if(psu_good != 0){ + info->status |= ONLP_THERMAL_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + //read the pus temperture register value + if(pid == PID_AG7648C){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d); + } + else{ + DEBUG_PRINT("\n[Debug][%s][%d][unsupported board:%d]", __FUNCTION__, __LINE__, pid); + return ONLP_STATUS_E_UNSUPPORTED; + } + 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); + + if((local_id > THERMAL_1_ON_PSU2) || (local_id < THERMAL_1_CLOSE_TO_CPU)){ + DEBUG_PRINT("\n[Debug][%s][%d][outside addr:%d]", __FUNCTION__, __LINE__, local_id); + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; + return ONLP_STATUS_E_INVALID; + } + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + 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_thermali_info_get(local_id,info); + + return rc; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_config.c new file mode 100755 index 00000000..3cabebd2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_delta_ag7648c_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(_x) __x86_64_delta_ag7648c_config_STRINGIFY_NAME(_x) +x86_64_delta_ag7648c_config_settings_t x86_64_delta_ag7648c_config_settings[] = +{ +#ifdef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_delta_ag7648c_config_STRINGIFY_VALUE +#undef __x86_64_delta_ag7648c_config_STRINGIFY_NAME + +const char* +x86_64_delta_ag7648c_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_delta_ag7648c_config_settings[i].name; i++) { + if(strcmp(x86_64_delta_ag7648c_config_settings[i].name, setting)) { + return x86_64_delta_ag7648c_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_delta_ag7648c_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_delta_ag7648c_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_delta_ag7648c_config_settings[i].name, x86_64_delta_ag7648c_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_enums.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_enums.c new file mode 100755 index 00000000..7eb66a72 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_int.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_int.h new file mode 100755 index 00000000..0006e5eb --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_delta_ag7648c Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_delta_ag7648c_INT_H__ +#define __x86_64_delta_ag7648c_INT_H__ + +#include + + +#endif /* __x86_64_delta_ag7648c_INT_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.c new file mode 100755 index 00000000..3f53bd83 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_delta_ag7648c_log.h" +/* + * x86_64_delta_ag7648c log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.h new file mode 100755 index 00000000..1683bbfb --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_delta_ag7648c_LOG_H__ +#define __x86_64_delta_ag7648c_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_delta_ag7648c +#include + +#endif /* __x86_64_delta_ag7648c_LOG_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_module.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_module.c new file mode 100755 index 00000000..a984cdf5 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_delta_ag7648c_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_delta_ag7648c_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_delta_ag7648c_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_ucli.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_ucli.c new file mode 100755 index 00000000..9dd339b1 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_delta_ag7648c_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_delta_ag7648c) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_delta_ag7648c_ucli_module__ = + { + "x86_64_delta_ag7648c_ucli", + NULL, + x86_64_delta_ag7648c_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_delta_ag7648c_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_delta_ag7648c_ucli_module__); + n = ucli_node_create("x86_64_delta_ag7648c", NULL, &x86_64_delta_ag7648c_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_delta_ag7648c")); + return n; +} + +#else +void* +x86_64_delta_ag7648c_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.c new file mode 100755 index 00000000..13d29c48 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.c @@ -0,0 +1,148 @@ +/************************************************************ + * + * + * Copyright 2018 Delta Technology Corporation. + * Copyright 2018 Delta Networks, Inc + + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "x86_64_delta_ag7648c_log.h" +#include "x86_64_delta_i2c.h" +#include +struct i2c_device_info i2c_device_list[]={ + {"RTC",0X0,0X69}, + {"TMP1_CLOSE_TO_CPU",0X2,0X4d}, + {"TMP1_CLOSE_TO_MAC",0X3,0X4c}, + {"TMP2_CLOSE_TO_SFP_PLUS",0X3,0X4d}, + {"TMP3_CLOSE_TO_QSFP",0X3,0X4E}, + {"SYSCPLD",0X2,0X31}, + {"MASTERCPLD",0X2,0X32}, + {"FAN1EEPROM",0X3,0X51}, + {"FAN2EEPROM",0X3,0X52}, + {"FAN3EEPROM",0X3,0X53}, + {"FANCTRL1",0X3,0X2A}, + {"FANCTRL2",0X3,0X29}, + {"CURT_MONTOR",0X1,0X40}, + {"ID_EEPROM",0X2,0X53}, + {"QSFP49",0XA,0X50}, + {"QSFP50",0XB,0X50}, + {"QSFP51",0XC,0X50}, + {"QSFP52",0XD,0X50}, + {"QSFP53",0XE,0X50}, + {"QSFP54",0XF,0X50}, +// ------------------------- + {"PSU1_PMBUS",0X6,0X58}, + {"PSU2_PMBUS",0X6,0X59}, + {"PSU1_EEPROM",0X6,0X50}, + {"PSU2_EEPROM",0X6,0X51}, + + {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; + +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.h new file mode 100755 index 00000000..92a4ee1e --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.h @@ -0,0 +1,49 @@ +/************************************************************ + * + * + * Copyright 2018 Delta Technology Corporation. + * Copyright 2018 Delta Networks, Inc + * + * 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. + * + * + ************************************************************/ +/* the i2c struct header*/ + +#ifndef __X86_64_DELTA_I2C_H__ +#define __X86_64_DELTA_I2C_H__ + +#include "x86_64_delta_ag7648c_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); +//extern int i2c_devname_write_block(char *name, int reg, char *buff, int buff_size); + +#endif diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/x86_64_delta_ag7648c.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/x86_64_delta_ag7648c.mk new file mode 100755 index 00000000..1f82839d --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/x86_64_delta_ag7648c.mk @@ -0,0 +1,13 @@ + +############################################################################### +# +# Inclusive Makefile for the x86_64_delta_ag7648c module. +# +# Autogenerated 2017-03-20 15:05:23.627200 +# +############################################################################### +x86_64_delta_ag7648c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(x86_64_delta_ag7648c_BASEDIR)module/make.mk +include $(x86_64_delta_ag7648c_BASEDIR)module/auto/make.mk +include $(x86_64_delta_ag7648c_BASEDIR)module/src/make.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/PKG.yml new file mode 100644 index 00000000..0d86acc6 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=delta BASENAME=x86-64-delta-ag7648c REVISION=r0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/lib/x86-64-delta-ag7648c-r0.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/lib/x86-64-delta-ag7648c-r0.yml new file mode 100755 index 00000000..2b5a6a3c --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/lib/x86-64-delta-ag7648c-r0.yml @@ -0,0 +1,32 @@ +--- + +###################################################################### +# +# platform-config for AG7648C +# +###################################################################### + +x86-64-delta-ag7648c-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + acpi=off + console=ttyS0,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/python/x86_64_delta_ag7648c_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/python/x86_64_delta_ag7648c_r0/__init__.py new file mode 100644 index 00000000..e5c25662 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/python/x86_64_delta_ag7648c_r0/__init__.py @@ -0,0 +1,28 @@ +from onl.platform.base import * +from onl.platform.delta import * + +class OnlPlatform_x86_64_delta_ag7648c_r0(OnlPlatformDelta,OnlPlatformPortConfig_48x10_6x40): + + PLATFORM='x86-64-delta-ag7648c-r0' + MODEL="AG7648C" + SYS_OBJECT_ID=".7648c.1" + + def baseconfig(self): + self.new_i2c_device('pca9547', 0x70, 1); + + self.insmod('x86-64-delta-ag7648c-cpld-mux.ko') + ########### initialize I2C bus 0 ########### + + + self.new_i2c_devices( + [ + ('clock_gen', 0x69, 0), + ('tmp75', 0x4d, 2), + ('tmp75', 0x4c, 3), + ('tmp75', 0x4d, 3), + ('tmp75', 0x4e, 3), + ] + ) + + + return True