mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-11-03 11:48:17 +00:00
Add new platform as7716-24sc / as7716-24xc
This commit is contained in:
3
packages/platforms/accton/x86-64/x86-64-accton-as7716-24sc/.gitignore
vendored
Normal file
3
packages/platforms/accton/x86-64/x86-64-accton-as7716-24sc/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*x86*64*accton*as7716*24sc*.mk
|
||||
onlpdump.mk
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as7716-24sc ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64"
|
||||
1
packages/platforms/accton/x86-64/x86-64-accton-as7716-24sc/modules/builds/.gitignore
vendored
Normal file
1
packages/platforms/accton/x86-64/x86-64-accton-as7716-24sc/modules/builds/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -0,0 +1,6 @@
|
||||
KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64
|
||||
KMODULES := $(wildcard *.c)
|
||||
VENDOR := accton
|
||||
BASENAME := x86-64-accton-as7716-24sc
|
||||
ARCH := x86_64
|
||||
include $(ONL)/make/kmodule.mk
|
||||
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
* An hwmon driver for accton as7716_24sc Transceiver Expansion Card
|
||||
*
|
||||
* Copyright (C) 2014 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* Based on ad7414.c
|
||||
* Copyright 2006 Stefan Roese <sr at denx.de>, DENX Software Engineering
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define CPLD_I2C_ADDR 0x60
|
||||
#define EXPANSION_CARD_PRESENT_REG 0x7A
|
||||
|
||||
static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t set_slot(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count) ;
|
||||
extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg);
|
||||
|
||||
/* Addresses scanned
|
||||
*/
|
||||
static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
|
||||
|
||||
enum as7716_24sc_expansion_card_sysfs_attributes {
|
||||
CARD_TYPE,
|
||||
CARD_SLOT,
|
||||
CARD_PRESENT,
|
||||
NUM_OF_ATTR
|
||||
};
|
||||
|
||||
/* Each client has this additional data
|
||||
*/
|
||||
struct as7716_24sc_expansion_card_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 driver_slot;
|
||||
u8 status[NUM_OF_ATTR]; /* 0: card type
|
||||
1: card slot
|
||||
2: card presence */
|
||||
};
|
||||
|
||||
static struct as7716_24sc_expansion_card_data *update_device(struct device *dev, int update_all);
|
||||
|
||||
/* sysfs attributes for hwmon
|
||||
*/
|
||||
static SENSOR_DEVICE_ATTR(card_present, S_IRUGO, show_present, NULL, CARD_PRESENT);
|
||||
static SENSOR_DEVICE_ATTR(card_type, S_IRUGO, show_status, NULL, CARD_TYPE);
|
||||
static SENSOR_DEVICE_ATTR(card_slot, S_IWUSR | S_IRUGO, show_status, set_slot, CARD_SLOT);
|
||||
|
||||
static struct attribute *as7716_24sc_expansion_card_attributes[] = {
|
||||
&sensor_dev_attr_card_present.dev_attr.attr,
|
||||
&sensor_dev_attr_card_type.dev_attr.attr,
|
||||
&sensor_dev_attr_card_slot.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static ssize_t show_present(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct as7716_24sc_expansion_card_data *data = update_device(dev, 0);
|
||||
ssize_t status = 0;
|
||||
u8 present = !(data->status[CARD_PRESENT] & BIT(data->driver_slot));
|
||||
|
||||
if (!data->valid) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return sprintf(buf, "%d\n", (int)present);
|
||||
}
|
||||
|
||||
static ssize_t show_status(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct as7716_24sc_expansion_card_data *data = update_device(dev, 1);
|
||||
ssize_t status = 0;
|
||||
u8 present = 0;
|
||||
|
||||
if (!data->valid) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
present = !(data->status[CARD_PRESENT] & BIT(data->driver_slot));
|
||||
|
||||
switch (attr->index) {
|
||||
case CARD_TYPE:
|
||||
status = present ? (data->status[CARD_TYPE] >> 4) : -EIO;
|
||||
break;
|
||||
case CARD_SLOT:
|
||||
status = present ? (data->status[CARD_SLOT] & 0x7) : -EIO;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (status < 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return sprintf(buf, "%d\n", (int)status);
|
||||
}
|
||||
|
||||
static ssize_t set_slot(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int status, value;
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
|
||||
status = kstrtoint(buf, 10, &value);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (value < 0 || value > 7)
|
||||
return -EINVAL;
|
||||
|
||||
/* Write the slot id to register 0x02 */
|
||||
status = i2c_smbus_write_byte_data(client, 0x02, value);
|
||||
if (unlikely(status < 0)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct attribute_group as7716_24sc_expansion_card_group = {
|
||||
.attrs = as7716_24sc_expansion_card_attributes,
|
||||
};
|
||||
|
||||
static int as7716_24sc_expansion_card_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct as7716_24sc_expansion_card_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
|
||||
status = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct as7716_24sc_expansion_card_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
status = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
data->valid = 0;
|
||||
data->driver_slot = dev_id->driver_data;
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
dev_info(&client->dev, "chip found\n");
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &as7716_24sc_expansion_card_group);
|
||||
if (status) {
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register_with_info(&client->dev, "as7716_24sc_expansion_card",
|
||||
NULL, NULL, NULL);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: expansion card '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24sc_expansion_card_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int as7716_24sc_expansion_card_remove(struct i2c_client *client)
|
||||
{
|
||||
struct as7716_24sc_expansion_card_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24sc_expansion_card_group);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum expansion_card_index
|
||||
{
|
||||
as7716_24sc_excard1,
|
||||
as7716_24sc_excard2,
|
||||
as7716_24sc_excard3,
|
||||
as7716_24sc_excard4,
|
||||
as7716_24sc_excard5,
|
||||
as7716_24sc_excard6,
|
||||
as7716_24sc_excard7,
|
||||
as7716_24sc_excard8
|
||||
};
|
||||
|
||||
#define I2C_DEV_ID(x) { #x, x}
|
||||
|
||||
static const struct i2c_device_id as7716_24sc_expansion_card_id[] = {
|
||||
I2C_DEV_ID(as7716_24sc_excard1),
|
||||
I2C_DEV_ID(as7716_24sc_excard2),
|
||||
I2C_DEV_ID(as7716_24sc_excard3),
|
||||
I2C_DEV_ID(as7716_24sc_excard4),
|
||||
I2C_DEV_ID(as7716_24sc_excard5),
|
||||
I2C_DEV_ID(as7716_24sc_excard6),
|
||||
I2C_DEV_ID(as7716_24sc_excard7),
|
||||
I2C_DEV_ID(as7716_24sc_excard8),
|
||||
{/* LIST END */}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, as7716_24sc_expansion_card_id);
|
||||
|
||||
static struct i2c_driver as7716_24sc_expansion_card_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "as7716_24sc_expansion_card",
|
||||
},
|
||||
.probe = as7716_24sc_expansion_card_probe,
|
||||
.remove = as7716_24sc_expansion_card_remove,
|
||||
.id_table = as7716_24sc_expansion_card_id,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
static struct as7716_24sc_expansion_card_data *update_device(struct device *dev, int update_all)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct as7716_24sc_expansion_card_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|
||||
|| !data->valid) {
|
||||
int status, i;
|
||||
u8 regs[] = {0x00, 0x02}; /* 0x00: type, 0x02: slot */
|
||||
|
||||
data->valid = 0;
|
||||
dev_dbg(&client->dev, "Starting as7716_24sc update\n");
|
||||
|
||||
/* Read present status */
|
||||
status = accton_i2c_cpld_read(CPLD_I2C_ADDR, EXPANSION_CARD_PRESENT_REG);
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status);
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
data->status[CARD_PRESENT] = status;
|
||||
}
|
||||
|
||||
/* Update card type and slot if card is present */
|
||||
if (!(data->status[CARD_PRESENT] & BIT(data->driver_slot))) {
|
||||
for (i = 0; i < ARRAY_SIZE(regs); i++) {
|
||||
status = i2c_smbus_read_byte_data(client, regs[i]);
|
||||
|
||||
if (status < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data->status[i] = status;
|
||||
}
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int __init as7716_24sc_expansion_card_init(void)
|
||||
{
|
||||
return i2c_add_driver(&as7716_24sc_expansion_card_driver);
|
||||
}
|
||||
|
||||
static void __exit as7716_24sc_expansion_card_exit(void)
|
||||
{
|
||||
i2c_del_driver(&as7716_24sc_expansion_card_driver);
|
||||
}
|
||||
|
||||
module_init(as7716_24sc_expansion_card_init);
|
||||
module_exit(as7716_24sc_expansion_card_exit);
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("as7716_24sc_expansion_card driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -0,0 +1,467 @@
|
||||
/*
|
||||
* A hwmon driver for the Accton as7716 24sc fan
|
||||
*
|
||||
* Copyright (C) 2014 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/dmi.h>
|
||||
|
||||
#define DRVNAME "as7716_24sc_fan"
|
||||
|
||||
static struct as7716_24sc_fan_data *as7716_24sc_fan_update_device(struct device *dev);
|
||||
static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count);
|
||||
|
||||
/* fan related data, the index should match sysfs_fan_attributes
|
||||
*/
|
||||
static const u8 fan_reg[] = {
|
||||
0x80, /* fan 1-6 present status */
|
||||
0x81, /* fan 1-6 direction(0:B2F 1:F2B) */
|
||||
0x87, /* fan PWM(for all fan) */
|
||||
0x90, /* front fan 1 speed(rpm) */
|
||||
0x91, /* front fan 2 speed(rpm) */
|
||||
0x92, /* front fan 3 speed(rpm) */
|
||||
0x93, /* front fan 4 speed(rpm) */
|
||||
0x98, /* rear fan 1 speed(rpm) */
|
||||
0x99, /* rear fan 2 speed(rpm) */
|
||||
0x9A, /* rear fan 3 speed(rpm) */
|
||||
0x9B, /* rear fan 4 speed(rpm) */
|
||||
};
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct as7716_24sc_fan_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* != 0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */
|
||||
};
|
||||
|
||||
enum fan_id {
|
||||
FAN1_ID,
|
||||
FAN2_ID,
|
||||
FAN3_ID,
|
||||
FAN4_ID
|
||||
};
|
||||
|
||||
enum sysfs_fan_attributes {
|
||||
FAN_PRESENT_REG,
|
||||
FAN_DIRECTION_REG,
|
||||
FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */
|
||||
FAN1_FRONT_SPEED_RPM,
|
||||
FAN2_FRONT_SPEED_RPM,
|
||||
FAN3_FRONT_SPEED_RPM,
|
||||
FAN4_FRONT_SPEED_RPM,
|
||||
FAN1_REAR_SPEED_RPM,
|
||||
FAN2_REAR_SPEED_RPM,
|
||||
FAN3_REAR_SPEED_RPM,
|
||||
FAN4_REAR_SPEED_RPM,
|
||||
FAN1_DIRECTION,
|
||||
FAN2_DIRECTION,
|
||||
FAN3_DIRECTION,
|
||||
FAN4_DIRECTION,
|
||||
FAN1_PRESENT,
|
||||
FAN2_PRESENT,
|
||||
FAN3_PRESENT,
|
||||
FAN4_PRESENT,
|
||||
FAN1_FAULT,
|
||||
FAN2_FAULT,
|
||||
FAN3_FAULT,
|
||||
FAN4_FAULT
|
||||
};
|
||||
|
||||
/* Define attributes
|
||||
*/
|
||||
#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT)
|
||||
#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_fault.dev_attr.attr
|
||||
|
||||
#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION)
|
||||
#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr
|
||||
|
||||
#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE)
|
||||
#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr
|
||||
|
||||
#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT)
|
||||
#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr
|
||||
|
||||
#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM)
|
||||
#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \
|
||||
&sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr
|
||||
|
||||
/* 6 fan fault attributes in this platform */
|
||||
DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1);
|
||||
DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2);
|
||||
DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3);
|
||||
DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4);
|
||||
/* 6 fan speed(rpm) attributes in this platform */
|
||||
DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1);
|
||||
DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2);
|
||||
DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3);
|
||||
DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4);
|
||||
/* 6 fan present attributes in this platform */
|
||||
DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1);
|
||||
DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2);
|
||||
DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3);
|
||||
DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4);
|
||||
/* 6 fan direction attribute in this platform */
|
||||
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1);
|
||||
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2);
|
||||
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3);
|
||||
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4);
|
||||
/* 1 fan duty cycle attribute in this platform */
|
||||
DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR();
|
||||
|
||||
static struct attribute *as7716_24sc_fan_attributes[] = {
|
||||
/* fan related attributes */
|
||||
DECLARE_FAN_FAULT_ATTR(1),
|
||||
DECLARE_FAN_FAULT_ATTR(2),
|
||||
DECLARE_FAN_FAULT_ATTR(3),
|
||||
DECLARE_FAN_FAULT_ATTR(4),
|
||||
DECLARE_FAN_SPEED_RPM_ATTR(1),
|
||||
DECLARE_FAN_SPEED_RPM_ATTR(2),
|
||||
DECLARE_FAN_SPEED_RPM_ATTR(3),
|
||||
DECLARE_FAN_SPEED_RPM_ATTR(4),
|
||||
DECLARE_FAN_PRESENT_ATTR(1),
|
||||
DECLARE_FAN_PRESENT_ATTR(2),
|
||||
DECLARE_FAN_PRESENT_ATTR(3),
|
||||
DECLARE_FAN_PRESENT_ATTR(4),
|
||||
DECLARE_FAN_DIRECTION_ATTR(1),
|
||||
DECLARE_FAN_DIRECTION_ATTR(2),
|
||||
DECLARE_FAN_DIRECTION_ATTR(3),
|
||||
DECLARE_FAN_DIRECTION_ATTR(4),
|
||||
DECLARE_FAN_DUTY_CYCLE_ATTR(),
|
||||
NULL
|
||||
};
|
||||
|
||||
#define FAN_DUTY_CYCLE_REG_MASK 0xF
|
||||
#define FAN_MAX_DUTY_CYCLE 100
|
||||
#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100
|
||||
#define MAX_RPM 366210
|
||||
#define REG_VAL_TO_RPM(val) (60000000000/(2*2*40960*(255-val)))
|
||||
|
||||
static int as7716_24sc_fan_read_value(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return i2c_smbus_read_byte_data(client, reg);
|
||||
}
|
||||
|
||||
static int as7716_24sc_fan_write_value(struct i2c_client *client, u8 reg, u8 value)
|
||||
{
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
}
|
||||
|
||||
/* fan utility functions
|
||||
*/
|
||||
static u32 reg_val_to_duty_cycle(u8 reg_val)
|
||||
{
|
||||
reg_val &= FAN_DUTY_CYCLE_REG_MASK;
|
||||
|
||||
if (!reg_val) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (reg_val == 0xF) {
|
||||
return FAN_MAX_DUTY_CYCLE;
|
||||
}
|
||||
|
||||
return (reg_val * 6) + 10;
|
||||
}
|
||||
|
||||
static u8 duty_cycle_to_reg_val(u8 duty_cycle)
|
||||
{
|
||||
if (duty_cycle < 16) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (duty_cycle >= 100) {
|
||||
return 0xF;
|
||||
}
|
||||
|
||||
return (duty_cycle - 10) / 6;
|
||||
}
|
||||
|
||||
static u32 reg_val_to_speed_rpm(u8 reg_val)
|
||||
{
|
||||
if (!reg_val) {
|
||||
return 0;
|
||||
}
|
||||
else if (reg_val == 0xFF) {
|
||||
return MAX_RPM;
|
||||
}
|
||||
|
||||
return REG_VAL_TO_RPM(reg_val);
|
||||
}
|
||||
|
||||
static u8 reg_val_to_direction(u8 reg_val, enum fan_id id)
|
||||
{
|
||||
u8 mask = (1 << id);
|
||||
return !!(reg_val & mask);
|
||||
}
|
||||
|
||||
static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id)
|
||||
{
|
||||
u8 mask = (1 << id);
|
||||
return !(reg_val & mask);
|
||||
}
|
||||
|
||||
static u8 is_fan_fault(struct as7716_24sc_fan_data *data, enum fan_id id)
|
||||
{
|
||||
u8 ret = 1;
|
||||
int front_fan_index = FAN1_FRONT_SPEED_RPM + id;
|
||||
int rear_fan_index = FAN1_REAR_SPEED_RPM + id;
|
||||
|
||||
/* Check if the speed of front or rear fan is ZERO,
|
||||
*/
|
||||
if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) &&
|
||||
reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int error, value;
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
|
||||
error = kstrtoint(buf, 10, &value);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (value < 0 || value > FAN_MAX_DUTY_CYCLE)
|
||||
return -EINVAL;
|
||||
|
||||
as7716_24sc_fan_write_value(client, 0x28, 0); /* Disable fan speed watch dog */
|
||||
as7716_24sc_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value));
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fan_show_value(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct as7716_24sc_fan_data *data = as7716_24sc_fan_update_device(dev);
|
||||
ssize_t ret = 0;
|
||||
|
||||
if (data->valid) {
|
||||
switch (attr->index) {
|
||||
case FAN_DUTY_CYCLE_PERCENTAGE:
|
||||
{
|
||||
u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]);
|
||||
ret = sprintf(buf, "%u\n", duty_cycle);
|
||||
break;
|
||||
}
|
||||
case FAN1_FRONT_SPEED_RPM:
|
||||
case FAN2_FRONT_SPEED_RPM:
|
||||
case FAN3_FRONT_SPEED_RPM:
|
||||
case FAN4_FRONT_SPEED_RPM:
|
||||
case FAN1_REAR_SPEED_RPM:
|
||||
case FAN2_REAR_SPEED_RPM:
|
||||
case FAN3_REAR_SPEED_RPM:
|
||||
case FAN4_REAR_SPEED_RPM:
|
||||
{
|
||||
u32 rpm = reg_val_to_speed_rpm(data->reg_val[attr->index]);
|
||||
ret = sprintf(buf, "%u\n", rpm);
|
||||
break;
|
||||
}
|
||||
case FAN1_PRESENT:
|
||||
case FAN2_PRESENT:
|
||||
case FAN3_PRESENT:
|
||||
case FAN4_PRESENT:
|
||||
ret = sprintf(buf, "%d\n",
|
||||
reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG],
|
||||
attr->index - FAN1_PRESENT));
|
||||
break;
|
||||
case FAN1_FAULT:
|
||||
case FAN2_FAULT:
|
||||
case FAN3_FAULT:
|
||||
case FAN4_FAULT:
|
||||
ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT));
|
||||
break;
|
||||
case FAN1_DIRECTION:
|
||||
case FAN2_DIRECTION:
|
||||
case FAN3_DIRECTION:
|
||||
case FAN4_DIRECTION:
|
||||
ret = sprintf(buf, "%d\n",
|
||||
reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG],
|
||||
attr->index - FAN1_DIRECTION));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct attribute_group as7716_24sc_fan_group = {
|
||||
.attrs = as7716_24sc_fan_attributes,
|
||||
};
|
||||
|
||||
static struct as7716_24sc_fan_data *as7716_24sc_fan_update_device(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct as7716_24sc_fan_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2) ||
|
||||
!data->valid) {
|
||||
int i;
|
||||
|
||||
dev_dbg(&client->dev, "Starting as7716_24sc_fan update\n");
|
||||
data->valid = 0;
|
||||
|
||||
/* Update fan data
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) {
|
||||
int status = as7716_24sc_fan_read_value(client, fan_reg[i]);
|
||||
|
||||
if (status < 0) {
|
||||
data->valid = 0;
|
||||
mutex_unlock(&data->update_lock);
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status);
|
||||
return data;
|
||||
}
|
||||
else {
|
||||
data->reg_val[i] = status;
|
||||
}
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int as7716_24sc_fan_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct as7716_24sc_fan_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
|
||||
status = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct as7716_24sc_fan_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
status = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
data->valid = 0;
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
dev_info(&client->dev, "chip found\n");
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &as7716_24sc_fan_group);
|
||||
if (status) {
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register_with_info(&client->dev, "as7716_24sc_fan",
|
||||
NULL, NULL, NULL);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: fan '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24sc_fan_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int as7716_24sc_fan_remove(struct i2c_client *client)
|
||||
{
|
||||
struct as7716_24sc_fan_data *data = i2c_get_clientdata(client);
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24sc_fan_group);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Addresses to scan */
|
||||
static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
|
||||
|
||||
static const struct i2c_device_id as7716_24sc_fan_id[] = {
|
||||
{ "as7716_24sc_fan", 0 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, as7716_24sc_fan_id);
|
||||
|
||||
static struct i2c_driver as7716_24sc_fan_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = DRVNAME,
|
||||
},
|
||||
.probe = as7716_24sc_fan_probe,
|
||||
.remove = as7716_24sc_fan_remove,
|
||||
.id_table = as7716_24sc_fan_id,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
static int __init as7716_24sc_fan_init(void)
|
||||
{
|
||||
return i2c_add_driver(&as7716_24sc_fan_driver);
|
||||
}
|
||||
|
||||
static void __exit as7716_24sc_fan_exit(void)
|
||||
{
|
||||
i2c_del_driver(&as7716_24sc_fan_driver);
|
||||
}
|
||||
|
||||
module_init(as7716_24sc_fan_init);
|
||||
module_exit(as7716_24sc_fan_exit);
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("as7716_24sc_fan driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -0,0 +1,432 @@
|
||||
/*
|
||||
* A LED driver for the as7716_24sc_led
|
||||
*
|
||||
* Copyright (C) 2014 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/*#define DEBUG*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/dmi.h>
|
||||
|
||||
extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg);
|
||||
extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value);
|
||||
|
||||
#define DRVNAME "as7716_24sc_led"
|
||||
|
||||
struct as7716_24sc_led_data {
|
||||
struct platform_device *pdev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* != 0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 reg_val[1]; /* only 1 register*/
|
||||
};
|
||||
|
||||
static struct as7716_24sc_led_data *ledctl = NULL;
|
||||
|
||||
/* LED related data
|
||||
*/
|
||||
|
||||
#define LED_CNTRLER_I2C_ADDRESS (0x60)
|
||||
|
||||
#define LED_TYPE_DIAG_REG_MASK (0x03)
|
||||
#define LED_MODE_DIAG_YELLOW_VALUE (0x00)
|
||||
#define LED_MODE_DIAG_ORANGE_VALUE (0x01)
|
||||
#define LED_MODE_DIAG_GREEN_VALUE (0x02)
|
||||
#define LED_MODE_DIAG_OFF_VALUE (0x03)
|
||||
|
||||
#define LED_TYPE_LOC_REG_MASK (0x10)
|
||||
#define LED_MODE_LOC_ORANGE_VALUE (0x00)
|
||||
#define LED_MODE_LOC_OFF_VALUE (0x10)
|
||||
|
||||
enum led_type {
|
||||
LED_TYPE_DIAG,
|
||||
LED_TYPE_LOC,
|
||||
LED_TYPE_FAN,
|
||||
LED_TYPE_PSU1,
|
||||
LED_TYPE_PSU2
|
||||
};
|
||||
|
||||
struct led_reg {
|
||||
u32 types;
|
||||
u8 reg_addr;
|
||||
};
|
||||
|
||||
static const struct led_reg led_reg_map[] = {
|
||||
{(1 << LED_TYPE_LOC) | (1 << LED_TYPE_DIAG) | (1 << LED_TYPE_FAN), 0x30},
|
||||
};
|
||||
|
||||
enum led_light_mode {
|
||||
LED_MODE_OFF,
|
||||
LED_MODE_RED = 10,
|
||||
LED_MODE_RED_BLINKING = 11,
|
||||
LED_MODE_ORANGE = 12,
|
||||
LED_MODE_ORANGE_BLINKING = 13,
|
||||
LED_MODE_YELLOW = 14,
|
||||
LED_MODE_YELLOW_BLINKING = 15,
|
||||
LED_MODE_GREEN = 16,
|
||||
LED_MODE_GREEN_BLINKING = 17,
|
||||
LED_MODE_BLUE = 18,
|
||||
LED_MODE_BLUE_BLINKING = 19,
|
||||
LED_MODE_PURPLE = 20,
|
||||
LED_MODE_PURPLE_BLINKING = 21,
|
||||
LED_MODE_AUTO = 22,
|
||||
LED_MODE_AUTO_BLINKING = 23,
|
||||
LED_MODE_WHITE = 24,
|
||||
LED_MODE_WHITE_BLINKING = 25,
|
||||
LED_MODE_CYAN = 26,
|
||||
LED_MODE_CYAN_BLINKING = 27,
|
||||
LED_MODE_UNKNOWN = 99
|
||||
};
|
||||
|
||||
struct led_type_mode {
|
||||
enum led_type type;
|
||||
enum led_light_mode mode;
|
||||
int reg_bit_mask;
|
||||
int mode_value;
|
||||
};
|
||||
|
||||
static struct led_type_mode led_type_mode_data[] = {
|
||||
{LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE},
|
||||
{LED_TYPE_LOC, LED_MODE_ORANGE,LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_ORANGE_VALUE},
|
||||
{LED_TYPE_DIAG, LED_MODE_OFF, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_OFF_VALUE},
|
||||
{LED_TYPE_DIAG, LED_MODE_GREEN, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_VALUE},
|
||||
{LED_TYPE_DIAG, LED_MODE_ORANGE,LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_ORANGE_VALUE},
|
||||
{LED_TYPE_DIAG, LED_MODE_YELLOW,LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_YELLOW_VALUE}
|
||||
};
|
||||
|
||||
static int get_led_reg(enum led_type type, u8 *reg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(led_reg_map); i++) {
|
||||
if(led_reg_map[i].types & (1 << type)) {
|
||||
*reg = led_reg_map[i].reg_addr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) {
|
||||
|
||||
if (type != led_type_mode_data[i].type)
|
||||
continue;
|
||||
|
||||
if ((led_type_mode_data[i].reg_bit_mask & reg_val) ==
|
||||
led_type_mode_data[i].mode_value)
|
||||
{
|
||||
return led_type_mode_data[i].mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u8 led_light_mode_to_reg_val(enum led_type type,
|
||||
enum led_light_mode mode, u8 reg_val) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) {
|
||||
if (type != led_type_mode_data[i].type)
|
||||
continue;
|
||||
|
||||
if (mode != led_type_mode_data[i].mode)
|
||||
continue;
|
||||
|
||||
reg_val = led_type_mode_data[i].mode_value |
|
||||
(reg_val & (~led_type_mode_data[i].reg_bit_mask));
|
||||
break;
|
||||
}
|
||||
|
||||
return reg_val;
|
||||
}
|
||||
|
||||
static int as7716_24sc_led_read_value(u8 reg)
|
||||
{
|
||||
return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg);
|
||||
}
|
||||
|
||||
static int as7716_24sc_led_write_value(u8 reg, u8 value)
|
||||
{
|
||||
return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value);
|
||||
}
|
||||
|
||||
static void as7716_24sc_led_update(void)
|
||||
{
|
||||
mutex_lock(&ledctl->update_lock);
|
||||
|
||||
if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2)
|
||||
|| !ledctl->valid) {
|
||||
int i;
|
||||
|
||||
dev_dbg(&ledctl->pdev->dev, "Starting as7716_24sc_led update\n");
|
||||
|
||||
/* Update LED data
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) {
|
||||
int status = as7716_24sc_led_read_value(led_reg_map[i].reg_addr);
|
||||
|
||||
if (status < 0) {
|
||||
ledctl->valid = 0;
|
||||
dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status);
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
ledctl->reg_val[i] = status;
|
||||
}
|
||||
}
|
||||
|
||||
ledctl->last_updated = jiffies;
|
||||
ledctl->valid = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&ledctl->update_lock);
|
||||
}
|
||||
|
||||
static void as7716_24sc_led_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness led_light_mode,
|
||||
enum led_type type)
|
||||
{
|
||||
int reg_val;
|
||||
u8 reg ;
|
||||
mutex_lock(&ledctl->update_lock);
|
||||
|
||||
if( !get_led_reg(type, ®)) {
|
||||
dev_dbg(&ledctl->pdev->dev, "Not match register for %d.\n", type);
|
||||
}
|
||||
|
||||
reg_val = as7716_24sc_led_read_value(reg);
|
||||
if (reg_val < 0) {
|
||||
dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val);
|
||||
as7716_24sc_led_write_value(reg, reg_val);
|
||||
|
||||
/* to prevent the slow-update issue */
|
||||
ledctl->valid = 0;
|
||||
|
||||
exit:
|
||||
mutex_unlock(&ledctl->update_lock);
|
||||
}
|
||||
|
||||
|
||||
static void as7716_24sc_led_diag_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness led_light_mode)
|
||||
{
|
||||
as7716_24sc_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG);
|
||||
}
|
||||
|
||||
static enum led_brightness as7716_24sc_led_diag_get(struct led_classdev *cdev)
|
||||
{
|
||||
as7716_24sc_led_update();
|
||||
return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]);
|
||||
}
|
||||
|
||||
static void as7716_24sc_led_loc_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness led_light_mode)
|
||||
{
|
||||
as7716_24sc_led_set(led_cdev, led_light_mode, LED_TYPE_LOC);
|
||||
}
|
||||
|
||||
static enum led_brightness as7716_24sc_led_loc_get(struct led_classdev *cdev)
|
||||
{
|
||||
as7716_24sc_led_update();
|
||||
return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]);
|
||||
}
|
||||
|
||||
static void as7716_24sc_led_auto_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness led_light_mode)
|
||||
{
|
||||
}
|
||||
|
||||
static enum led_brightness as7716_24sc_led_auto_get(struct led_classdev *cdev)
|
||||
{
|
||||
return LED_MODE_AUTO;
|
||||
}
|
||||
|
||||
static struct led_classdev as7716_24sc_leds[] = {
|
||||
[LED_TYPE_DIAG] = {
|
||||
.name = "as7716_24sc_led::diag",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24sc_led_diag_set,
|
||||
.brightness_get = as7716_24sc_led_diag_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_GREEN,
|
||||
},
|
||||
[LED_TYPE_LOC] = {
|
||||
.name = "as7716_24sc_led::loc",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24sc_led_loc_set,
|
||||
.brightness_get = as7716_24sc_led_loc_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_ORANGE,
|
||||
},
|
||||
[LED_TYPE_FAN] = {
|
||||
.name = "as7716_24sc_led::fan",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24sc_led_auto_set,
|
||||
.brightness_get = as7716_24sc_led_auto_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_AUTO,
|
||||
},
|
||||
[LED_TYPE_PSU1] = {
|
||||
.name = "as7716_24sc_led::psu1",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24sc_led_auto_set,
|
||||
.brightness_get = as7716_24sc_led_auto_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_AUTO,
|
||||
},
|
||||
[LED_TYPE_PSU2] = {
|
||||
.name = "as7716_24sc_led::psu2",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24sc_led_auto_set,
|
||||
.brightness_get = as7716_24sc_led_auto_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_AUTO,
|
||||
},
|
||||
};
|
||||
|
||||
static int as7716_24sc_led_suspend(struct platform_device *dev,
|
||||
pm_message_t state)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(as7716_24sc_leds); i++) {
|
||||
led_classdev_suspend(&as7716_24sc_leds[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int as7716_24sc_led_resume(struct platform_device *dev)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(as7716_24sc_leds); i++) {
|
||||
led_classdev_resume(&as7716_24sc_leds[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int as7716_24sc_led_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(as7716_24sc_leds); i++) {
|
||||
ret = led_classdev_register(&pdev->dev, &as7716_24sc_leds[i]);
|
||||
|
||||
if (ret < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check if all LEDs were successfully registered */
|
||||
if (i != ARRAY_SIZE(as7716_24sc_leds)){
|
||||
int j;
|
||||
|
||||
/* only unregister the LEDs that were successfully registered */
|
||||
for (j = 0; j < i; j++) {
|
||||
led_classdev_unregister(&as7716_24sc_leds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int as7716_24sc_led_remove(struct platform_device *pdev)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(as7716_24sc_leds); i++) {
|
||||
led_classdev_unregister(&as7716_24sc_leds[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver as7716_24sc_led_driver = {
|
||||
.probe = as7716_24sc_led_probe,
|
||||
.remove = as7716_24sc_led_remove,
|
||||
.suspend = as7716_24sc_led_suspend,
|
||||
.resume = as7716_24sc_led_resume,
|
||||
.driver = {
|
||||
.name = DRVNAME,
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init as7716_24sc_led_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = platform_driver_register(&as7716_24sc_led_driver);
|
||||
if (ret < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ledctl = kzalloc(sizeof(struct as7716_24sc_led_data), GFP_KERNEL);
|
||||
if (!ledctl) {
|
||||
ret = -ENOMEM;
|
||||
platform_driver_unregister(&as7716_24sc_led_driver);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
mutex_init(&ledctl->update_lock);
|
||||
|
||||
ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
|
||||
if (IS_ERR(ledctl->pdev)) {
|
||||
ret = PTR_ERR(ledctl->pdev);
|
||||
platform_driver_unregister(&as7716_24sc_led_driver);
|
||||
kfree(ledctl);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit as7716_24sc_led_exit(void)
|
||||
{
|
||||
platform_device_unregister(ledctl->pdev);
|
||||
platform_driver_unregister(&as7716_24sc_led_driver);
|
||||
kfree(ledctl);
|
||||
}
|
||||
|
||||
module_init(as7716_24sc_led_init);
|
||||
module_exit(as7716_24sc_led_exit);
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("as7716_24sc_led driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* An hwmon driver for accton as7716_24sc Power Module
|
||||
*
|
||||
* Copyright (C) 2014 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* Based on ad7414.c
|
||||
* Copyright 2006 Stefan Roese <sr at denx.de>, DENX Software Engineering
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dmi.h>
|
||||
|
||||
#define PSU_STATUS_I2C_ADDR 0x60
|
||||
#define PSU_STATUS_I2C_REG_OFFSET 0x03
|
||||
|
||||
#define IS_POWER_GOOD(id, value) (!!(value & BIT(2+id)))
|
||||
#define IS_PRESENT(id, value) (!(value & BIT(id)))
|
||||
|
||||
static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf);
|
||||
extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg);
|
||||
|
||||
/* Addresses scanned
|
||||
*/
|
||||
static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
|
||||
|
||||
/* Each client has this additional data
|
||||
*/
|
||||
struct as7716_24sc_psu_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 index; /* PSU index */
|
||||
u8 status; /* Status(present/power_good) register read from CPLD */
|
||||
};
|
||||
|
||||
static struct as7716_24sc_psu_data *as7716_24sc_psu_update_device(struct device *dev);
|
||||
|
||||
enum as7716_24sc_psu_sysfs_attributes {
|
||||
PSU_PRESENT,
|
||||
PSU_POWER_GOOD,
|
||||
};
|
||||
|
||||
/* sysfs attributes for hwmon
|
||||
*/
|
||||
static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT);
|
||||
static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD);
|
||||
|
||||
static struct attribute *as7716_24sc_psu_attributes[] = {
|
||||
&sensor_dev_attr_psu_present.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_power_good.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static ssize_t show_status(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct as7716_24sc_psu_data *data = as7716_24sc_psu_update_device(dev);
|
||||
u8 status = 0;
|
||||
|
||||
if (!data->valid) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (attr->index == PSU_PRESENT) {
|
||||
status = IS_PRESENT(data->index, data->status);
|
||||
}
|
||||
else { /* PSU_POWER_GOOD */
|
||||
status = IS_POWER_GOOD(data->index, data->status);
|
||||
}
|
||||
|
||||
return sprintf(buf, "%d\n", status);
|
||||
}
|
||||
|
||||
static const struct attribute_group as7716_24sc_psu_group = {
|
||||
.attrs = as7716_24sc_psu_attributes,
|
||||
};
|
||||
|
||||
static int as7716_24sc_psu_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct as7716_24sc_psu_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {
|
||||
status = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct as7716_24sc_psu_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
status = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
data->valid = 0;
|
||||
data->index = dev_id->driver_data;
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
dev_info(&client->dev, "chip found\n");
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &as7716_24sc_psu_group);
|
||||
if (status) {
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register_with_info(&client->dev, "as7716_24sc_psu",
|
||||
NULL, NULL, NULL);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: psu '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24sc_psu_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int as7716_24sc_psu_remove(struct i2c_client *client)
|
||||
{
|
||||
struct as7716_24sc_psu_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24sc_psu_group);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum psu_index
|
||||
{
|
||||
as7716_24sc_psu1,
|
||||
as7716_24sc_psu2
|
||||
};
|
||||
|
||||
static const struct i2c_device_id as7716_24sc_psu_id[] = {
|
||||
{ "as7716_24sc_psu1", as7716_24sc_psu1 },
|
||||
{ "as7716_24sc_psu2", as7716_24sc_psu2 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, as7716_24sc_psu_id);
|
||||
|
||||
static struct i2c_driver as7716_24sc_psu_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "as7716_24sc_psu",
|
||||
},
|
||||
.probe = as7716_24sc_psu_probe,
|
||||
.remove = as7716_24sc_psu_remove,
|
||||
.id_table = as7716_24sc_psu_id,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
static struct as7716_24sc_psu_data *as7716_24sc_psu_update_device(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct as7716_24sc_psu_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|
||||
|| !data->valid) {
|
||||
int status;
|
||||
|
||||
data->valid = 0;
|
||||
dev_dbg(&client->dev, "Starting as7716_24sc update\n");
|
||||
|
||||
/* Read psu status */
|
||||
status = accton_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET);
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status);
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
data->status = status;
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int __init as7716_24sc_psu_init(void)
|
||||
{
|
||||
return i2c_add_driver(&as7716_24sc_psu_driver);
|
||||
}
|
||||
|
||||
static void __exit as7716_24sc_psu_exit(void)
|
||||
{
|
||||
i2c_del_driver(&as7716_24sc_psu_driver);
|
||||
}
|
||||
|
||||
module_init(as7716_24sc_psu_init);
|
||||
module_exit(as7716_24sc_psu_exit);
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("as7716_24sc_psu driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-as7716-24sc ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
@@ -0,0 +1,2 @@
|
||||
FILTER=src
|
||||
include $(ONL)/make/subdirs.mk
|
||||
@@ -0,0 +1,45 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
MODULE := libonlp-x86-64-accton-as7716-24sc
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF x86_64_accton_as7716_24sc onlplib
|
||||
DEPENDMODULE_HEADERS := sff
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
SHAREDLIB := libonlp-x86-64-accton-as7716-24sc.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
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
.DEFAULT_GOAL := onlpdump
|
||||
|
||||
MODULE := onlpdump
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF onlp x86_64_accton_as7716_24sc 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
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
name: x86_64_accton_as7716_24sc
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
include $(ONL)/make/config.mk
|
||||
MODULE := x86_64_accton_as7716_24sc
|
||||
AUTOMODULE := x86_64_accton_as7716_24sc
|
||||
include $(BUILDER)/definemodule.mk
|
||||
@@ -0,0 +1,6 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_24sc README
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_24sc Autogeneration
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_accton_as7716_24sc_AUTO_DEFS := module/auto/x86_64_accton_as7716_24sc.yml
|
||||
x86_64_accton_as7716_24sc_AUTO_DIRS := module/inc/x86_64_accton_as7716_24sc module/src
|
||||
include $(BUILDER)/auto.mk
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_24sc Autogeneration Definitions.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
cdefs: &cdefs
|
||||
- X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_LOGGING:
|
||||
doc: "Include or exclude logging."
|
||||
default: 1
|
||||
- X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT:
|
||||
doc: "Default enabled log options."
|
||||
default: AIM_LOG_OPTIONS_DEFAULT
|
||||
- X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT:
|
||||
doc: "Default enabled log bits."
|
||||
default: AIM_LOG_BITS_DEFAULT
|
||||
- X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
|
||||
doc: "Default enabled custom log bits."
|
||||
default: 0
|
||||
- X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB:
|
||||
doc: "Default all porting macros to use the C standard libraries."
|
||||
default: 1
|
||||
- X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
|
||||
doc: "Include standard library headers for stdlib porting macros."
|
||||
default: X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB
|
||||
- X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI:
|
||||
doc: "Include generic uCli support."
|
||||
default: 0
|
||||
|
||||
|
||||
definitions:
|
||||
cdefs:
|
||||
X86_64_ACCTON_AS7716_24SC_CONFIG_HEADER:
|
||||
defs: *cdefs
|
||||
basename: x86_64_accton_as7716_24sc_config
|
||||
|
||||
portingmacro:
|
||||
x86_64_accton_as7716_24sc:
|
||||
macros:
|
||||
- malloc
|
||||
- free
|
||||
- memset
|
||||
- memcpy
|
||||
- strncpy
|
||||
- vsnprintf
|
||||
- snprintf
|
||||
- strlen
|
||||
@@ -0,0 +1,14 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24sc/x86_64_accton_as7716_24sc_config.h>
|
||||
|
||||
/* <--auto.start.xmacro(ALL).define> */
|
||||
/* <auto.end.xmacro(ALL).define> */
|
||||
|
||||
/* <--auto.start.xenum(ALL).define> */
|
||||
/* <auto.end.xenum(ALL).define> */
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_accton_as7716_24sc Configuration Header
|
||||
*
|
||||
* @addtogroup x86_64_accton_as7716_24sc-config
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24SC_CONFIG_H__
|
||||
#define __X86_64_ACCTON_AS7716_24SC_CONFIG_H__
|
||||
|
||||
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
|
||||
#include <global_custom_config.h>
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24SC_INCLUDE_CUSTOM_CONFIG
|
||||
#include <x86_64_accton_as7716_24sc_custom_config.h>
|
||||
#endif
|
||||
|
||||
/* <auto.start.cdefs(X86_64_ACCTON_AS7716_24SC_CONFIG_HEADER).header> */
|
||||
#include <AIM/aim.h>
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_LOGGING
|
||||
*
|
||||
* Include or exclude logging. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_LOGGING
|
||||
#define X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_LOGGING 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
*X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
*
|
||||
* Default enabled log options. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
#define X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled log bits. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT
|
||||
#define X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled custom log bits. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
#define X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB
|
||||
*
|
||||
* Default all porting macros to use the C standard libraries. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB
|
||||
#define X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
*
|
||||
* Include standard library headers for stdlib porting macros. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
#define X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI
|
||||
*
|
||||
* Include generic uCli support. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI
|
||||
#define X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* All compile time options can be queried or displayed
|
||||
*/
|
||||
|
||||
/** Configuration settings structure. */
|
||||
typedef struct x86_64_accton_as7716_24sc_config_settings_s {
|
||||
/** name */
|
||||
const char* name;
|
||||
/** value */
|
||||
const char* value;
|
||||
} x86_64_accton_as7716_24sc_config_settings_t;
|
||||
|
||||
/** Configuration settings table. */
|
||||
/** x86_64_accton_as7716_24sc_config_settings table. */
|
||||
extern x86_64_accton_as7716_24sc_config_settings_t x86_64_accton_as7716_24sc_config_settings[];
|
||||
|
||||
/**
|
||||
* @brief Lookup a configuration setting.
|
||||
* @param setting The name of the configuration option to lookup.
|
||||
*/
|
||||
const char* x86_64_accton_as7716_24sc_config_lookup(const char* setting);
|
||||
|
||||
/**
|
||||
* @brief Show the compile-time configuration.
|
||||
* @param pvs The output stream.
|
||||
*/
|
||||
int x86_64_accton_as7716_24sc_config_show(struct aim_pvs_s* pvs);
|
||||
|
||||
/* <auto.end.cdefs(X86_64_ACCTON_AS7716_24SC_CONFIG_HEADER).header> */
|
||||
|
||||
#include "x86_64_accton_as7716_24sc_porting.h"
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24SC_CONFIG_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,26 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_accton_as7716_24sc Doxygen Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24SC_DOX_H__
|
||||
#define __X86_64_ACCTON_AS7716_24SC_DOX_H__
|
||||
|
||||
/**
|
||||
* @defgroup x86_64_accton_as7716_24sc x86_64_accton_as7716_24sc - x86_64_accton_as7716_24sc Description
|
||||
*
|
||||
|
||||
The documentation overview for this module should go here.
|
||||
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup x86_64_accton_as7716_24sc-x86_64_accton_as7716_24sc Public Interface
|
||||
* @defgroup x86_64_accton_as7716_24sc-config Compile Time Configuration
|
||||
* @defgroup x86_64_accton_as7716_24sc-porting Porting Macros
|
||||
*
|
||||
* @}
|
||||
*
|
||||
*/
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24SC_DOX_H__ */
|
||||
@@ -0,0 +1,107 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_accton_as7716_24sc Porting Macros.
|
||||
*
|
||||
* @addtogroup x86_64_accton_as7716_24sc-porting
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24SC_PORTING_H__
|
||||
#define __X86_64_ACCTON_AS7716_24SC_PORTING_H__
|
||||
|
||||
|
||||
/* <auto.start.portingmacro(ALL).define> */
|
||||
#if X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_MALLOC
|
||||
#if defined(GLOBAL_MALLOC)
|
||||
#define X86_64_ACCTON_AS7716_24SC_MALLOC GLOBAL_MALLOC
|
||||
#elif X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24SC_MALLOC malloc
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24SC_MALLOC is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_FREE
|
||||
#if defined(GLOBAL_FREE)
|
||||
#define X86_64_ACCTON_AS7716_24SC_FREE GLOBAL_FREE
|
||||
#elif X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24SC_FREE free
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24SC_FREE is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_MEMSET
|
||||
#if defined(GLOBAL_MEMSET)
|
||||
#define X86_64_ACCTON_AS7716_24SC_MEMSET GLOBAL_MEMSET
|
||||
#elif X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24SC_MEMSET memset
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24SC_MEMSET is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_MEMCPY
|
||||
#if defined(GLOBAL_MEMCPY)
|
||||
#define X86_64_ACCTON_AS7716_24SC_MEMCPY GLOBAL_MEMCPY
|
||||
#elif X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24SC_MEMCPY memcpy
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24SC_MEMCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_STRNCPY
|
||||
#if defined(GLOBAL_STRNCPY)
|
||||
#define X86_64_ACCTON_AS7716_24SC_STRNCPY GLOBAL_STRNCPY
|
||||
#elif X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24SC_STRNCPY strncpy
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24SC_STRNCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_VSNPRINTF
|
||||
#if defined(GLOBAL_VSNPRINTF)
|
||||
#define X86_64_ACCTON_AS7716_24SC_VSNPRINTF GLOBAL_VSNPRINTF
|
||||
#elif X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24SC_VSNPRINTF vsnprintf
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24SC_VSNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_SNPRINTF
|
||||
#if defined(GLOBAL_SNPRINTF)
|
||||
#define X86_64_ACCTON_AS7716_24SC_SNPRINTF GLOBAL_SNPRINTF
|
||||
#elif X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24SC_SNPRINTF snprintf
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24SC_SNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24SC_STRLEN
|
||||
#if defined(GLOBAL_STRLEN)
|
||||
#define X86_64_ACCTON_AS7716_24SC_STRLEN GLOBAL_STRLEN
|
||||
#elif X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24SC_STRLEN strlen
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24SC_STRLEN is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* <auto.end.portingmacro(ALL).define> */
|
||||
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24SC_PORTING_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,10 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
x86_64_accton_as7716_24sc_INCLUDES := -I $(THIS_DIR)inc
|
||||
x86_64_accton_as7716_24sc_INTERNAL_INCLUDES := -I $(THIS_DIR)src
|
||||
x86_64_accton_as7716_24sc_DEPENDMODULE_ENTRIES := init:x86_64_accton_as7716_24sc ucli:x86_64_accton_as7716_24sc
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Local source generation targets.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
ucli:
|
||||
@../../../../tools/uclihandlers.py x86_64_accton_as7716_24sc_ucli.c
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2017 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Fan Platform Implementation Defaults.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
enum fan_id {
|
||||
FAN_1_ON_FAN_BOARD = 1,
|
||||
FAN_2_ON_FAN_BOARD,
|
||||
FAN_3_ON_FAN_BOARD,
|
||||
FAN_4_ON_FAN_BOARD,
|
||||
FAN_1_ON_PSU_1,
|
||||
FAN_1_ON_PSU_2
|
||||
};
|
||||
|
||||
#define MAX_FAN_SPEED 14702
|
||||
#define MAX_PSU_FAN_SPEED 18000
|
||||
|
||||
#define CHASSIS_FAN_INFO(fid) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\
|
||||
0x0,\
|
||||
ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\
|
||||
0,\
|
||||
0,\
|
||||
ONLP_FAN_MODE_INVALID,\
|
||||
}
|
||||
|
||||
#define PSU_FAN_INFO(pid, fid) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\
|
||||
0x0,\
|
||||
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\
|
||||
0,\
|
||||
0,\
|
||||
ONLP_FAN_MODE_INVALID,\
|
||||
}
|
||||
|
||||
/* Static fan information */
|
||||
onlp_fan_info_t finfo[] = {
|
||||
{ }, /* Not used */
|
||||
CHASSIS_FAN_INFO(1),
|
||||
CHASSIS_FAN_INFO(2),
|
||||
CHASSIS_FAN_INFO(3),
|
||||
CHASSIS_FAN_INFO(4),
|
||||
PSU_FAN_INFO(1, 1),
|
||||
PSU_FAN_INFO(2, 1)
|
||||
};
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_FAN(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info)
|
||||
{
|
||||
int value;
|
||||
|
||||
/* get fan present status
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (value == 0) {
|
||||
return ONLP_STATUS_OK; /* fan is not present */
|
||||
}
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
|
||||
/* get fan fault status (turn on when any one fails)
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_fault", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (value > 0) {
|
||||
info->status |= ONLP_FAN_STATUS_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* get fan direction (both : the same)
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_direction", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->status |= value ? ONLP_FAN_STATUS_B2F : ONLP_FAN_STATUS_F2B;
|
||||
|
||||
|
||||
/* get front fan speed
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
info->rpm = value;
|
||||
|
||||
/* get rear fan speed
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
/* take the min value from front/rear fan speed
|
||||
*/
|
||||
if (info->rpm > value) {
|
||||
info->rpm = value;
|
||||
}
|
||||
|
||||
/* get speed percentage from rpm
|
||||
*/
|
||||
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
_onlp_get_fan_direction_on_psu(void)
|
||||
{
|
||||
/* Try to read direction from PSU1.
|
||||
* If PSU1 is not valid, read from PSU2
|
||||
*/
|
||||
int i = 0;
|
||||
|
||||
for (i = PSU1_ID; i <= PSU2_ID; i++) {
|
||||
psu_type_t psu_type;
|
||||
psu_type = get_psu_type(i, NULL, 0);
|
||||
|
||||
if (psu_type == PSU_TYPE_UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (psu_type) {
|
||||
case PSU_TYPE_AC_DPS850_F2B:
|
||||
return ONLP_FAN_STATUS_F2B;
|
||||
case PSU_TYPE_AC_DPS850_B2F:
|
||||
return ONLP_FAN_STATUS_B2F;
|
||||
default:
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
/* get fan direction
|
||||
*/
|
||||
info->status |= _onlp_get_fan_direction_on_psu();
|
||||
|
||||
/* get fan speed
|
||||
*/
|
||||
if (psu_dps850_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) {
|
||||
info->rpm = val;
|
||||
info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED;
|
||||
info->status |= (val == 0) ? ONLP_FAN_STATUS_FAILED : 0;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to all of onlp_fani_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_fani_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
{
|
||||
int rc = 0;
|
||||
int fid;
|
||||
VALIDATE(id);
|
||||
|
||||
fid = ONLP_OID_ID_GET(id);
|
||||
*info = finfo[fid];
|
||||
|
||||
switch (fid)
|
||||
{
|
||||
case FAN_1_ON_PSU_1:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info);
|
||||
break;
|
||||
case FAN_1_ON_PSU_2:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info);
|
||||
break;
|
||||
case FAN_1_ON_FAN_BOARD:
|
||||
case FAN_2_ON_FAN_BOARD:
|
||||
case FAN_3_ON_FAN_BOARD:
|
||||
case FAN_4_ON_FAN_BOARD:
|
||||
rc =_onlp_fani_info_get_fan(fid, 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)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as a percentage.
|
||||
*
|
||||
* This will only be called if the OID has the PERCENTAGE_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
{
|
||||
int fid;
|
||||
char *path = NULL;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
fid = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* reject p=0 (p=0, stop fan) */
|
||||
if (p == 0){
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
switch (fid)
|
||||
{
|
||||
case FAN_1_ON_FAN_BOARD:
|
||||
case FAN_2_ON_FAN_BOARD:
|
||||
path = FAN_NODE(fan_duty_cycle_percentage);
|
||||
break;
|
||||
default:
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
if (onlp_file_write_int(p, path) < 0) {
|
||||
AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2017 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define LED_FORMAT "/sys/class/leds/as7716_24sc_led::%s/brightness"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_LED(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* LED related data
|
||||
*/
|
||||
enum onlp_led_id
|
||||
{
|
||||
LED_RESERVED = 0,
|
||||
LED_PSU1,
|
||||
LED_PSU2,
|
||||
LED_FAN,
|
||||
LED_DIAG,
|
||||
LED_LOC
|
||||
};
|
||||
|
||||
enum led_light_mode {
|
||||
LED_MODE_OFF,
|
||||
LED_MODE_RED = 10,
|
||||
LED_MODE_RED_BLINKING = 11,
|
||||
LED_MODE_ORANGE = 12,
|
||||
LED_MODE_ORANGE_BLINKING = 13,
|
||||
LED_MODE_YELLOW = 14,
|
||||
LED_MODE_YELLOW_BLINKING = 15,
|
||||
LED_MODE_GREEN = 16,
|
||||
LED_MODE_GREEN_BLINKING = 17,
|
||||
LED_MODE_BLUE = 18,
|
||||
LED_MODE_BLUE_BLINKING = 19,
|
||||
LED_MODE_PURPLE = 20,
|
||||
LED_MODE_PURPLE_BLINKING = 21,
|
||||
LED_MODE_AUTO = 22,
|
||||
LED_MODE_AUTO_BLINKING = 23,
|
||||
LED_MODE_WHITE = 24,
|
||||
LED_MODE_WHITE_BLINKING = 25,
|
||||
LED_MODE_CYAN = 26,
|
||||
LED_MODE_CYAN_BLINKING = 27,
|
||||
LED_MODE_UNKNOWN = 99
|
||||
};
|
||||
|
||||
typedef struct led_light_mode_map {
|
||||
enum onlp_led_id id;
|
||||
enum led_light_mode driver_led_mode;
|
||||
enum onlp_led_mode_e onlp_led_mode;
|
||||
} led_light_mode_map_t;
|
||||
|
||||
led_light_mode_map_t led_map[] = {
|
||||
{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_DIAG, LED_MODE_ORANGE,ONLP_LED_MODE_ORANGE},
|
||||
{LED_DIAG, LED_MODE_YELLOW,ONLP_LED_MODE_YELLOW},
|
||||
{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_LOC, LED_MODE_ORANGE,ONLP_LED_MODE_ORANGE},
|
||||
{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}
|
||||
};
|
||||
|
||||
static char *leds[] = /* must map with onlp_led_id */
|
||||
{
|
||||
"reserved",
|
||||
"psu1",
|
||||
"psu2",
|
||||
"fan",
|
||||
"diag",
|
||||
"loc",
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the information for the given LED OID.
|
||||
*/
|
||||
static onlp_led_info_t linfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 1 (PSU1 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 2 (PSU2 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 4 (DIAG LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_YELLOW,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 5 (LOC LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED,
|
||||
},
|
||||
};
|
||||
|
||||
static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for (i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode)
|
||||
{
|
||||
return led_map[i].onlp_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for(i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode)
|
||||
{
|
||||
return led_map[i].driver_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to any other onlp_ledi_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_init(void)
|
||||
{
|
||||
/*
|
||||
* LED Off
|
||||
*/
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF);
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
{
|
||||
int lid, value;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
lid = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[ONLP_OID_ID_GET(id)];
|
||||
|
||||
/* Get LED mode */
|
||||
if (onlp_file_read_int(&value, LED_FORMAT, leds[lid]) < 0) {
|
||||
DEBUG_PRINT("Unable to read status from file "LED_FORMAT, leds[lid]);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->mode = driver_to_onlp_led_mode(lid, value);
|
||||
|
||||
/* Set the on/off status */
|
||||
if (info->mode != ONLP_LED_MODE_OFF) {
|
||||
info->status |= ONLP_LED_STATUS_ON;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn an LED on or off.
|
||||
*
|
||||
* This function will only be called if the LED OID supports the ONOFF
|
||||
* capability.
|
||||
*
|
||||
* What 'on' means in terms of colors or modes for multimode LEDs is
|
||||
* up to the platform to decide. This is intended as baseline toggle mechanism.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_set(onlp_oid_t id, int on_or_off)
|
||||
{
|
||||
VALIDATE(id);
|
||||
|
||||
if (!on_or_off) {
|
||||
return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function puts the LED into the given mode. It is a more functional
|
||||
* interface for multimode LEDs.
|
||||
*
|
||||
* Only modes reported in the LED's capabilities will be attempted.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
|
||||
{
|
||||
int lid;
|
||||
VALIDATE(id);
|
||||
|
||||
lid = ONLP_OID_ID_GET(id);
|
||||
if (onlp_file_write_int(onlp_to_driver_led_mode(lid , mode), LED_FORMAT, leds[lid]) < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic LED ioctl interface.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
LIBRARY := x86_64_accton_as7716_24sc
|
||||
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
include $(BUILDER)/lib.mk
|
||||
@@ -0,0 +1,315 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <onlp/onlp.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/i2c.h>
|
||||
#include <AIM/aim.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PSU_MODEL_NAME_LEN 13
|
||||
#define PSU_SERIAL_NUMBER_LEN 14
|
||||
#define PSU_NODE_MAX_PATH_LEN 64
|
||||
|
||||
int get_psu_serial_number(int id, char *serial, int serial_len)
|
||||
{
|
||||
int size = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
char *path = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_serial) :
|
||||
PSU2_AC_PMBUS_NODE(psu_mfr_serial) ;
|
||||
|
||||
if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, path);
|
||||
if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
|
||||
}
|
||||
|
||||
serial[PSU_SERIAL_NUMBER_LEN] = '\0';
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len)
|
||||
{
|
||||
int value = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
char model[PSU_MODEL_NAME_LEN + 1] = {0};
|
||||
char *path = NULL;
|
||||
|
||||
if (modelname && modelname_len < PSU_MODEL_NAME_LEN) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Check if the psu is present
|
||||
*/
|
||||
path = (id == PSU1_ID) ? PSU1_AC_EEPROM_NODE(psu_present) :
|
||||
PSU2_AC_EEPROM_NODE(psu_present) ;
|
||||
if (onlp_file_read_int(&value, path) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Read mode name */
|
||||
path = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) :
|
||||
PSU2_AC_PMBUS_NODE(psu_mfr_model) ;
|
||||
ret = onlp_file_read((uint8_t*)model, PSU_MODEL_NAME_LEN, &value, path);
|
||||
if (ret != ONLP_STATUS_OK || value != PSU_MODEL_NAME_LEN) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
|
||||
}
|
||||
|
||||
if (modelname) {
|
||||
memcpy(modelname, model, sizeof(model));
|
||||
}
|
||||
|
||||
if (strncmp(model, "DPS-850AB-4", strlen("DPS-850AB-4")) == 0) {
|
||||
return PSU_TYPE_AC_DPS850_F2B;
|
||||
}
|
||||
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
int psu_dps850_pmbus_info_get(int id, char *node, int *value)
|
||||
{
|
||||
char *prefix = NULL;
|
||||
|
||||
*value = 0;
|
||||
|
||||
prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX;
|
||||
if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
#define DSP_ADDR 0x6a
|
||||
#define DSP_READ_MAX_RETRY 50000
|
||||
#define DSP_WRITE_MAX_RETRY 10
|
||||
#define DSP_BUSY_VALUE 1
|
||||
#define DSP_NOBUSY_VALUE 0
|
||||
#define NTT_I2C_CMD_WAIT_US 100000
|
||||
|
||||
int dsp_exec_read(int bus, struct dsp_ctrl_s* dsp_ctrl, int *ret_val)
|
||||
{
|
||||
int i = 0, ret = 0;
|
||||
uint8_t value = 0, offset = 0;
|
||||
|
||||
if (ret_val) {
|
||||
*ret_val = 0;
|
||||
}
|
||||
|
||||
/* Set the address to be read into register 0x10 ~ 0x13
|
||||
*/
|
||||
for (i = 0; i <= 3; i++) {
|
||||
offset = 0x10 + i;
|
||||
value = (dsp_ctrl->value1 >> (8 * (3-i))) & 0xff;
|
||||
|
||||
ret = onlp_i2c_writeb(bus, DSP_ADDR, offset, value, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): Failed to write data into bus(%d), addr(0x%x), offset(0x%x), value(0x%x), error code(%d)\r\n",
|
||||
__FUNCTION__, __LINE__, bus, DSP_ADDR, offset, value, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger the read operation : write 0x2 to Reg0x1 of dsp controller
|
||||
offset = 0x01;
|
||||
value = 0x02;
|
||||
ret = onlp_i2c_writeb(bus, DSP_ADDR, offset, value, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): Failed to write data into bus(%d), addr(0x%x), offset(0x%x), value(0x%x), error code(%d)\r\n",
|
||||
__FUNCTION__, __LINE__, bus, DSP_ADDR, offset, value, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// Check Reg0x02 is changed to 0x0(Busy:0x01, no-busy:0x00)
|
||||
offset = 0x02;
|
||||
i = DSP_READ_MAX_RETRY;
|
||||
while(i--) {
|
||||
ret = onlp_i2c_readb(bus, DSP_ADDR, offset, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): Failed to read data from bus(%d), addr(0x%x), offset(0x%x), value(0x%x), error code(%d)\r\n",
|
||||
__FUNCTION__, __LINE__, bus, DSP_ADDR, offset, value, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret == DSP_BUSY_VALUE) {
|
||||
usleep(NTT_I2C_CMD_WAIT_US);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret == DSP_BUSY_VALUE) {
|
||||
DEBUG_PRINT("%s(%d): Device is busy!! Not change to Idle\r\n", __FUNCTION__, __LINE__);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
|
||||
/* Read the output data from register 0x20 ~ 0x23
|
||||
*/
|
||||
for (i = 0; i <= 3; i++) {
|
||||
offset = 0x20 + i;
|
||||
|
||||
ret = onlp_i2c_readb(bus, DSP_ADDR, offset, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): Failed to read data from bus(%d), addr(0x%x), offset(0x%x), value(0x%x), error code(%d)\r\n",
|
||||
__FUNCTION__, __LINE__, bus, DSP_ADDR, offset, value, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret_val) {
|
||||
*ret_val <<= 8;
|
||||
*ret_val |= (ret & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int cfp_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
int i, bus, ret = 0, value = 0;
|
||||
struct dsp_ctrl_s eeprom_cmd = {"R", 0x40008000};
|
||||
int i2c_bus[] = {41, 43, 45, 47, 49, 51, 53, 55};
|
||||
|
||||
/* init dsp card */
|
||||
bus = i2c_bus[port % 8];
|
||||
|
||||
/* read eeprom */
|
||||
for (i = 0; i < 256; i++) {
|
||||
ret = dsp_exec_read(bus, &eeprom_cmd, &value);
|
||||
|
||||
if (ret < 0) {
|
||||
AIM_LOG_ERROR("Unable to read the eeprom of port (%d), check if it has been initialized properly by dsp_ctrl ", port);
|
||||
return ret;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("%s(%d): command:(%s0x%x), Value(0x%x)\r\n", __FUNCTION__, __LINE__, eeprom_cmd.type, eeprom_cmd.value1, value);
|
||||
data[i] = (value & 0xff);
|
||||
eeprom_cmd.value1++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define EXPANSION_CARD_FORMAT "/sys/bus/i2c/devices/%d-006a/%s"
|
||||
|
||||
typedef enum card_type {
|
||||
CARD_TYPE_Q28,
|
||||
CARD_TYPE_DCO,
|
||||
CARD_TYPE_ACO,
|
||||
CARD_TYPE_NOT_PRESENT,
|
||||
CARD_TYPE_UNKNOWN
|
||||
} card_type_t;
|
||||
|
||||
card_type_t get_card_type(int port)
|
||||
{
|
||||
int slot = 0;
|
||||
int type = 0;
|
||||
int present = 0;
|
||||
int i2c_bus[] = {41, 43, 45, 47, 49, 51, 53, 55};
|
||||
|
||||
/* Get card slot of this port */
|
||||
slot = (port % 16) / 2;
|
||||
|
||||
if (onlp_file_read_int(&present, EXPANSION_CARD_FORMAT, i2c_bus[slot], "card_present") < 0) {
|
||||
AIM_LOG_ERROR("Unable to read card present status from bus(%d)\r\n", i2c_bus[slot]);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (!present) {
|
||||
return CARD_TYPE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
if (onlp_file_read_int(&type, EXPANSION_CARD_FORMAT, i2c_bus[slot], "card_type") < 0) {
|
||||
AIM_LOG_ERROR("Unable to read card_type from bus(%d)\r\n", i2c_bus[slot]);
|
||||
return CARD_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (type != CARD_TYPE_Q28 && type != CARD_TYPE_DCO) {
|
||||
type = CARD_TYPE_ACO; /* workaround */
|
||||
}
|
||||
|
||||
//printf("CARD_TYPE = (%d)\r\n", type);
|
||||
return type;
|
||||
}
|
||||
|
||||
port_type_t get_port_type(int port)
|
||||
{
|
||||
card_type_t card_type;
|
||||
port_type_t port_type;
|
||||
|
||||
if (port < 16) {
|
||||
return PORT_TYPE_Q28;
|
||||
}
|
||||
|
||||
/* Get card type to get correct port mapping table */
|
||||
card_type = get_card_type(port);
|
||||
|
||||
switch (card_type) {
|
||||
case CARD_TYPE_Q28: port_type = PORT_TYPE_Q28; break;
|
||||
case CARD_TYPE_ACO: port_type = PORT_TYPE_ACO_200G; break;
|
||||
case CARD_TYPE_DCO: port_type = PORT_TYPE_DCO_200G; break;
|
||||
default: port_type = PORT_TYPE_UNKNOWN; break;
|
||||
}
|
||||
|
||||
//printf("Port type = (%d)\r\n", port_type);
|
||||
return port_type;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int get_port_number(void)
|
||||
{
|
||||
/* Read type from expansion card */
|
||||
int port_number;
|
||||
card_type_t card_type = get_card_type();
|
||||
|
||||
switch (card_type) {
|
||||
case CARD_TYPE_Q28: port_number = 32; break;
|
||||
case CARD_TYPE_ACO: /* fall through */
|
||||
case CARD_TYPE_DCO: port_number = 24; break;
|
||||
case CARD_TYPE_UNKNOWN: /* fall through */
|
||||
default: port_number = 16; break;
|
||||
}
|
||||
|
||||
printf("Port Number = (%d)\r\n", port_number);
|
||||
return port_number;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#ifndef __PLATFORM_LIB_H__
|
||||
#define __PLATFORM_LIB_H__
|
||||
|
||||
#include "x86_64_accton_as7716_24sc_log.h"
|
||||
|
||||
#define CHASSIS_FAN_COUNT 4
|
||||
#define CHASSIS_THERMAL_COUNT 7
|
||||
#define CHASSIS_LED_COUNT 5
|
||||
#define CHASSIS_PSU_COUNT 2
|
||||
|
||||
#define PSU1_ID 1
|
||||
#define PSU2_ID 2
|
||||
|
||||
#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/18-0058/"
|
||||
#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/17-0059/"
|
||||
|
||||
#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node
|
||||
#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node
|
||||
|
||||
#define PSU1_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/18-0050/"
|
||||
#define PSU2_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/17-0051/"
|
||||
|
||||
#define PSU1_AC_EEPROM_NODE(node) PSU1_AC_EEPROM_PREFIX#node
|
||||
#define PSU2_AC_EEPROM_NODE(node) PSU2_AC_EEPROM_PREFIX#node
|
||||
|
||||
#define FAN_BOARD_PATH "/sys/bus/i2c/devices/9-0066/"
|
||||
#define FAN_NODE(node) FAN_BOARD_PATH#node
|
||||
|
||||
#define IDPROM_PATH "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
|
||||
enum onlp_thermal_id
|
||||
{
|
||||
THERMAL_RESERVED = 0,
|
||||
THERMAL_CPU_CORE,
|
||||
THERMAL_1_ON_MAIN_BROAD,
|
||||
THERMAL_2_ON_MAIN_BROAD,
|
||||
THERMAL_3_ON_MAIN_BROAD,
|
||||
THERMAL_4_ON_MAIN_BROAD,
|
||||
THERMAL_5_ON_MAIN_BROAD,
|
||||
THERMAL_6_ON_MAIN_BROAD,
|
||||
THERMAL_1_ON_PSU1,
|
||||
THERMAL_1_ON_PSU2,
|
||||
};
|
||||
|
||||
typedef enum psu_type {
|
||||
PSU_TYPE_UNKNOWN,
|
||||
PSU_TYPE_AC_DPS850_F2B,
|
||||
PSU_TYPE_AC_DPS850_B2F
|
||||
} psu_type_t;
|
||||
|
||||
typedef enum port_type {
|
||||
PORT_TYPE_Q28,
|
||||
PORT_TYPE_ACO_200G,
|
||||
PORT_TYPE_DCO_200G,
|
||||
PORT_TYPE_UNKNOWN
|
||||
} port_type_t;
|
||||
|
||||
//int get_port_number(void);
|
||||
port_type_t get_port_type(int port);
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);
|
||||
int get_psu_serial_number(int id, char *serial, int serial_len);
|
||||
int psu_dps850_pmbus_info_get(int id, char *node, int *value);
|
||||
|
||||
struct dsp_ctrl_s
|
||||
{
|
||||
char *type;
|
||||
unsigned int value1;
|
||||
unsigned int value2;
|
||||
unsigned int value3;
|
||||
unsigned int value4;
|
||||
};
|
||||
|
||||
int dsp_initialize(int dsp_bus);
|
||||
int dsp_exec_read(int bus, struct dsp_ctrl_s* dsp_ctrl, int *ret_val);
|
||||
int cfp_eeprom_read(int port, uint8_t data[256]);
|
||||
|
||||
#define DEBUG_MODE 0
|
||||
|
||||
#if (DEBUG_MODE == 1)
|
||||
#define DEBUG_PRINT(fmt, args...) \
|
||||
printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args)
|
||||
#else
|
||||
#define DEBUG_PRINT(fmt, args...)
|
||||
#endif
|
||||
|
||||
#endif /* __PLATFORM_LIB_H__ */
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include <onlplib/file.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PSU_STATUS_PRESENT 1
|
||||
#define PSU_STATUS_POWER_GOOD 1
|
||||
#define PSU_NODE_MAX_PATH_LEN 64
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_PSU(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
psu_status_info_get(int id, char *node, int *value)
|
||||
{
|
||||
char *prefix = NULL;
|
||||
|
||||
*value = 0;
|
||||
|
||||
prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX;
|
||||
if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
psu_dps850_info_get(onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int index = ONLP_OID_ID_GET(info->hdr.id);
|
||||
|
||||
/* Set capability
|
||||
*/
|
||||
info->caps = ONLP_PSU_CAPS_AC;
|
||||
|
||||
if (info->status & ONLP_PSU_STATUS_FAILED) {
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* Set the associated oid_table */
|
||||
info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);
|
||||
info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT);
|
||||
|
||||
/* Read voltage, current and power */
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_v_out", &val) == 0) {
|
||||
info->mvout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_VOUT;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_v_in", &val) == 0) {
|
||||
info->mvin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_VIN;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_i_out", &val) == 0) {
|
||||
info->miout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_IOUT;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_i_in", &val) == 0) {
|
||||
info->miin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_IIN;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_p_out", &val) == 0) {
|
||||
info->mpout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_POUT;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_p_in", &val) == 0) {
|
||||
info->mpin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_PIN;
|
||||
}
|
||||
|
||||
get_psu_serial_number(index, info->serial, sizeof(info->serial));
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get all information about the given PSU oid.
|
||||
*/
|
||||
static onlp_psu_info_t pinfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 },
|
||||
},
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 },
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int index = ONLP_OID_ID_GET(id);
|
||||
psu_type_t psu_type;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
memset(info, 0, sizeof(onlp_psu_info_t));
|
||||
*info = pinfo[index]; /* Set the onlp_oid_hdr_t */
|
||||
|
||||
/* Get the present state */
|
||||
if (psu_status_info_get(index, "psu_present", &val) != 0) {
|
||||
printf("Unable to read PSU(%d) node(psu_present)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_PRESENT) {
|
||||
info->status &= ~ONLP_PSU_STATUS_PRESENT;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
info->status |= ONLP_PSU_STATUS_PRESENT;
|
||||
|
||||
|
||||
/* Get power good status */
|
||||
if (psu_status_info_get(index, "psu_power_good", &val) != 0) {
|
||||
printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_POWER_GOOD) {
|
||||
info->status |= ONLP_PSU_STATUS_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* Get PSU type
|
||||
*/
|
||||
psu_type = get_psu_type(index, info->model, sizeof(info->model));
|
||||
|
||||
switch (psu_type) {
|
||||
case PSU_TYPE_AC_DPS850_F2B:
|
||||
case PSU_TYPE_AC_DPS850_B2F:
|
||||
ret = psu_dps850_info_get(info);
|
||||
break;
|
||||
case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/
|
||||
info->status |= ONLP_PSU_STATUS_UNPLUGGED;
|
||||
info->status &= ~ONLP_PSU_STATUS_FAILED;
|
||||
ret = ONLP_STATUS_OK;
|
||||
break;
|
||||
default:
|
||||
ret = ONLP_STATUS_E_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2017 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/sfpi.h>
|
||||
#include <onlplib/i2c.h>
|
||||
#include <onlplib/file.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define MAX_PORT_PATH 64
|
||||
#define NUM_OF_PORT 32
|
||||
static const int qsfp_mux_index[] = {
|
||||
29, 30, 31, 32, 34, 33, 36, 35,
|
||||
25, 26, 27, 28, 37, 38, 39, 40,
|
||||
42, 41, 44, 43, 46, 45, 48, 47,
|
||||
50, 49, 52, 51, 54, 53, 56, 55
|
||||
};
|
||||
|
||||
#define QSFP_BUS_INDEX(port) (qsfp_mux_index[port])
|
||||
#define QSFP_PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s"
|
||||
|
||||
#define BIT_INDEX(i) (1ULL << (i))
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* 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;
|
||||
AIM_BITMAP_CLR_ALL(bmap);
|
||||
|
||||
for(p = 0; p < NUM_OF_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 = 0;
|
||||
port_type_t type = get_port_type(port);
|
||||
|
||||
//printf("%s(%d):Port Type = (%d)\r\n", __FUNCTION__, __LINE__, type);
|
||||
if (port >= 24 && type != PORT_TYPE_Q28) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (onlp_file_read_int(&present, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(port), "sfp_is_present") < 0) {
|
||||
AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return present;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
{
|
||||
uint32_t bytes[4];
|
||||
char path[MAX_PORT_PATH] = {0};
|
||||
FILE* fp;
|
||||
|
||||
sprintf(path, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(0), "sfp_is_present_all");
|
||||
fp = fopen(path, "r");
|
||||
|
||||
if(fp == NULL) {
|
||||
AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file.");
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
int count = fscanf(fp, "%x %x %x %x", bytes+0, bytes+1, bytes+2, bytes+3);
|
||||
fclose(fp);
|
||||
if(count != AIM_ARRAYSIZE(bytes)) {
|
||||
/* Likely a CPLD read timeout. */
|
||||
AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file.");
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
/* Convert to 64 bit integer in port order */
|
||||
int i = 0;
|
||||
uint32_t presence_all = 0 ;
|
||||
for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) {
|
||||
presence_all <<= 8;
|
||||
presence_all |= bytes[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_OF_PORT; i++) {
|
||||
port_type_t type = get_port_type(i);
|
||||
|
||||
if (i >= 24 && type != PORT_TYPE_Q28) {
|
||||
presence_all &= ~BIT_INDEX(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Populate bitmap */
|
||||
for(i = 0; presence_all; i++) {
|
||||
AIM_BITMAP_MOD(dst, i, (presence_all & 1));
|
||||
presence_all >>= 1;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
int ret = ONLP_STATUS_OK;
|
||||
port_type_t port_type = get_port_type(port);
|
||||
|
||||
if (PORT_TYPE_UNKNOWN == port_type) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (PORT_TYPE_Q28 == port_type) {
|
||||
int size = 0;
|
||||
|
||||
if(onlp_file_read(data, 256, &size, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) {
|
||||
ret = (size == 256) ? ONLP_STATUS_OK : ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
else {
|
||||
ret = ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return cfp_eeprom_read(port, data);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = QSFP_BUS_INDEX(port);
|
||||
return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
int bus = QSFP_BUS_INDEX(port);
|
||||
return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = QSFP_BUS_INDEX(port);
|
||||
return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
int bus = QSFP_BUS_INDEX(port);
|
||||
return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_denit(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,357 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2017 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/i2c.h>
|
||||
#include <onlp/platformi/sysi.h>
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#include "x86_64_accton_as7716_24sc_int.h"
|
||||
#include "x86_64_accton_as7716_24sc_log.h"
|
||||
|
||||
#define CPLD_VERSION_FORMAT "/sys/bus/i2c/devices/%s/version"
|
||||
#define NUM_OF_CPLD 3
|
||||
|
||||
static char* cpld_path[NUM_OF_CPLD] =
|
||||
{
|
||||
"11-0060",
|
||||
"12-0062",
|
||||
"13-0064"
|
||||
};
|
||||
|
||||
const char*
|
||||
onlp_sysi_platform_get(void)
|
||||
{
|
||||
return "x86-64-accton-as7716-24sc-r0";
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
onlp_sysi_init(void)
|
||||
{
|
||||
/* init dsp */
|
||||
int i = 0, ret;
|
||||
int dsp_busses[] = {41, 43, 45, 47, 49, 51, 53, 55};
|
||||
|
||||
for (i = 0; i < AIM_ARRAYSIZE(dsp_busses); i++) {
|
||||
printf("%s(%d)\r\n", __FUNCTION__, __LINE__);
|
||||
ret = dsp_initialize(dsp_busses[i]);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): dsp_initialize failed, dsp_id(%d), bus(%d), error code(%d)\r\n", __FUNCTION__, __LINE__, i, dsp_busses[i], ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s(%d)\r\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
onlp_sysi_onie_data_get(uint8_t** data, int* size)
|
||||
{
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int i = 0;
|
||||
uint8_t* rdata = aim_zmalloc(256);
|
||||
|
||||
for (i = 0; i < 128; i++) {
|
||||
ret = onlp_i2c_readw(0, 0x56, i*2, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
aim_free(rdata);
|
||||
*size = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdata[i*2] = ret & 0xff;
|
||||
rdata[i*2+1] = (ret >> 8) & 0xff;
|
||||
}
|
||||
|
||||
*size = 256;
|
||||
*data = rdata;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* PSUs on the chassis */
|
||||
for (i = 1; i <= CHASSIS_PSU_COUNT; i++) {
|
||||
*e++ = ONLP_PSU_ID_CREATE(i);
|
||||
}
|
||||
|
||||
/* Fans on the chassis */
|
||||
for (i = 1; i <= CHASSIS_FAN_COUNT; i++) {
|
||||
*e++ = ONLP_FAN_ID_CREATE(i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
|
||||
{
|
||||
int i, v[NUM_OF_CPLD] = {0};
|
||||
|
||||
for (i = 0; i < AIM_ARRAYSIZE(cpld_path); i++) {
|
||||
v[i] = 0;
|
||||
|
||||
if(onlp_file_read_int(v+i, CPLD_VERSION_FORMAT , cpld_path[i]) < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
pi->cpld_versions = aim_fstrdup("%d.%d.%d", v[0], v[1], v[2]);
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
|
||||
{
|
||||
aim_free(pi->cpld_versions);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_manage_init(void)
|
||||
{
|
||||
/*
|
||||
* Bring the fan to max.
|
||||
* These will be reduced after the first platform management sequence.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FAN_DUTY_MAX (100)
|
||||
#define FAN_DUTY_MIN (52)
|
||||
|
||||
static int
|
||||
sysi_fanctrl_fan_fault_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted)
|
||||
{
|
||||
int i;
|
||||
*adjusted = 0;
|
||||
|
||||
/* Bring fan speed to FAN_DUTY_MAX if any fan is not operational */
|
||||
for (i = 0; i < CHASSIS_FAN_COUNT; i++) {
|
||||
if (!(fi[i].status & ONLP_FAN_STATUS_FAILED)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*adjusted = 1;
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
sysi_fanctrl_fan_absent_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted)
|
||||
{
|
||||
int i;
|
||||
*adjusted = 0;
|
||||
|
||||
/* Bring fan speed to FAN_DUTY_MAX if fan is not present */
|
||||
for (i = 0; i < CHASSIS_FAN_COUNT; i++) {
|
||||
if (fi[i].status & ONLP_FAN_STATUS_PRESENT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*adjusted = 1;
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
sysi_fanctrl_fan_unknown_speed_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted)
|
||||
{
|
||||
int i, match = 0;
|
||||
int fanduty;
|
||||
int legal_duties[] = {FAN_DUTY_MIN, 64, 76, 88, FAN_DUTY_MAX};
|
||||
|
||||
*adjusted = 0;
|
||||
|
||||
if (onlp_file_read_int(&fanduty, FAN_NODE(fan_duty_cycle_percentage)) < 0) {
|
||||
*adjusted = 1;
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MIN);
|
||||
}
|
||||
|
||||
/* Bring fan speed to min if current speed is not expected
|
||||
*/
|
||||
for (i = 0; i < AIM_ARRAYSIZE(legal_duties); i++) {
|
||||
if (fanduty != legal_duties[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
*adjusted = 1;
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MIN);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
struct thermal_threshold {
|
||||
int tid; /* thermal id */
|
||||
int threshold[4];
|
||||
};
|
||||
|
||||
struct thermal_threshold threshold_data[CHASSIS_THERMAL_COUNT] = {
|
||||
{ /* Not Used*/ },
|
||||
{ THERMAL_1_ON_MAIN_BROAD, {38000, 42000, 46000, 50000}},
|
||||
{ THERMAL_2_ON_MAIN_BROAD, {48000, 51000, 54000, 57000}},
|
||||
{ THERMAL_3_ON_MAIN_BROAD, {40000, 43000, 48000, 52000}},
|
||||
{ THERMAL_4_ON_MAIN_BROAD, {40000, 48000, 53000, 60000}},
|
||||
{ THERMAL_5_ON_MAIN_BROAD, {64000, 66000, 68000, 70000}},
|
||||
{ /* Not Used*/ },
|
||||
};
|
||||
|
||||
static int
|
||||
sysi_fanctrl_overall_thermal_sensor_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted)
|
||||
{
|
||||
int i, new_duty = FAN_DUTY_MIN;
|
||||
|
||||
*adjusted = 1;
|
||||
|
||||
for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_5_ON_MAIN_BROAD); i++) {
|
||||
if (ti[i-1].mcelsius > threshold_data[i-1].threshold[3]) {
|
||||
new_duty = FAN_DUTY_MAX;
|
||||
}
|
||||
else if (ti[i-1].mcelsius > threshold_data[i-1].threshold[2]) {
|
||||
new_duty = (new_duty > 88) ? new_duty : 88;
|
||||
}
|
||||
else if (ti[i-1].mcelsius > threshold_data[i-1].threshold[1]) {
|
||||
new_duty = (new_duty > 76) ? new_duty : 76;
|
||||
}
|
||||
else if (ti[i-1].mcelsius > threshold_data[i-1].threshold[0]) {
|
||||
new_duty = (new_duty > 64) ? new_duty : 64;
|
||||
}
|
||||
}
|
||||
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty);
|
||||
}
|
||||
|
||||
typedef int (*fan_control_policy)(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted);
|
||||
|
||||
fan_control_policy fan_control_policies[] = {
|
||||
sysi_fanctrl_fan_fault_policy,
|
||||
sysi_fanctrl_fan_absent_policy,
|
||||
sysi_fanctrl_fan_unknown_speed_policy,
|
||||
sysi_fanctrl_overall_thermal_sensor_policy,
|
||||
};
|
||||
|
||||
int
|
||||
onlp_sysi_platform_manage_fans(void)
|
||||
{
|
||||
int i, rc;
|
||||
onlp_fan_info_t fi[CHASSIS_FAN_COUNT];
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT];
|
||||
|
||||
memset(fi, 0, sizeof(fi));
|
||||
memset(ti, 0, sizeof(ti));
|
||||
|
||||
/* Get fan status
|
||||
*/
|
||||
for (i = 0; i < CHASSIS_FAN_COUNT; i++) {
|
||||
rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fi[i]);
|
||||
|
||||
if (rc != ONLP_STATUS_OK) {
|
||||
onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX);
|
||||
AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i+1);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get thermal sensor status
|
||||
*/
|
||||
for (i = 0; i < CHASSIS_THERMAL_COUNT; i++) {
|
||||
rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i+1), &ti[i]);
|
||||
|
||||
if (rc != ONLP_STATUS_OK) {
|
||||
onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX);
|
||||
AIM_LOG_ERROR("Unable to get thermal(%d) status\r\n", i+1);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Apply thermal policy according the policy list,
|
||||
* If fan duty is adjusted by one of the policies, skip the others
|
||||
*/
|
||||
for (i = 0; i < AIM_ARRAYSIZE(fan_control_policies); i++) {
|
||||
int adjusted = 0;
|
||||
|
||||
rc = fan_control_policies[i](fi, ti, &adjusted);
|
||||
if (!adjusted) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_manage_leds(void)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Thermal Sensor Platform Implementation.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_THERMAL(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static char* devfiles__[] = /* must map with onlp_thermal_id */
|
||||
{
|
||||
"reserved",
|
||||
NULL, /* CPU_CORE files */
|
||||
"/sys/bus/i2c/devices/10-0048*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-0049*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-004a*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-004c*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-004d*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-004b*temp1_input",
|
||||
"/sys/bus/i2c/devices/18-0058/psu_temp1_input",
|
||||
"/sys/bus/i2c/devices/17-0059/psu_temp1_input",
|
||||
};
|
||||
static char* cpu_coretemp_files[] =
|
||||
{
|
||||
"/sys/devices/platform/coretemp.0*temp2_input",
|
||||
"/sys/devices/platform/coretemp.0*temp3_input",
|
||||
"/sys/devices/platform/coretemp.0*temp4_input",
|
||||
"/sys/devices/platform/coretemp.0*temp5_input",
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Static values */
|
||||
static onlp_thermal_info_t linfo[] = {
|
||||
{ }, /* Not used */
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "Chassis Thermal Sensor 1", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "Chassis Thermal Sensor 2", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 3", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "Chassis Thermal Sensor 4", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "Chassis Thermal Sensor 5", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BROAD), "Chassis Thermal Sensor 6", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* This will be called to intiialize the thermali subsystem.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the information structure for the given thermal OID.
|
||||
*
|
||||
* If the OID is invalid, return ONLP_E_STATUS_INVALID.
|
||||
* If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
|
||||
* Otherwise, return ONLP_STATUS_OK with the OID's information.
|
||||
*
|
||||
* Note -- it is expected that you fill out the information
|
||||
* structure even if the sensor described by the OID is not present.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
|
||||
{
|
||||
int tid;
|
||||
VALIDATE(id);
|
||||
|
||||
tid = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[tid];
|
||||
|
||||
if(tid == THERMAL_CPU_CORE) {
|
||||
int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return onlp_file_read_int(&info->mcelsius, devfiles__[tid]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24sc/x86_64_accton_as7716_24sc_config.h>
|
||||
|
||||
/* <auto.start.cdefs(X86_64_ACCTON_AS7716_24SC_CONFIG_HEADER).source> */
|
||||
#define __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(_x) #_x
|
||||
#define __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(_x)
|
||||
x86_64_accton_as7716_24sc_config_settings_t x86_64_accton_as7716_24sc_config_settings[] =
|
||||
{
|
||||
#ifdef X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_LOGGING
|
||||
{ __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_LOGGING) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7716_24sc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
{ __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7716_24sc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT
|
||||
{ __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7716_24sc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
{ __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7716_24sc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB
|
||||
{ __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB), __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_STDLIB(__x86_64_accton_as7716_24sc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
{ __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24SC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7716_24sc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI
|
||||
{ __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7716_24sc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
{ NULL, NULL }
|
||||
};
|
||||
#undef __x86_64_accton_as7716_24sc_config_STRINGIFY_VALUE
|
||||
#undef __x86_64_accton_as7716_24sc_config_STRINGIFY_NAME
|
||||
|
||||
const char*
|
||||
x86_64_accton_as7716_24sc_config_lookup(const char* setting)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; x86_64_accton_as7716_24sc_config_settings[i].name; i++) {
|
||||
if(strcmp(x86_64_accton_as7716_24sc_config_settings[i].name, setting)) {
|
||||
return x86_64_accton_as7716_24sc_config_settings[i].value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
x86_64_accton_as7716_24sc_config_show(struct aim_pvs_s* pvs)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; x86_64_accton_as7716_24sc_config_settings[i].name; i++) {
|
||||
aim_printf(pvs, "%s = %s\n", x86_64_accton_as7716_24sc_config_settings[i].name, x86_64_accton_as7716_24sc_config_settings[i].value);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* <auto.end.cdefs(X86_64_ACCTON_AS7716_24SC_CONFIG_HEADER).source> */
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24sc/x86_64_accton_as7716_24sc_config.h>
|
||||
|
||||
/* <--auto.start.enum(ALL).source> */
|
||||
/* <auto.end.enum(ALL).source> */
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_accton_as7716_24sc Internal Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24SC_INT_H__
|
||||
#define __X86_64_ACCTON_AS7716_24SC_INT_H__
|
||||
|
||||
#include <x86_64_accton_as7716_24sc/x86_64_accton_as7716_24sc_config.h>
|
||||
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24SC_INT_H__ */
|
||||
@@ -0,0 +1,18 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24sc/x86_64_accton_as7716_24sc_config.h>
|
||||
|
||||
#include "x86_64_accton_as7716_24sc_log.h"
|
||||
/*
|
||||
* x86_64_accton_as7716_24sc log struct.
|
||||
*/
|
||||
AIM_LOG_STRUCT_DEFINE(
|
||||
X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_OPTIONS_DEFAULT,
|
||||
X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_BITS_DEFAULT,
|
||||
NULL, /* Custom log map */
|
||||
X86_64_ACCTON_AS7716_24SC_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24SC_LOG_H__
|
||||
#define __X86_64_ACCTON_AS7716_24SC_LOG_H__
|
||||
|
||||
#define AIM_LOG_MODULE_NAME x86_64_accton_as7716_24sc
|
||||
#include <AIM/aim_log.h>
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24SC_LOG_H__ */
|
||||
@@ -0,0 +1,24 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24sc/x86_64_accton_as7716_24sc_config.h>
|
||||
|
||||
#include "x86_64_accton_as7716_24sc_log.h"
|
||||
|
||||
static int
|
||||
datatypes_init__(void)
|
||||
{
|
||||
#define X86_64_ACCTON_AS7716_24SC_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
|
||||
#include <x86_64_accton_as7716_24sc/x86_64_accton_as7716_24sc.x>
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __x86_64_accton_as7716_24sc_module_init__(void)
|
||||
{
|
||||
AIM_LOG_STRUCT_REGISTER();
|
||||
datatypes_init__();
|
||||
}
|
||||
|
||||
int __onlp_platform_version__ = 1;
|
||||
@@ -0,0 +1,50 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24sc/x86_64_accton_as7716_24sc_config.h>
|
||||
|
||||
#if X86_64_ACCTON_AS7716_24SC_CONFIG_INCLUDE_UCLI == 1
|
||||
|
||||
#include <uCli/ucli.h>
|
||||
#include <uCli/ucli_argparse.h>
|
||||
#include <uCli/ucli_handler_macros.h>
|
||||
|
||||
static ucli_status_t
|
||||
x86_64_accton_as7716_24sc_ucli_ucli__config__(ucli_context_t* uc)
|
||||
{
|
||||
UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as7716_24sc)
|
||||
}
|
||||
|
||||
/* <auto.ucli.handlers.start> */
|
||||
/* <auto.ucli.handlers.end> */
|
||||
|
||||
static ucli_module_t
|
||||
x86_64_accton_as7716_24sc_ucli_module__ =
|
||||
{
|
||||
"x86_64_accton_as7716_24sc_ucli",
|
||||
NULL,
|
||||
x86_64_accton_as7716_24sc_ucli_ucli_handlers__,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
ucli_node_t*
|
||||
x86_64_accton_as7716_24sc_ucli_node_create(void)
|
||||
{
|
||||
ucli_node_t* n;
|
||||
ucli_module_init(&x86_64_accton_as7716_24sc_ucli_module__);
|
||||
n = ucli_node_create("x86_64_accton_as7716_24sc", NULL, &x86_64_accton_as7716_24sc_ucli_module__);
|
||||
ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as7716_24sc"));
|
||||
return n;
|
||||
}
|
||||
|
||||
#else
|
||||
void*
|
||||
x86_64_accton_as7716_24sc_ucli_node_create(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as7716-24sc REVISION=r0
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# platform-config for AS7716
|
||||
#
|
||||
######################################################################
|
||||
|
||||
x86-64-accton-as7716-24sc-r0:
|
||||
|
||||
grub:
|
||||
|
||||
serial: >-
|
||||
--port=0x3f8
|
||||
--speed=115200
|
||||
--word=8
|
||||
--parity=no
|
||||
--stop=1
|
||||
|
||||
kernel:
|
||||
<<: *kernel-4-14
|
||||
|
||||
args: >-
|
||||
nopat
|
||||
console=ttyS0,115200n8
|
||||
tg3.short_preamble=1
|
||||
tg3.bcm5718s_reset=1
|
||||
|
||||
##network:
|
||||
## interfaces:
|
||||
## ma1:
|
||||
## name: ~
|
||||
## syspath: pci0000:00/0000:00:1c.0/0000:0a:00.0
|
||||
@@ -0,0 +1,102 @@
|
||||
from onl.platform.base import *
|
||||
from onl.platform.accton import *
|
||||
|
||||
class OnlPlatform_x86_64_accton_as7716_24sc_r0(OnlPlatformAccton,
|
||||
OnlPlatformPortConfig_32x100):
|
||||
PLATFORM='x86-64-accton-as7716-24sc-r0'
|
||||
MODEL="AS7716-24sc"
|
||||
SYS_OBJECT_ID=".7716.24"
|
||||
|
||||
def baseconfig(self):
|
||||
|
||||
self.insmod('accton_i2c_cpld')
|
||||
self.insmod('dps850')
|
||||
self.insmod_platform()
|
||||
|
||||
########### initialize I2C bus 0 ###########
|
||||
self.new_i2c_devices([
|
||||
# initialize multiplexer (PCA9548)
|
||||
('pca9548', 0x77, 0),
|
||||
|
||||
# initiate leaf multiplexer (PCA9548)
|
||||
('pca9548', 0x70, 1),
|
||||
|
||||
# initiate chassis fan
|
||||
('as7716_24sc_fan', 0x66, 9),
|
||||
|
||||
# inititate LM75
|
||||
('lm75', 0x48, 10),
|
||||
('lm75', 0x49, 10),
|
||||
('lm75', 0x4a, 10),
|
||||
('lm75', 0x4b, 10),
|
||||
('lm75', 0x4c, 10),
|
||||
('lm75', 0x4d, 10),
|
||||
|
||||
#initiate CPLD
|
||||
('accton_i2c_cpld', 0x60, 11),
|
||||
('accton_i2c_cpld', 0x62, 12),
|
||||
('accton_i2c_cpld', 0x64, 13),
|
||||
|
||||
# initiate leaf multiplexer (PCA9548)
|
||||
('pca9548', 0x71, 2),
|
||||
|
||||
# initiate PSU-1
|
||||
('as7716_24sc_psu1', 0x50, 18),
|
||||
('dps850', 0x58, 18),
|
||||
|
||||
# initiate PSU-2
|
||||
('as7716_24sc_psu2', 0x51, 17),
|
||||
('dps850', 0x59, 17),
|
||||
|
||||
# initiate leaf multiplexer (PCA9548)
|
||||
('pca9548', 0x72, 2),
|
||||
('pca9548', 0x73, 2),
|
||||
('pca9548', 0x74, 2),
|
||||
('pca9548', 0x75, 2),
|
||||
|
||||
# initialize QSFP port 1-32
|
||||
('as7716_24sc_port9', 0x50, 25),
|
||||
('as7716_24sc_port10', 0x50, 26),
|
||||
('as7716_24sc_port11', 0x50, 27),
|
||||
('as7716_24sc_port12', 0x50, 28),
|
||||
('as7716_24sc_port1', 0x50, 29),
|
||||
('as7716_24sc_port2', 0x50, 30),
|
||||
('as7716_24sc_port3', 0x50, 31),
|
||||
('as7716_24sc_port4', 0x50, 32),
|
||||
('as7716_24sc_port6', 0x50, 33),
|
||||
('as7716_24sc_port5', 0x50, 34),
|
||||
('as7716_24sc_port8', 0x50, 35),
|
||||
('as7716_24sc_port7', 0x50, 36),
|
||||
('as7716_24sc_port13', 0x50, 37),
|
||||
('as7716_24sc_port14', 0x50, 38),
|
||||
('as7716_24sc_port15', 0x50, 39),
|
||||
('as7716_24sc_port16', 0x50, 40),
|
||||
('as7716_24sc_port18', 0x50, 41),
|
||||
('as7716_24sc_port17', 0x50, 42),
|
||||
('as7716_24sc_port20', 0x50, 43),
|
||||
('as7716_24sc_port19', 0x50, 44),
|
||||
('as7716_24sc_port22', 0x50, 45),
|
||||
('as7716_24sc_port21', 0x50, 46),
|
||||
('as7716_24sc_port24', 0x50, 47),
|
||||
('as7716_24sc_port23', 0x50, 48),
|
||||
('as7716_24sc_port26', 0x50, 49),
|
||||
('as7716_24sc_port25', 0x50, 50),
|
||||
('as7716_24sc_port28', 0x50, 51),
|
||||
('as7716_24sc_port27', 0x50, 52),
|
||||
('as7716_24sc_port30', 0x50, 53),
|
||||
('as7716_24sc_port29', 0x50, 54),
|
||||
('as7716_24sc_port32', 0x50, 55),
|
||||
('as7716_24sc_port31', 0x50, 56),
|
||||
|
||||
# initialize expansion card
|
||||
('as7716_24sc_excard1', 0x6a, 41),
|
||||
('as7716_24sc_excard2', 0x6a, 43),
|
||||
('as7716_24sc_excard3', 0x6a, 45),
|
||||
('as7716_24sc_excard4', 0x6a, 47),
|
||||
('as7716_24sc_excard5', 0x6a, 49),
|
||||
('as7716_24sc_excard6', 0x6a, 51),
|
||||
('as7716_24sc_excard7', 0x6a, 53),
|
||||
('as7716_24sc_excard8', 0x6a, 55),
|
||||
])
|
||||
|
||||
return True
|
||||
3
packages/platforms/accton/x86-64/x86-64-accton-as7716-24xc/.gitignore
vendored
Normal file
3
packages/platforms/accton/x86-64/x86-64-accton-as7716-24xc/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*x86*64*accton*as7716*24xc*.mk
|
||||
onlpdump.mk
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as7716-24xc ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64"
|
||||
1
packages/platforms/accton/x86-64/x86-64-accton-as7716-24xc/modules/builds/.gitignore
vendored
Normal file
1
packages/platforms/accton/x86-64/x86-64-accton-as7716-24xc/modules/builds/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lib
|
||||
@@ -0,0 +1,6 @@
|
||||
KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64
|
||||
KMODULES := $(wildcard *.c)
|
||||
VENDOR := accton
|
||||
BASENAME := x86-64-accton-as7716-24xc
|
||||
ARCH := x86_64
|
||||
include $(ONL)/make/kmodule.mk
|
||||
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
* An hwmon driver for accton as7716_24xc Transceiver Expansion Card
|
||||
*
|
||||
* Copyright (C) 2014 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* Based on ad7414.c
|
||||
* Copyright 2006 Stefan Roese <sr at denx.de>, DENX Software Engineering
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define CPLD_I2C_ADDR 0x60
|
||||
#define EXPANSION_CARD_PRESENT_REG 0x7A
|
||||
|
||||
static ssize_t show_present(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t set_slot(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count) ;
|
||||
extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg);
|
||||
|
||||
/* Addresses scanned
|
||||
*/
|
||||
static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
|
||||
|
||||
enum as7716_24xc_expansion_card_sysfs_attributes {
|
||||
CARD_TYPE,
|
||||
CARD_SLOT,
|
||||
CARD_PRESENT,
|
||||
NUM_OF_ATTR
|
||||
};
|
||||
|
||||
/* Each client has this additional data
|
||||
*/
|
||||
struct as7716_24xc_expansion_card_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 driver_slot;
|
||||
u8 status[NUM_OF_ATTR]; /* 0: card type
|
||||
1: card slot
|
||||
2: card presence */
|
||||
};
|
||||
|
||||
static struct as7716_24xc_expansion_card_data *update_device(struct device *dev, int update_all);
|
||||
|
||||
/* sysfs attributes for hwmon
|
||||
*/
|
||||
static SENSOR_DEVICE_ATTR(card_present, S_IRUGO, show_present, NULL, CARD_PRESENT);
|
||||
static SENSOR_DEVICE_ATTR(card_type, S_IRUGO, show_status, NULL, CARD_TYPE);
|
||||
static SENSOR_DEVICE_ATTR(card_slot, S_IWUSR | S_IRUGO, show_status, set_slot, CARD_SLOT);
|
||||
|
||||
static struct attribute *as7716_24xc_expansion_card_attributes[] = {
|
||||
&sensor_dev_attr_card_present.dev_attr.attr,
|
||||
&sensor_dev_attr_card_type.dev_attr.attr,
|
||||
&sensor_dev_attr_card_slot.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static ssize_t show_present(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct as7716_24xc_expansion_card_data *data = update_device(dev, 0);
|
||||
ssize_t status = 0;
|
||||
u8 present = !(data->status[CARD_PRESENT] & BIT(data->driver_slot));
|
||||
|
||||
if (!data->valid) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return sprintf(buf, "%d\n", (int)present);
|
||||
}
|
||||
|
||||
static ssize_t show_status(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct as7716_24xc_expansion_card_data *data = update_device(dev, 1);
|
||||
ssize_t status = 0;
|
||||
u8 present = 0;
|
||||
|
||||
if (!data->valid) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
present = !(data->status[CARD_PRESENT] & BIT(data->driver_slot));
|
||||
|
||||
switch (attr->index) {
|
||||
case CARD_TYPE:
|
||||
status = present ? (data->status[CARD_TYPE] >> 4) : -EIO;
|
||||
break;
|
||||
case CARD_SLOT:
|
||||
status = present ? (data->status[CARD_SLOT] & 0x7) : -EIO;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (status < 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return sprintf(buf, "%d\n", (int)status);
|
||||
}
|
||||
|
||||
static ssize_t set_slot(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int status, value;
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
|
||||
status = kstrtoint(buf, 10, &value);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (value < 0 || value > 7)
|
||||
return -EINVAL;
|
||||
|
||||
/* Write the slot id to register 0x02 */
|
||||
status = i2c_smbus_write_byte_data(client, 0x02, value);
|
||||
if (unlikely(status < 0)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct attribute_group as7716_24xc_expansion_card_group = {
|
||||
.attrs = as7716_24xc_expansion_card_attributes,
|
||||
};
|
||||
|
||||
static int as7716_24xc_expansion_card_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct as7716_24xc_expansion_card_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
|
||||
status = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct as7716_24xc_expansion_card_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
status = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
data->valid = 0;
|
||||
data->driver_slot = dev_id->driver_data;
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
dev_info(&client->dev, "chip found\n");
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &as7716_24xc_expansion_card_group);
|
||||
if (status) {
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register_with_info(&client->dev, "as7716_24xc_expansion_card",
|
||||
NULL, NULL, NULL);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: expansion card '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24xc_expansion_card_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int as7716_24xc_expansion_card_remove(struct i2c_client *client)
|
||||
{
|
||||
struct as7716_24xc_expansion_card_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24xc_expansion_card_group);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum expansion_card_index
|
||||
{
|
||||
as7716_24xc_excard1,
|
||||
as7716_24xc_excard2,
|
||||
as7716_24xc_excard3,
|
||||
as7716_24xc_excard4,
|
||||
as7716_24xc_excard5,
|
||||
as7716_24xc_excard6,
|
||||
as7716_24xc_excard7,
|
||||
as7716_24xc_excard8
|
||||
};
|
||||
|
||||
#define I2C_DEV_ID(x) { #x, x}
|
||||
|
||||
static const struct i2c_device_id as7716_24xc_expansion_card_id[] = {
|
||||
I2C_DEV_ID(as7716_24xc_excard1),
|
||||
I2C_DEV_ID(as7716_24xc_excard2),
|
||||
I2C_DEV_ID(as7716_24xc_excard3),
|
||||
I2C_DEV_ID(as7716_24xc_excard4),
|
||||
I2C_DEV_ID(as7716_24xc_excard5),
|
||||
I2C_DEV_ID(as7716_24xc_excard6),
|
||||
I2C_DEV_ID(as7716_24xc_excard7),
|
||||
I2C_DEV_ID(as7716_24xc_excard8),
|
||||
{/* LIST END */}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, as7716_24xc_expansion_card_id);
|
||||
|
||||
static struct i2c_driver as7716_24xc_expansion_card_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "as7716_24xc_expansion_card",
|
||||
},
|
||||
.probe = as7716_24xc_expansion_card_probe,
|
||||
.remove = as7716_24xc_expansion_card_remove,
|
||||
.id_table = as7716_24xc_expansion_card_id,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
static struct as7716_24xc_expansion_card_data *update_device(struct device *dev, int update_all)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct as7716_24xc_expansion_card_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|
||||
|| !data->valid) {
|
||||
int status, i;
|
||||
u8 regs[] = {0x00, 0x02}; /* 0x00: type, 0x02: slot */
|
||||
|
||||
data->valid = 0;
|
||||
dev_dbg(&client->dev, "Starting as7716_24xc update\n");
|
||||
|
||||
/* Read present status */
|
||||
status = accton_i2c_cpld_read(CPLD_I2C_ADDR, EXPANSION_CARD_PRESENT_REG);
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status);
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
data->status[CARD_PRESENT] = status;
|
||||
}
|
||||
|
||||
/* Update card type and slot if card is present */
|
||||
if (!(data->status[CARD_PRESENT] & BIT(data->driver_slot))) {
|
||||
for (i = 0; i < ARRAY_SIZE(regs); i++) {
|
||||
status = i2c_smbus_read_byte_data(client, regs[i]);
|
||||
|
||||
if (status < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data->status[i] = status;
|
||||
}
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int __init as7716_24xc_expansion_card_init(void)
|
||||
{
|
||||
return i2c_add_driver(&as7716_24xc_expansion_card_driver);
|
||||
}
|
||||
|
||||
static void __exit as7716_24xc_expansion_card_exit(void)
|
||||
{
|
||||
i2c_del_driver(&as7716_24xc_expansion_card_driver);
|
||||
}
|
||||
|
||||
module_init(as7716_24xc_expansion_card_init);
|
||||
module_exit(as7716_24xc_expansion_card_exit);
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("as7716_24xc_expansion_card driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -0,0 +1,467 @@
|
||||
/*
|
||||
* A hwmon driver for the Accton as7716 24xc fan
|
||||
*
|
||||
* Copyright (C) 2014 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/dmi.h>
|
||||
|
||||
#define DRVNAME "as7716_24xc_fan"
|
||||
|
||||
static struct as7716_24xc_fan_data *as7716_24xc_fan_update_device(struct device *dev);
|
||||
static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf);
|
||||
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count);
|
||||
|
||||
/* fan related data, the index should match sysfs_fan_attributes
|
||||
*/
|
||||
static const u8 fan_reg[] = {
|
||||
0x80, /* fan 1-6 present status */
|
||||
0x81, /* fan 1-6 direction(0:B2F 1:F2B) */
|
||||
0x87, /* fan PWM(for all fan) */
|
||||
0x90, /* front fan 1 speed(rpm) */
|
||||
0x91, /* front fan 2 speed(rpm) */
|
||||
0x92, /* front fan 3 speed(rpm) */
|
||||
0x93, /* front fan 4 speed(rpm) */
|
||||
0x98, /* rear fan 1 speed(rpm) */
|
||||
0x99, /* rear fan 2 speed(rpm) */
|
||||
0x9A, /* rear fan 3 speed(rpm) */
|
||||
0x9B, /* rear fan 4 speed(rpm) */
|
||||
};
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct as7716_24xc_fan_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* != 0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */
|
||||
};
|
||||
|
||||
enum fan_id {
|
||||
FAN1_ID,
|
||||
FAN2_ID,
|
||||
FAN3_ID,
|
||||
FAN4_ID
|
||||
};
|
||||
|
||||
enum sysfs_fan_attributes {
|
||||
FAN_PRESENT_REG,
|
||||
FAN_DIRECTION_REG,
|
||||
FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */
|
||||
FAN1_FRONT_SPEED_RPM,
|
||||
FAN2_FRONT_SPEED_RPM,
|
||||
FAN3_FRONT_SPEED_RPM,
|
||||
FAN4_FRONT_SPEED_RPM,
|
||||
FAN1_REAR_SPEED_RPM,
|
||||
FAN2_REAR_SPEED_RPM,
|
||||
FAN3_REAR_SPEED_RPM,
|
||||
FAN4_REAR_SPEED_RPM,
|
||||
FAN1_DIRECTION,
|
||||
FAN2_DIRECTION,
|
||||
FAN3_DIRECTION,
|
||||
FAN4_DIRECTION,
|
||||
FAN1_PRESENT,
|
||||
FAN2_PRESENT,
|
||||
FAN3_PRESENT,
|
||||
FAN4_PRESENT,
|
||||
FAN1_FAULT,
|
||||
FAN2_FAULT,
|
||||
FAN3_FAULT,
|
||||
FAN4_FAULT
|
||||
};
|
||||
|
||||
/* Define attributes
|
||||
*/
|
||||
#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT)
|
||||
#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_fault.dev_attr.attr
|
||||
|
||||
#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION)
|
||||
#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr
|
||||
|
||||
#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE)
|
||||
#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr
|
||||
|
||||
#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT)
|
||||
#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr
|
||||
|
||||
#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\
|
||||
static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM)
|
||||
#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \
|
||||
&sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr
|
||||
|
||||
/* 6 fan fault attributes in this platform */
|
||||
DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1);
|
||||
DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2);
|
||||
DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3);
|
||||
DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4);
|
||||
/* 6 fan speed(rpm) attributes in this platform */
|
||||
DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1);
|
||||
DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2);
|
||||
DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3);
|
||||
DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4);
|
||||
/* 6 fan present attributes in this platform */
|
||||
DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1);
|
||||
DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2);
|
||||
DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3);
|
||||
DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4);
|
||||
/* 6 fan direction attribute in this platform */
|
||||
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1);
|
||||
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2);
|
||||
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3);
|
||||
DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4);
|
||||
/* 1 fan duty cycle attribute in this platform */
|
||||
DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR();
|
||||
|
||||
static struct attribute *as7716_24xc_fan_attributes[] = {
|
||||
/* fan related attributes */
|
||||
DECLARE_FAN_FAULT_ATTR(1),
|
||||
DECLARE_FAN_FAULT_ATTR(2),
|
||||
DECLARE_FAN_FAULT_ATTR(3),
|
||||
DECLARE_FAN_FAULT_ATTR(4),
|
||||
DECLARE_FAN_SPEED_RPM_ATTR(1),
|
||||
DECLARE_FAN_SPEED_RPM_ATTR(2),
|
||||
DECLARE_FAN_SPEED_RPM_ATTR(3),
|
||||
DECLARE_FAN_SPEED_RPM_ATTR(4),
|
||||
DECLARE_FAN_PRESENT_ATTR(1),
|
||||
DECLARE_FAN_PRESENT_ATTR(2),
|
||||
DECLARE_FAN_PRESENT_ATTR(3),
|
||||
DECLARE_FAN_PRESENT_ATTR(4),
|
||||
DECLARE_FAN_DIRECTION_ATTR(1),
|
||||
DECLARE_FAN_DIRECTION_ATTR(2),
|
||||
DECLARE_FAN_DIRECTION_ATTR(3),
|
||||
DECLARE_FAN_DIRECTION_ATTR(4),
|
||||
DECLARE_FAN_DUTY_CYCLE_ATTR(),
|
||||
NULL
|
||||
};
|
||||
|
||||
#define FAN_DUTY_CYCLE_REG_MASK 0xF
|
||||
#define FAN_MAX_DUTY_CYCLE 100
|
||||
#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100
|
||||
#define MAX_RPM 366210
|
||||
#define REG_VAL_TO_RPM(val) (60000000000/(2*2*40960*(255-val)))
|
||||
|
||||
static int as7716_24xc_fan_read_value(struct i2c_client *client, u8 reg)
|
||||
{
|
||||
return i2c_smbus_read_byte_data(client, reg);
|
||||
}
|
||||
|
||||
static int as7716_24xc_fan_write_value(struct i2c_client *client, u8 reg, u8 value)
|
||||
{
|
||||
return i2c_smbus_write_byte_data(client, reg, value);
|
||||
}
|
||||
|
||||
/* fan utility functions
|
||||
*/
|
||||
static u32 reg_val_to_duty_cycle(u8 reg_val)
|
||||
{
|
||||
reg_val &= FAN_DUTY_CYCLE_REG_MASK;
|
||||
|
||||
if (!reg_val) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (reg_val == 0xF) {
|
||||
return FAN_MAX_DUTY_CYCLE;
|
||||
}
|
||||
|
||||
return (reg_val * 6) + 10;
|
||||
}
|
||||
|
||||
static u8 duty_cycle_to_reg_val(u8 duty_cycle)
|
||||
{
|
||||
if (duty_cycle < 16) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (duty_cycle >= 100) {
|
||||
return 0xF;
|
||||
}
|
||||
|
||||
return (duty_cycle - 10) / 6;
|
||||
}
|
||||
|
||||
static u32 reg_val_to_speed_rpm(u8 reg_val)
|
||||
{
|
||||
if (!reg_val) {
|
||||
return 0;
|
||||
}
|
||||
else if (reg_val == 0xFF) {
|
||||
return MAX_RPM;
|
||||
}
|
||||
|
||||
return REG_VAL_TO_RPM(reg_val);
|
||||
}
|
||||
|
||||
static u8 reg_val_to_direction(u8 reg_val, enum fan_id id)
|
||||
{
|
||||
u8 mask = (1 << id);
|
||||
return !!(reg_val & mask);
|
||||
}
|
||||
|
||||
static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id)
|
||||
{
|
||||
u8 mask = (1 << id);
|
||||
return !(reg_val & mask);
|
||||
}
|
||||
|
||||
static u8 is_fan_fault(struct as7716_24xc_fan_data *data, enum fan_id id)
|
||||
{
|
||||
u8 ret = 1;
|
||||
int front_fan_index = FAN1_FRONT_SPEED_RPM + id;
|
||||
int rear_fan_index = FAN1_REAR_SPEED_RPM + id;
|
||||
|
||||
/* Check if the speed of front or rear fan is ZERO,
|
||||
*/
|
||||
if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) &&
|
||||
reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
int error, value;
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
|
||||
error = kstrtoint(buf, 10, &value);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (value < 0 || value > FAN_MAX_DUTY_CYCLE)
|
||||
return -EINVAL;
|
||||
|
||||
as7716_24xc_fan_write_value(client, 0x28, 0); /* Disable fan speed watch dog */
|
||||
as7716_24xc_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value));
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fan_show_value(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct as7716_24xc_fan_data *data = as7716_24xc_fan_update_device(dev);
|
||||
ssize_t ret = 0;
|
||||
|
||||
if (data->valid) {
|
||||
switch (attr->index) {
|
||||
case FAN_DUTY_CYCLE_PERCENTAGE:
|
||||
{
|
||||
u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]);
|
||||
ret = sprintf(buf, "%u\n", duty_cycle);
|
||||
break;
|
||||
}
|
||||
case FAN1_FRONT_SPEED_RPM:
|
||||
case FAN2_FRONT_SPEED_RPM:
|
||||
case FAN3_FRONT_SPEED_RPM:
|
||||
case FAN4_FRONT_SPEED_RPM:
|
||||
case FAN1_REAR_SPEED_RPM:
|
||||
case FAN2_REAR_SPEED_RPM:
|
||||
case FAN3_REAR_SPEED_RPM:
|
||||
case FAN4_REAR_SPEED_RPM:
|
||||
{
|
||||
u32 rpm = reg_val_to_speed_rpm(data->reg_val[attr->index]);
|
||||
ret = sprintf(buf, "%u\n", rpm);
|
||||
break;
|
||||
}
|
||||
case FAN1_PRESENT:
|
||||
case FAN2_PRESENT:
|
||||
case FAN3_PRESENT:
|
||||
case FAN4_PRESENT:
|
||||
ret = sprintf(buf, "%d\n",
|
||||
reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG],
|
||||
attr->index - FAN1_PRESENT));
|
||||
break;
|
||||
case FAN1_FAULT:
|
||||
case FAN2_FAULT:
|
||||
case FAN3_FAULT:
|
||||
case FAN4_FAULT:
|
||||
ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT));
|
||||
break;
|
||||
case FAN1_DIRECTION:
|
||||
case FAN2_DIRECTION:
|
||||
case FAN3_DIRECTION:
|
||||
case FAN4_DIRECTION:
|
||||
ret = sprintf(buf, "%d\n",
|
||||
reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG],
|
||||
attr->index - FAN1_DIRECTION));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct attribute_group as7716_24xc_fan_group = {
|
||||
.attrs = as7716_24xc_fan_attributes,
|
||||
};
|
||||
|
||||
static struct as7716_24xc_fan_data *as7716_24xc_fan_update_device(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct as7716_24xc_fan_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2) ||
|
||||
!data->valid) {
|
||||
int i;
|
||||
|
||||
dev_dbg(&client->dev, "Starting as7716_24xc_fan update\n");
|
||||
data->valid = 0;
|
||||
|
||||
/* Update fan data
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) {
|
||||
int status = as7716_24xc_fan_read_value(client, fan_reg[i]);
|
||||
|
||||
if (status < 0) {
|
||||
data->valid = 0;
|
||||
mutex_unlock(&data->update_lock);
|
||||
dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status);
|
||||
return data;
|
||||
}
|
||||
else {
|
||||
data->reg_val[i] = status;
|
||||
}
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int as7716_24xc_fan_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct as7716_24xc_fan_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
|
||||
status = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct as7716_24xc_fan_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
status = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
data->valid = 0;
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
dev_info(&client->dev, "chip found\n");
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &as7716_24xc_fan_group);
|
||||
if (status) {
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register_with_info(&client->dev, "as7716_24xc_fan",
|
||||
NULL, NULL, NULL);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: fan '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24xc_fan_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int as7716_24xc_fan_remove(struct i2c_client *client)
|
||||
{
|
||||
struct as7716_24xc_fan_data *data = i2c_get_clientdata(client);
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24xc_fan_group);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Addresses to scan */
|
||||
static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
|
||||
|
||||
static const struct i2c_device_id as7716_24xc_fan_id[] = {
|
||||
{ "as7716_24xc_fan", 0 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, as7716_24xc_fan_id);
|
||||
|
||||
static struct i2c_driver as7716_24xc_fan_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = DRVNAME,
|
||||
},
|
||||
.probe = as7716_24xc_fan_probe,
|
||||
.remove = as7716_24xc_fan_remove,
|
||||
.id_table = as7716_24xc_fan_id,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
static int __init as7716_24xc_fan_init(void)
|
||||
{
|
||||
return i2c_add_driver(&as7716_24xc_fan_driver);
|
||||
}
|
||||
|
||||
static void __exit as7716_24xc_fan_exit(void)
|
||||
{
|
||||
i2c_del_driver(&as7716_24xc_fan_driver);
|
||||
}
|
||||
|
||||
module_init(as7716_24xc_fan_init);
|
||||
module_exit(as7716_24xc_fan_exit);
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("as7716_24xc_fan driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -0,0 +1,432 @@
|
||||
/*
|
||||
* A LED driver for the as7716_24xc_led
|
||||
*
|
||||
* Copyright (C) 2014 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
/*#define DEBUG*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/dmi.h>
|
||||
|
||||
extern int accton_i2c_cpld_read (unsigned short cpld_addr, u8 reg);
|
||||
extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value);
|
||||
|
||||
#define DRVNAME "as7716_24xc_led"
|
||||
|
||||
struct as7716_24xc_led_data {
|
||||
struct platform_device *pdev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* != 0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 reg_val[1]; /* only 1 register*/
|
||||
};
|
||||
|
||||
static struct as7716_24xc_led_data *ledctl = NULL;
|
||||
|
||||
/* LED related data
|
||||
*/
|
||||
|
||||
#define LED_CNTRLER_I2C_ADDRESS (0x60)
|
||||
|
||||
#define LED_TYPE_DIAG_REG_MASK (0x03)
|
||||
#define LED_MODE_DIAG_YELLOW_VALUE (0x00)
|
||||
#define LED_MODE_DIAG_ORANGE_VALUE (0x01)
|
||||
#define LED_MODE_DIAG_GREEN_VALUE (0x02)
|
||||
#define LED_MODE_DIAG_OFF_VALUE (0x03)
|
||||
|
||||
#define LED_TYPE_LOC_REG_MASK (0x10)
|
||||
#define LED_MODE_LOC_ORANGE_VALUE (0x00)
|
||||
#define LED_MODE_LOC_OFF_VALUE (0x10)
|
||||
|
||||
enum led_type {
|
||||
LED_TYPE_DIAG,
|
||||
LED_TYPE_LOC,
|
||||
LED_TYPE_FAN,
|
||||
LED_TYPE_PSU1,
|
||||
LED_TYPE_PSU2
|
||||
};
|
||||
|
||||
struct led_reg {
|
||||
u32 types;
|
||||
u8 reg_addr;
|
||||
};
|
||||
|
||||
static const struct led_reg led_reg_map[] = {
|
||||
{(1 << LED_TYPE_LOC) | (1 << LED_TYPE_DIAG) | (1 << LED_TYPE_FAN), 0x30},
|
||||
};
|
||||
|
||||
enum led_light_mode {
|
||||
LED_MODE_OFF,
|
||||
LED_MODE_RED = 10,
|
||||
LED_MODE_RED_BLINKING = 11,
|
||||
LED_MODE_ORANGE = 12,
|
||||
LED_MODE_ORANGE_BLINKING = 13,
|
||||
LED_MODE_YELLOW = 14,
|
||||
LED_MODE_YELLOW_BLINKING = 15,
|
||||
LED_MODE_GREEN = 16,
|
||||
LED_MODE_GREEN_BLINKING = 17,
|
||||
LED_MODE_BLUE = 18,
|
||||
LED_MODE_BLUE_BLINKING = 19,
|
||||
LED_MODE_PURPLE = 20,
|
||||
LED_MODE_PURPLE_BLINKING = 21,
|
||||
LED_MODE_AUTO = 22,
|
||||
LED_MODE_AUTO_BLINKING = 23,
|
||||
LED_MODE_WHITE = 24,
|
||||
LED_MODE_WHITE_BLINKING = 25,
|
||||
LED_MODE_CYAN = 26,
|
||||
LED_MODE_CYAN_BLINKING = 27,
|
||||
LED_MODE_UNKNOWN = 99
|
||||
};
|
||||
|
||||
struct led_type_mode {
|
||||
enum led_type type;
|
||||
enum led_light_mode mode;
|
||||
int reg_bit_mask;
|
||||
int mode_value;
|
||||
};
|
||||
|
||||
static struct led_type_mode led_type_mode_data[] = {
|
||||
{LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE},
|
||||
{LED_TYPE_LOC, LED_MODE_ORANGE,LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_ORANGE_VALUE},
|
||||
{LED_TYPE_DIAG, LED_MODE_OFF, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_OFF_VALUE},
|
||||
{LED_TYPE_DIAG, LED_MODE_GREEN, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_VALUE},
|
||||
{LED_TYPE_DIAG, LED_MODE_ORANGE,LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_ORANGE_VALUE},
|
||||
{LED_TYPE_DIAG, LED_MODE_YELLOW,LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_YELLOW_VALUE}
|
||||
};
|
||||
|
||||
static int get_led_reg(enum led_type type, u8 *reg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(led_reg_map); i++) {
|
||||
if(led_reg_map[i].types & (1 << type)) {
|
||||
*reg = led_reg_map[i].reg_addr;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) {
|
||||
|
||||
if (type != led_type_mode_data[i].type)
|
||||
continue;
|
||||
|
||||
if ((led_type_mode_data[i].reg_bit_mask & reg_val) ==
|
||||
led_type_mode_data[i].mode_value)
|
||||
{
|
||||
return led_type_mode_data[i].mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u8 led_light_mode_to_reg_val(enum led_type type,
|
||||
enum led_light_mode mode, u8 reg_val) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) {
|
||||
if (type != led_type_mode_data[i].type)
|
||||
continue;
|
||||
|
||||
if (mode != led_type_mode_data[i].mode)
|
||||
continue;
|
||||
|
||||
reg_val = led_type_mode_data[i].mode_value |
|
||||
(reg_val & (~led_type_mode_data[i].reg_bit_mask));
|
||||
break;
|
||||
}
|
||||
|
||||
return reg_val;
|
||||
}
|
||||
|
||||
static int as7716_24xc_led_read_value(u8 reg)
|
||||
{
|
||||
return accton_i2c_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg);
|
||||
}
|
||||
|
||||
static int as7716_24xc_led_write_value(u8 reg, u8 value)
|
||||
{
|
||||
return accton_i2c_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value);
|
||||
}
|
||||
|
||||
static void as7716_24xc_led_update(void)
|
||||
{
|
||||
mutex_lock(&ledctl->update_lock);
|
||||
|
||||
if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2)
|
||||
|| !ledctl->valid) {
|
||||
int i;
|
||||
|
||||
dev_dbg(&ledctl->pdev->dev, "Starting as7716_24xc_led update\n");
|
||||
|
||||
/* Update LED data
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) {
|
||||
int status = as7716_24xc_led_read_value(led_reg_map[i].reg_addr);
|
||||
|
||||
if (status < 0) {
|
||||
ledctl->valid = 0;
|
||||
dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status);
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
ledctl->reg_val[i] = status;
|
||||
}
|
||||
}
|
||||
|
||||
ledctl->last_updated = jiffies;
|
||||
ledctl->valid = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&ledctl->update_lock);
|
||||
}
|
||||
|
||||
static void as7716_24xc_led_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness led_light_mode,
|
||||
enum led_type type)
|
||||
{
|
||||
int reg_val;
|
||||
u8 reg ;
|
||||
mutex_lock(&ledctl->update_lock);
|
||||
|
||||
if( !get_led_reg(type, ®)) {
|
||||
dev_dbg(&ledctl->pdev->dev, "Not match register for %d.\n", type);
|
||||
}
|
||||
|
||||
reg_val = as7716_24xc_led_read_value(reg);
|
||||
if (reg_val < 0) {
|
||||
dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val);
|
||||
as7716_24xc_led_write_value(reg, reg_val);
|
||||
|
||||
/* to prevent the slow-update issue */
|
||||
ledctl->valid = 0;
|
||||
|
||||
exit:
|
||||
mutex_unlock(&ledctl->update_lock);
|
||||
}
|
||||
|
||||
|
||||
static void as7716_24xc_led_diag_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness led_light_mode)
|
||||
{
|
||||
as7716_24xc_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG);
|
||||
}
|
||||
|
||||
static enum led_brightness as7716_24xc_led_diag_get(struct led_classdev *cdev)
|
||||
{
|
||||
as7716_24xc_led_update();
|
||||
return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]);
|
||||
}
|
||||
|
||||
static void as7716_24xc_led_loc_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness led_light_mode)
|
||||
{
|
||||
as7716_24xc_led_set(led_cdev, led_light_mode, LED_TYPE_LOC);
|
||||
}
|
||||
|
||||
static enum led_brightness as7716_24xc_led_loc_get(struct led_classdev *cdev)
|
||||
{
|
||||
as7716_24xc_led_update();
|
||||
return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]);
|
||||
}
|
||||
|
||||
static void as7716_24xc_led_auto_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness led_light_mode)
|
||||
{
|
||||
}
|
||||
|
||||
static enum led_brightness as7716_24xc_led_auto_get(struct led_classdev *cdev)
|
||||
{
|
||||
return LED_MODE_AUTO;
|
||||
}
|
||||
|
||||
static struct led_classdev as7716_24xc_leds[] = {
|
||||
[LED_TYPE_DIAG] = {
|
||||
.name = "as7716_24xc_led::diag",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24xc_led_diag_set,
|
||||
.brightness_get = as7716_24xc_led_diag_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_GREEN,
|
||||
},
|
||||
[LED_TYPE_LOC] = {
|
||||
.name = "as7716_24xc_led::loc",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24xc_led_loc_set,
|
||||
.brightness_get = as7716_24xc_led_loc_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_ORANGE,
|
||||
},
|
||||
[LED_TYPE_FAN] = {
|
||||
.name = "as7716_24xc_led::fan",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24xc_led_auto_set,
|
||||
.brightness_get = as7716_24xc_led_auto_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_AUTO,
|
||||
},
|
||||
[LED_TYPE_PSU1] = {
|
||||
.name = "as7716_24xc_led::psu1",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24xc_led_auto_set,
|
||||
.brightness_get = as7716_24xc_led_auto_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_AUTO,
|
||||
},
|
||||
[LED_TYPE_PSU2] = {
|
||||
.name = "as7716_24xc_led::psu2",
|
||||
.default_trigger = "unused",
|
||||
.brightness_set = as7716_24xc_led_auto_set,
|
||||
.brightness_get = as7716_24xc_led_auto_get,
|
||||
.flags = LED_CORE_SUSPENDRESUME,
|
||||
.max_brightness = LED_MODE_AUTO,
|
||||
},
|
||||
};
|
||||
|
||||
static int as7716_24xc_led_suspend(struct platform_device *dev,
|
||||
pm_message_t state)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(as7716_24xc_leds); i++) {
|
||||
led_classdev_suspend(&as7716_24xc_leds[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int as7716_24xc_led_resume(struct platform_device *dev)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(as7716_24xc_leds); i++) {
|
||||
led_classdev_resume(&as7716_24xc_leds[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int as7716_24xc_led_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(as7716_24xc_leds); i++) {
|
||||
ret = led_classdev_register(&pdev->dev, &as7716_24xc_leds[i]);
|
||||
|
||||
if (ret < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check if all LEDs were successfully registered */
|
||||
if (i != ARRAY_SIZE(as7716_24xc_leds)){
|
||||
int j;
|
||||
|
||||
/* only unregister the LEDs that were successfully registered */
|
||||
for (j = 0; j < i; j++) {
|
||||
led_classdev_unregister(&as7716_24xc_leds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int as7716_24xc_led_remove(struct platform_device *pdev)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(as7716_24xc_leds); i++) {
|
||||
led_classdev_unregister(&as7716_24xc_leds[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver as7716_24xc_led_driver = {
|
||||
.probe = as7716_24xc_led_probe,
|
||||
.remove = as7716_24xc_led_remove,
|
||||
.suspend = as7716_24xc_led_suspend,
|
||||
.resume = as7716_24xc_led_resume,
|
||||
.driver = {
|
||||
.name = DRVNAME,
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init as7716_24xc_led_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = platform_driver_register(&as7716_24xc_led_driver);
|
||||
if (ret < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ledctl = kzalloc(sizeof(struct as7716_24xc_led_data), GFP_KERNEL);
|
||||
if (!ledctl) {
|
||||
ret = -ENOMEM;
|
||||
platform_driver_unregister(&as7716_24xc_led_driver);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
mutex_init(&ledctl->update_lock);
|
||||
|
||||
ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
|
||||
if (IS_ERR(ledctl->pdev)) {
|
||||
ret = PTR_ERR(ledctl->pdev);
|
||||
platform_driver_unregister(&as7716_24xc_led_driver);
|
||||
kfree(ledctl);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit as7716_24xc_led_exit(void)
|
||||
{
|
||||
platform_device_unregister(ledctl->pdev);
|
||||
platform_driver_unregister(&as7716_24xc_led_driver);
|
||||
kfree(ledctl);
|
||||
}
|
||||
|
||||
module_init(as7716_24xc_led_init);
|
||||
module_exit(as7716_24xc_led_exit);
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("as7716_24xc_led driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* An hwmon driver for accton as7716_24xc Power Module
|
||||
*
|
||||
* Copyright (C) 2014 Accton Technology Corporation.
|
||||
* Brandon Chuang <brandon_chuang@accton.com.tw>
|
||||
*
|
||||
* Based on ad7414.c
|
||||
* Copyright 2006 Stefan Roese <sr at denx.de>, DENX Software Engineering
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dmi.h>
|
||||
|
||||
#define PSU_STATUS_I2C_ADDR 0x60
|
||||
#define PSU_STATUS_I2C_REG_OFFSET 0x03
|
||||
|
||||
#define IS_POWER_GOOD(id, value) (!!(value & BIT(2+id)))
|
||||
#define IS_PRESENT(id, value) (!(value & BIT(id)))
|
||||
|
||||
static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf);
|
||||
extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg);
|
||||
|
||||
/* Addresses scanned
|
||||
*/
|
||||
static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
|
||||
|
||||
/* Each client has this additional data
|
||||
*/
|
||||
struct as7716_24xc_psu_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
char valid; /* !=0 if registers are valid */
|
||||
unsigned long last_updated; /* In jiffies */
|
||||
u8 index; /* PSU index */
|
||||
u8 status; /* Status(present/power_good) register read from CPLD */
|
||||
};
|
||||
|
||||
static struct as7716_24xc_psu_data *as7716_24xc_psu_update_device(struct device *dev);
|
||||
|
||||
enum as7716_24xc_psu_sysfs_attributes {
|
||||
PSU_PRESENT,
|
||||
PSU_POWER_GOOD,
|
||||
};
|
||||
|
||||
/* sysfs attributes for hwmon
|
||||
*/
|
||||
static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT);
|
||||
static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD);
|
||||
|
||||
static struct attribute *as7716_24xc_psu_attributes[] = {
|
||||
&sensor_dev_attr_psu_present.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_power_good.dev_attr.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
static ssize_t show_status(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct as7716_24xc_psu_data *data = as7716_24xc_psu_update_device(dev);
|
||||
u8 status = 0;
|
||||
|
||||
if (!data->valid) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (attr->index == PSU_PRESENT) {
|
||||
status = IS_PRESENT(data->index, data->status);
|
||||
}
|
||||
else { /* PSU_POWER_GOOD */
|
||||
status = IS_POWER_GOOD(data->index, data->status);
|
||||
}
|
||||
|
||||
return sprintf(buf, "%d\n", status);
|
||||
}
|
||||
|
||||
static const struct attribute_group as7716_24xc_psu_group = {
|
||||
.attrs = as7716_24xc_psu_attributes,
|
||||
};
|
||||
|
||||
static int as7716_24xc_psu_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *dev_id)
|
||||
{
|
||||
struct as7716_24xc_psu_data *data;
|
||||
int status;
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {
|
||||
status = -EIO;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data = kzalloc(sizeof(struct as7716_24xc_psu_data), GFP_KERNEL);
|
||||
if (!data) {
|
||||
status = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
data->valid = 0;
|
||||
data->index = dev_id->driver_data;
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
dev_info(&client->dev, "chip found\n");
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &as7716_24xc_psu_group);
|
||||
if (status) {
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
data->hwmon_dev = hwmon_device_register_with_info(&client->dev, "as7716_24xc_psu",
|
||||
NULL, NULL, NULL);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: psu '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24xc_psu_group);
|
||||
exit_free:
|
||||
kfree(data);
|
||||
exit:
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int as7716_24xc_psu_remove(struct i2c_client *client)
|
||||
{
|
||||
struct as7716_24xc_psu_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &as7716_24xc_psu_group);
|
||||
kfree(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum psu_index
|
||||
{
|
||||
as7716_24xc_psu1,
|
||||
as7716_24xc_psu2
|
||||
};
|
||||
|
||||
static const struct i2c_device_id as7716_24xc_psu_id[] = {
|
||||
{ "as7716_24xc_psu1", as7716_24xc_psu1 },
|
||||
{ "as7716_24xc_psu2", as7716_24xc_psu2 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, as7716_24xc_psu_id);
|
||||
|
||||
static struct i2c_driver as7716_24xc_psu_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "as7716_24xc_psu",
|
||||
},
|
||||
.probe = as7716_24xc_psu_probe,
|
||||
.remove = as7716_24xc_psu_remove,
|
||||
.id_table = as7716_24xc_psu_id,
|
||||
.address_list = normal_i2c,
|
||||
};
|
||||
|
||||
static struct as7716_24xc_psu_data *as7716_24xc_psu_update_device(struct device *dev)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct as7716_24xc_psu_data *data = i2c_get_clientdata(client);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|
||||
|| !data->valid) {
|
||||
int status;
|
||||
|
||||
data->valid = 0;
|
||||
dev_dbg(&client->dev, "Starting as7716_24xc update\n");
|
||||
|
||||
/* Read psu status */
|
||||
status = accton_i2c_cpld_read(PSU_STATUS_I2C_ADDR, PSU_STATUS_I2C_REG_OFFSET);
|
||||
|
||||
if (status < 0) {
|
||||
dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status);
|
||||
goto exit;
|
||||
}
|
||||
else {
|
||||
data->status = status;
|
||||
}
|
||||
|
||||
data->last_updated = jiffies;
|
||||
data->valid = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int __init as7716_24xc_psu_init(void)
|
||||
{
|
||||
return i2c_add_driver(&as7716_24xc_psu_driver);
|
||||
}
|
||||
|
||||
static void __exit as7716_24xc_psu_exit(void)
|
||||
{
|
||||
i2c_del_driver(&as7716_24xc_psu_driver);
|
||||
}
|
||||
|
||||
module_init(as7716_24xc_psu_init);
|
||||
module_exit(as7716_24xc_psu_exit);
|
||||
|
||||
MODULE_AUTHOR("Brandon Chuang <brandon_chuang@accton.com.tw>");
|
||||
MODULE_DESCRIPTION("as7716_24xc_psu driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-as7716-24xc ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
@@ -0,0 +1,2 @@
|
||||
FILTER=src
|
||||
include $(ONL)/make/subdirs.mk
|
||||
@@ -0,0 +1,45 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
MODULE := libonlp-x86-64-accton-as7716-24xc
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF x86_64_accton_as7716_24xc onlplib
|
||||
DEPENDMODULE_HEADERS := sff
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
SHAREDLIB := libonlp-x86-64-accton-as7716-24xc.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
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
.DEFAULT_GOAL := onlpdump
|
||||
|
||||
MODULE := onlpdump
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF onlp x86_64_accton_as7716_24xc 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
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
name: x86_64_accton_as7716_24xc
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
include $(ONL)/make/config.mk
|
||||
MODULE := x86_64_accton_as7716_24xc
|
||||
AUTOMODULE := x86_64_accton_as7716_24xc
|
||||
include $(BUILDER)/definemodule.mk
|
||||
@@ -0,0 +1,6 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_24xc README
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_24xc Autogeneration
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_accton_as7716_24xc_AUTO_DEFS := module/auto/x86_64_accton_as7716_24xc.yml
|
||||
x86_64_accton_as7716_24xc_AUTO_DIRS := module/inc/x86_64_accton_as7716_24xc module/src
|
||||
include $(BUILDER)/auto.mk
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_24xc Autogeneration Definitions.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
cdefs: &cdefs
|
||||
- X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_LOGGING:
|
||||
doc: "Include or exclude logging."
|
||||
default: 1
|
||||
- X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT:
|
||||
doc: "Default enabled log options."
|
||||
default: AIM_LOG_OPTIONS_DEFAULT
|
||||
- X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT:
|
||||
doc: "Default enabled log bits."
|
||||
default: AIM_LOG_BITS_DEFAULT
|
||||
- X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
|
||||
doc: "Default enabled custom log bits."
|
||||
default: 0
|
||||
- X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB:
|
||||
doc: "Default all porting macros to use the C standard libraries."
|
||||
default: 1
|
||||
- X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
|
||||
doc: "Include standard library headers for stdlib porting macros."
|
||||
default: X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB
|
||||
- X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI:
|
||||
doc: "Include generic uCli support."
|
||||
default: 0
|
||||
|
||||
|
||||
definitions:
|
||||
cdefs:
|
||||
X86_64_ACCTON_AS7716_24XC_CONFIG_HEADER:
|
||||
defs: *cdefs
|
||||
basename: x86_64_accton_as7716_24xc_config
|
||||
|
||||
portingmacro:
|
||||
x86_64_accton_as7716_24xc:
|
||||
macros:
|
||||
- malloc
|
||||
- free
|
||||
- memset
|
||||
- memcpy
|
||||
- strncpy
|
||||
- vsnprintf
|
||||
- snprintf
|
||||
- strlen
|
||||
@@ -0,0 +1,14 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24xc/x86_64_accton_as7716_24xc_config.h>
|
||||
|
||||
/* <--auto.start.xmacro(ALL).define> */
|
||||
/* <auto.end.xmacro(ALL).define> */
|
||||
|
||||
/* <--auto.start.xenum(ALL).define> */
|
||||
/* <auto.end.xenum(ALL).define> */
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_accton_as7716_24xc Configuration Header
|
||||
*
|
||||
* @addtogroup x86_64_accton_as7716_24xc-config
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24XC_CONFIG_H__
|
||||
#define __X86_64_ACCTON_AS7716_24XC_CONFIG_H__
|
||||
|
||||
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
|
||||
#include <global_custom_config.h>
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24XC_INCLUDE_CUSTOM_CONFIG
|
||||
#include <x86_64_accton_as7716_24xc_custom_config.h>
|
||||
#endif
|
||||
|
||||
/* <auto.start.cdefs(X86_64_ACCTON_AS7716_24XC_CONFIG_HEADER).header> */
|
||||
#include <AIM/aim.h>
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_LOGGING
|
||||
*
|
||||
* Include or exclude logging. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_LOGGING
|
||||
#define X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_LOGGING 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
*X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
*
|
||||
* Default enabled log options. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
#define X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled log bits. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT
|
||||
#define X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled custom log bits. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
#define X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB
|
||||
*
|
||||
* Default all porting macros to use the C standard libraries. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB
|
||||
#define X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
*
|
||||
* Include standard library headers for stdlib porting macros. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
#define X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB
|
||||
#endif
|
||||
|
||||
/**
|
||||
* X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI
|
||||
*
|
||||
* Include generic uCli support. */
|
||||
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI
|
||||
#define X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* All compile time options can be queried or displayed
|
||||
*/
|
||||
|
||||
/** Configuration settings structure. */
|
||||
typedef struct x86_64_accton_as7716_24xc_config_settings_s {
|
||||
/** name */
|
||||
const char* name;
|
||||
/** value */
|
||||
const char* value;
|
||||
} x86_64_accton_as7716_24xc_config_settings_t;
|
||||
|
||||
/** Configuration settings table. */
|
||||
/** x86_64_accton_as7716_24xc_config_settings table. */
|
||||
extern x86_64_accton_as7716_24xc_config_settings_t x86_64_accton_as7716_24xc_config_settings[];
|
||||
|
||||
/**
|
||||
* @brief Lookup a configuration setting.
|
||||
* @param setting The name of the configuration option to lookup.
|
||||
*/
|
||||
const char* x86_64_accton_as7716_24xc_config_lookup(const char* setting);
|
||||
|
||||
/**
|
||||
* @brief Show the compile-time configuration.
|
||||
* @param pvs The output stream.
|
||||
*/
|
||||
int x86_64_accton_as7716_24xc_config_show(struct aim_pvs_s* pvs);
|
||||
|
||||
/* <auto.end.cdefs(X86_64_ACCTON_AS7716_24XC_CONFIG_HEADER).header> */
|
||||
|
||||
#include "x86_64_accton_as7716_24xc_porting.h"
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24XC_CONFIG_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,26 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_accton_as7716_24xc Doxygen Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24XC_DOX_H__
|
||||
#define __X86_64_ACCTON_AS7716_24XC_DOX_H__
|
||||
|
||||
/**
|
||||
* @defgroup x86_64_accton_as7716_24xc x86_64_accton_as7716_24xc - x86_64_accton_as7716_24xc Description
|
||||
*
|
||||
|
||||
The documentation overview for this module should go here.
|
||||
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup x86_64_accton_as7716_24xc-x86_64_accton_as7716_24xc Public Interface
|
||||
* @defgroup x86_64_accton_as7716_24xc-config Compile Time Configuration
|
||||
* @defgroup x86_64_accton_as7716_24xc-porting Porting Macros
|
||||
*
|
||||
* @}
|
||||
*
|
||||
*/
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24XC_DOX_H__ */
|
||||
@@ -0,0 +1,107 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_accton_as7716_24xc Porting Macros.
|
||||
*
|
||||
* @addtogroup x86_64_accton_as7716_24xc-porting
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24XC_PORTING_H__
|
||||
#define __X86_64_ACCTON_AS7716_24XC_PORTING_H__
|
||||
|
||||
|
||||
/* <auto.start.portingmacro(ALL).define> */
|
||||
#if X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_MALLOC
|
||||
#if defined(GLOBAL_MALLOC)
|
||||
#define X86_64_ACCTON_AS7716_24XC_MALLOC GLOBAL_MALLOC
|
||||
#elif X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24XC_MALLOC malloc
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24XC_MALLOC is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_FREE
|
||||
#if defined(GLOBAL_FREE)
|
||||
#define X86_64_ACCTON_AS7716_24XC_FREE GLOBAL_FREE
|
||||
#elif X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24XC_FREE free
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24XC_FREE is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_MEMSET
|
||||
#if defined(GLOBAL_MEMSET)
|
||||
#define X86_64_ACCTON_AS7716_24XC_MEMSET GLOBAL_MEMSET
|
||||
#elif X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24XC_MEMSET memset
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24XC_MEMSET is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_MEMCPY
|
||||
#if defined(GLOBAL_MEMCPY)
|
||||
#define X86_64_ACCTON_AS7716_24XC_MEMCPY GLOBAL_MEMCPY
|
||||
#elif X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24XC_MEMCPY memcpy
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24XC_MEMCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_STRNCPY
|
||||
#if defined(GLOBAL_STRNCPY)
|
||||
#define X86_64_ACCTON_AS7716_24XC_STRNCPY GLOBAL_STRNCPY
|
||||
#elif X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24XC_STRNCPY strncpy
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24XC_STRNCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_VSNPRINTF
|
||||
#if defined(GLOBAL_VSNPRINTF)
|
||||
#define X86_64_ACCTON_AS7716_24XC_VSNPRINTF GLOBAL_VSNPRINTF
|
||||
#elif X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24XC_VSNPRINTF vsnprintf
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24XC_VSNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_SNPRINTF
|
||||
#if defined(GLOBAL_SNPRINTF)
|
||||
#define X86_64_ACCTON_AS7716_24XC_SNPRINTF GLOBAL_SNPRINTF
|
||||
#elif X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24XC_SNPRINTF snprintf
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24XC_SNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef X86_64_ACCTON_AS7716_24XC_STRLEN
|
||||
#if defined(GLOBAL_STRLEN)
|
||||
#define X86_64_ACCTON_AS7716_24XC_STRLEN GLOBAL_STRLEN
|
||||
#elif X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB == 1
|
||||
#define X86_64_ACCTON_AS7716_24XC_STRLEN strlen
|
||||
#else
|
||||
#error The macro X86_64_ACCTON_AS7716_24XC_STRLEN is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* <auto.end.portingmacro(ALL).define> */
|
||||
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24XC_PORTING_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,10 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
x86_64_accton_as7716_24xc_INCLUDES := -I $(THIS_DIR)inc
|
||||
x86_64_accton_as7716_24xc_INTERNAL_INCLUDES := -I $(THIS_DIR)src
|
||||
x86_64_accton_as7716_24xc_DEPENDMODULE_ENTRIES := init:x86_64_accton_as7716_24xc ucli:x86_64_accton_as7716_24xc
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Local source generation targets.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
ucli:
|
||||
@../../../../tools/uclihandlers.py x86_64_accton_as7716_24xc_ucli.c
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2017 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Fan Platform Implementation Defaults.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
enum fan_id {
|
||||
FAN_1_ON_FAN_BOARD = 1,
|
||||
FAN_2_ON_FAN_BOARD,
|
||||
FAN_3_ON_FAN_BOARD,
|
||||
FAN_4_ON_FAN_BOARD,
|
||||
FAN_1_ON_PSU_1,
|
||||
FAN_1_ON_PSU_2
|
||||
};
|
||||
|
||||
#define MAX_FAN_SPEED 14702
|
||||
#define MAX_PSU_FAN_SPEED 18000
|
||||
|
||||
#define CHASSIS_FAN_INFO(fid) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\
|
||||
0x0,\
|
||||
ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\
|
||||
0,\
|
||||
0,\
|
||||
ONLP_FAN_MODE_INVALID,\
|
||||
}
|
||||
|
||||
#define PSU_FAN_INFO(pid, fid) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\
|
||||
0x0,\
|
||||
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\
|
||||
0,\
|
||||
0,\
|
||||
ONLP_FAN_MODE_INVALID,\
|
||||
}
|
||||
|
||||
/* Static fan information */
|
||||
onlp_fan_info_t finfo[] = {
|
||||
{ }, /* Not used */
|
||||
CHASSIS_FAN_INFO(1),
|
||||
CHASSIS_FAN_INFO(2),
|
||||
CHASSIS_FAN_INFO(3),
|
||||
CHASSIS_FAN_INFO(4),
|
||||
PSU_FAN_INFO(1, 1),
|
||||
PSU_FAN_INFO(2, 1)
|
||||
};
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_FAN(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info)
|
||||
{
|
||||
int value;
|
||||
|
||||
/* get fan present status
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (value == 0) {
|
||||
return ONLP_STATUS_OK; /* fan is not present */
|
||||
}
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
|
||||
/* get fan fault status (turn on when any one fails)
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_fault", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (value > 0) {
|
||||
info->status |= ONLP_FAN_STATUS_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* get fan direction (both : the same)
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_direction", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->status |= value ? ONLP_FAN_STATUS_B2F : ONLP_FAN_STATUS_F2B;
|
||||
|
||||
|
||||
/* get front fan speed
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
info->rpm = value;
|
||||
|
||||
/* get rear fan speed
|
||||
*/
|
||||
if (onlp_file_read_int(&value, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
/* take the min value from front/rear fan speed
|
||||
*/
|
||||
if (info->rpm > value) {
|
||||
info->rpm = value;
|
||||
}
|
||||
|
||||
/* get speed percentage from rpm
|
||||
*/
|
||||
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
_onlp_get_fan_direction_on_psu(void)
|
||||
{
|
||||
/* Try to read direction from PSU1.
|
||||
* If PSU1 is not valid, read from PSU2
|
||||
*/
|
||||
int i = 0;
|
||||
|
||||
for (i = PSU1_ID; i <= PSU2_ID; i++) {
|
||||
psu_type_t psu_type;
|
||||
psu_type = get_psu_type(i, NULL, 0);
|
||||
|
||||
if (psu_type == PSU_TYPE_UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (psu_type) {
|
||||
case PSU_TYPE_AC_DPS850_F2B:
|
||||
return ONLP_FAN_STATUS_F2B;
|
||||
case PSU_TYPE_AC_DPS850_B2F:
|
||||
return ONLP_FAN_STATUS_B2F;
|
||||
default:
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
/* get fan direction
|
||||
*/
|
||||
info->status |= _onlp_get_fan_direction_on_psu();
|
||||
|
||||
/* get fan speed
|
||||
*/
|
||||
if (psu_dps850_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) {
|
||||
info->rpm = val;
|
||||
info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED;
|
||||
info->status |= (val == 0) ? ONLP_FAN_STATUS_FAILED : 0;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to all of onlp_fani_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_fani_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
{
|
||||
int rc = 0;
|
||||
int fid;
|
||||
VALIDATE(id);
|
||||
|
||||
fid = ONLP_OID_ID_GET(id);
|
||||
*info = finfo[fid];
|
||||
|
||||
switch (fid)
|
||||
{
|
||||
case FAN_1_ON_PSU_1:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info);
|
||||
break;
|
||||
case FAN_1_ON_PSU_2:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info);
|
||||
break;
|
||||
case FAN_1_ON_FAN_BOARD:
|
||||
case FAN_2_ON_FAN_BOARD:
|
||||
case FAN_3_ON_FAN_BOARD:
|
||||
case FAN_4_ON_FAN_BOARD:
|
||||
rc =_onlp_fani_info_get_fan(fid, 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)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as a percentage.
|
||||
*
|
||||
* This will only be called if the OID has the PERCENTAGE_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
{
|
||||
int fid;
|
||||
char *path = NULL;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
fid = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* reject p=0 (p=0, stop fan) */
|
||||
if (p == 0){
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
switch (fid)
|
||||
{
|
||||
case FAN_1_ON_FAN_BOARD:
|
||||
case FAN_2_ON_FAN_BOARD:
|
||||
path = FAN_NODE(fan_duty_cycle_percentage);
|
||||
break;
|
||||
default:
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
if (onlp_file_write_int(p, path) < 0) {
|
||||
AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,257 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2017 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define LED_FORMAT "/sys/class/leds/as7716_24xc_led::%s/brightness"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_LED(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* LED related data
|
||||
*/
|
||||
enum onlp_led_id
|
||||
{
|
||||
LED_RESERVED = 0,
|
||||
LED_PSU1,
|
||||
LED_PSU2,
|
||||
LED_FAN,
|
||||
LED_DIAG,
|
||||
LED_LOC
|
||||
};
|
||||
|
||||
enum led_light_mode {
|
||||
LED_MODE_OFF,
|
||||
LED_MODE_RED = 10,
|
||||
LED_MODE_RED_BLINKING = 11,
|
||||
LED_MODE_ORANGE = 12,
|
||||
LED_MODE_ORANGE_BLINKING = 13,
|
||||
LED_MODE_YELLOW = 14,
|
||||
LED_MODE_YELLOW_BLINKING = 15,
|
||||
LED_MODE_GREEN = 16,
|
||||
LED_MODE_GREEN_BLINKING = 17,
|
||||
LED_MODE_BLUE = 18,
|
||||
LED_MODE_BLUE_BLINKING = 19,
|
||||
LED_MODE_PURPLE = 20,
|
||||
LED_MODE_PURPLE_BLINKING = 21,
|
||||
LED_MODE_AUTO = 22,
|
||||
LED_MODE_AUTO_BLINKING = 23,
|
||||
LED_MODE_WHITE = 24,
|
||||
LED_MODE_WHITE_BLINKING = 25,
|
||||
LED_MODE_CYAN = 26,
|
||||
LED_MODE_CYAN_BLINKING = 27,
|
||||
LED_MODE_UNKNOWN = 99
|
||||
};
|
||||
|
||||
typedef struct led_light_mode_map {
|
||||
enum onlp_led_id id;
|
||||
enum led_light_mode driver_led_mode;
|
||||
enum onlp_led_mode_e onlp_led_mode;
|
||||
} led_light_mode_map_t;
|
||||
|
||||
led_light_mode_map_t led_map[] = {
|
||||
{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_DIAG, LED_MODE_ORANGE,ONLP_LED_MODE_ORANGE},
|
||||
{LED_DIAG, LED_MODE_YELLOW,ONLP_LED_MODE_YELLOW},
|
||||
{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_LOC, LED_MODE_ORANGE,ONLP_LED_MODE_ORANGE},
|
||||
{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}
|
||||
};
|
||||
|
||||
static char *leds[] = /* must map with onlp_led_id */
|
||||
{
|
||||
"reserved",
|
||||
"psu1",
|
||||
"psu2",
|
||||
"fan",
|
||||
"diag",
|
||||
"loc",
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the information for the given LED OID.
|
||||
*/
|
||||
static onlp_led_info_t linfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 1 (PSU1 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 2 (PSU2 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 4 (DIAG LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_YELLOW,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 5 (LOC LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_RED,
|
||||
},
|
||||
};
|
||||
|
||||
static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for (i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode)
|
||||
{
|
||||
return led_map[i].onlp_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for(i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode)
|
||||
{
|
||||
return led_map[i].driver_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to any other onlp_ledi_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_init(void)
|
||||
{
|
||||
/*
|
||||
* LED Off
|
||||
*/
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF);
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
{
|
||||
int lid, value;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
lid = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[ONLP_OID_ID_GET(id)];
|
||||
|
||||
/* Get LED mode */
|
||||
if (onlp_file_read_int(&value, LED_FORMAT, leds[lid]) < 0) {
|
||||
DEBUG_PRINT("Unable to read status from file "LED_FORMAT, leds[lid]);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->mode = driver_to_onlp_led_mode(lid, value);
|
||||
|
||||
/* Set the on/off status */
|
||||
if (info->mode != ONLP_LED_MODE_OFF) {
|
||||
info->status |= ONLP_LED_STATUS_ON;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn an LED on or off.
|
||||
*
|
||||
* This function will only be called if the LED OID supports the ONOFF
|
||||
* capability.
|
||||
*
|
||||
* What 'on' means in terms of colors or modes for multimode LEDs is
|
||||
* up to the platform to decide. This is intended as baseline toggle mechanism.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_set(onlp_oid_t id, int on_or_off)
|
||||
{
|
||||
VALIDATE(id);
|
||||
|
||||
if (!on_or_off) {
|
||||
return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function puts the LED into the given mode. It is a more functional
|
||||
* interface for multimode LEDs.
|
||||
*
|
||||
* Only modes reported in the LED's capabilities will be attempted.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
|
||||
{
|
||||
int lid;
|
||||
VALIDATE(id);
|
||||
|
||||
lid = ONLP_OID_ID_GET(id);
|
||||
if (onlp_file_write_int(onlp_to_driver_led_mode(lid , mode), LED_FORMAT, leds[lid]) < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic LED ioctl interface.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
LIBRARY := x86_64_accton_as7716_24xc
|
||||
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
include $(BUILDER)/lib.mk
|
||||
@@ -0,0 +1,315 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <onlp/onlp.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/i2c.h>
|
||||
#include <AIM/aim.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PSU_MODEL_NAME_LEN 13
|
||||
#define PSU_SERIAL_NUMBER_LEN 14
|
||||
#define PSU_NODE_MAX_PATH_LEN 64
|
||||
|
||||
int get_psu_serial_number(int id, char *serial, int serial_len)
|
||||
{
|
||||
int size = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
char *path = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_serial) :
|
||||
PSU2_AC_PMBUS_NODE(psu_mfr_serial) ;
|
||||
|
||||
if (serial == NULL || serial_len < PSU_SERIAL_NUMBER_LEN) {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
ret = onlp_file_read((uint8_t*)serial, PSU_SERIAL_NUMBER_LEN, &size, path);
|
||||
if (ret != ONLP_STATUS_OK || size != PSU_SERIAL_NUMBER_LEN) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
|
||||
}
|
||||
|
||||
serial[PSU_SERIAL_NUMBER_LEN] = '\0';
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len)
|
||||
{
|
||||
int value = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
char model[PSU_MODEL_NAME_LEN + 1] = {0};
|
||||
char *path = NULL;
|
||||
|
||||
if (modelname && modelname_len < PSU_MODEL_NAME_LEN) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Check if the psu is present
|
||||
*/
|
||||
path = (id == PSU1_ID) ? PSU1_AC_EEPROM_NODE(psu_present) :
|
||||
PSU2_AC_EEPROM_NODE(psu_present) ;
|
||||
if (onlp_file_read_int(&value, path) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Read mode name */
|
||||
path = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_mfr_model) :
|
||||
PSU2_AC_PMBUS_NODE(psu_mfr_model) ;
|
||||
ret = onlp_file_read((uint8_t*)model, PSU_MODEL_NAME_LEN, &value, path);
|
||||
if (ret != ONLP_STATUS_OK || value != PSU_MODEL_NAME_LEN) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
|
||||
}
|
||||
|
||||
if (modelname) {
|
||||
memcpy(modelname, model, sizeof(model));
|
||||
}
|
||||
|
||||
if (strncmp(model, "DPS-850AB-4", strlen("DPS-850AB-4")) == 0) {
|
||||
return PSU_TYPE_AC_DPS850_F2B;
|
||||
}
|
||||
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
int psu_dps850_pmbus_info_get(int id, char *node, int *value)
|
||||
{
|
||||
char *prefix = NULL;
|
||||
|
||||
*value = 0;
|
||||
|
||||
prefix = (id == PSU1_ID) ? PSU1_AC_PMBUS_PREFIX : PSU2_AC_PMBUS_PREFIX;
|
||||
if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
#define DSP_ADDR 0x6a
|
||||
#define DSP_READ_MAX_RETRY 50000
|
||||
#define DSP_WRITE_MAX_RETRY 10
|
||||
#define DSP_BUSY_VALUE 1
|
||||
#define DSP_NOBUSY_VALUE 0
|
||||
#define NTT_I2C_CMD_WAIT_US 100000
|
||||
|
||||
int dsp_exec_read(int bus, struct dsp_ctrl_s* dsp_ctrl, int *ret_val)
|
||||
{
|
||||
int i = 0, ret = 0;
|
||||
uint8_t value = 0, offset = 0;
|
||||
|
||||
if (ret_val) {
|
||||
*ret_val = 0;
|
||||
}
|
||||
|
||||
/* Set the address to be read into register 0x10 ~ 0x13
|
||||
*/
|
||||
for (i = 0; i <= 3; i++) {
|
||||
offset = 0x10 + i;
|
||||
value = (dsp_ctrl->value1 >> (8 * (3-i))) & 0xff;
|
||||
|
||||
ret = onlp_i2c_writeb(bus, DSP_ADDR, offset, value, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): Failed to write data into bus(%d), addr(0x%x), offset(0x%x), value(0x%x), error code(%d)\r\n",
|
||||
__FUNCTION__, __LINE__, bus, DSP_ADDR, offset, value, ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger the read operation : write 0x2 to Reg0x1 of dsp controller
|
||||
offset = 0x01;
|
||||
value = 0x02;
|
||||
ret = onlp_i2c_writeb(bus, DSP_ADDR, offset, value, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): Failed to write data into bus(%d), addr(0x%x), offset(0x%x), value(0x%x), error code(%d)\r\n",
|
||||
__FUNCTION__, __LINE__, bus, DSP_ADDR, offset, value, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// Check Reg0x02 is changed to 0x0(Busy:0x01, no-busy:0x00)
|
||||
offset = 0x02;
|
||||
i = DSP_READ_MAX_RETRY;
|
||||
while(i--) {
|
||||
ret = onlp_i2c_readb(bus, DSP_ADDR, offset, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): Failed to read data from bus(%d), addr(0x%x), offset(0x%x), value(0x%x), error code(%d)\r\n",
|
||||
__FUNCTION__, __LINE__, bus, DSP_ADDR, offset, value, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret == DSP_BUSY_VALUE) {
|
||||
usleep(NTT_I2C_CMD_WAIT_US);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret == DSP_BUSY_VALUE) {
|
||||
DEBUG_PRINT("%s(%d): Device is busy!! Not change to Idle\r\n", __FUNCTION__, __LINE__);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
|
||||
/* Read the output data from register 0x20 ~ 0x23
|
||||
*/
|
||||
for (i = 0; i <= 3; i++) {
|
||||
offset = 0x20 + i;
|
||||
|
||||
ret = onlp_i2c_readb(bus, DSP_ADDR, offset, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): Failed to read data from bus(%d), addr(0x%x), offset(0x%x), value(0x%x), error code(%d)\r\n",
|
||||
__FUNCTION__, __LINE__, bus, DSP_ADDR, offset, value, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret_val) {
|
||||
*ret_val <<= 8;
|
||||
*ret_val |= (ret & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int cfp_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
int i, bus, ret = 0, value = 0;
|
||||
struct dsp_ctrl_s eeprom_cmd = {"R", 0x40008000};
|
||||
int i2c_bus[] = {41, 43, 45, 47, 49, 51, 53, 55};
|
||||
|
||||
/* init dsp card */
|
||||
bus = i2c_bus[port % 8];
|
||||
|
||||
/* read eeprom */
|
||||
for (i = 0; i < 256; i++) {
|
||||
ret = dsp_exec_read(bus, &eeprom_cmd, &value);
|
||||
|
||||
if (ret < 0) {
|
||||
AIM_LOG_ERROR("Unable to read the eeprom of port (%d), check if it has been initialized properly by dsp_ctrl ", port);
|
||||
return ret;
|
||||
}
|
||||
|
||||
DEBUG_PRINT("%s(%d): command:(%s0x%x), Value(0x%x)\r\n", __FUNCTION__, __LINE__, eeprom_cmd.type, eeprom_cmd.value1, value);
|
||||
data[i] = (value & 0xff);
|
||||
eeprom_cmd.value1++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define EXPANSION_CARD_FORMAT "/sys/bus/i2c/devices/%d-006a/%s"
|
||||
|
||||
typedef enum card_type {
|
||||
CARD_TYPE_Q28,
|
||||
CARD_TYPE_DCO,
|
||||
CARD_TYPE_ACO,
|
||||
CARD_TYPE_NOT_PRESENT,
|
||||
CARD_TYPE_UNKNOWN
|
||||
} card_type_t;
|
||||
|
||||
card_type_t get_card_type(int port)
|
||||
{
|
||||
int slot = 0;
|
||||
int type = 0;
|
||||
int present = 0;
|
||||
int i2c_bus[] = {41, 43, 45, 47, 49, 51, 53, 55};
|
||||
|
||||
/* Get card slot of this port */
|
||||
slot = (port % 16) / 2;
|
||||
|
||||
if (onlp_file_read_int(&present, EXPANSION_CARD_FORMAT, i2c_bus[slot], "card_present") < 0) {
|
||||
AIM_LOG_ERROR("Unable to read card present status from bus(%d)\r\n", i2c_bus[slot]);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (!present) {
|
||||
return CARD_TYPE_NOT_PRESENT;
|
||||
}
|
||||
|
||||
if (onlp_file_read_int(&type, EXPANSION_CARD_FORMAT, i2c_bus[slot], "card_type") < 0) {
|
||||
AIM_LOG_ERROR("Unable to read card_type from bus(%d)\r\n", i2c_bus[slot]);
|
||||
return CARD_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (type != CARD_TYPE_Q28 && type != CARD_TYPE_DCO) {
|
||||
type = CARD_TYPE_ACO; /* workaround */
|
||||
}
|
||||
|
||||
//printf("CARD_TYPE = (%d)\r\n", type);
|
||||
return type;
|
||||
}
|
||||
|
||||
port_type_t get_port_type(int port)
|
||||
{
|
||||
card_type_t card_type;
|
||||
port_type_t port_type;
|
||||
|
||||
if (port < 16) {
|
||||
return PORT_TYPE_Q28;
|
||||
}
|
||||
|
||||
/* Get card type to get correct port mapping table */
|
||||
card_type = get_card_type(port);
|
||||
|
||||
switch (card_type) {
|
||||
case CARD_TYPE_Q28: port_type = PORT_TYPE_Q28; break;
|
||||
case CARD_TYPE_ACO: port_type = PORT_TYPE_ACO_200G; break;
|
||||
case CARD_TYPE_DCO: port_type = PORT_TYPE_DCO_200G; break;
|
||||
default: port_type = PORT_TYPE_UNKNOWN; break;
|
||||
}
|
||||
|
||||
//printf("Port type = (%d)\r\n", port_type);
|
||||
return port_type;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int get_port_number(void)
|
||||
{
|
||||
/* Read type from expansion card */
|
||||
int port_number;
|
||||
card_type_t card_type = get_card_type();
|
||||
|
||||
switch (card_type) {
|
||||
case CARD_TYPE_Q28: port_number = 32; break;
|
||||
case CARD_TYPE_ACO: /* fall through */
|
||||
case CARD_TYPE_DCO: port_number = 24; break;
|
||||
case CARD_TYPE_UNKNOWN: /* fall through */
|
||||
default: port_number = 16; break;
|
||||
}
|
||||
|
||||
printf("Port Number = (%d)\r\n", port_number);
|
||||
return port_number;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#ifndef __PLATFORM_LIB_H__
|
||||
#define __PLATFORM_LIB_H__
|
||||
|
||||
#include "x86_64_accton_as7716_24xc_log.h"
|
||||
|
||||
#define CHASSIS_FAN_COUNT 4
|
||||
#define CHASSIS_THERMAL_COUNT 7
|
||||
#define CHASSIS_LED_COUNT 5
|
||||
#define CHASSIS_PSU_COUNT 2
|
||||
|
||||
#define PSU1_ID 1
|
||||
#define PSU2_ID 2
|
||||
|
||||
#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/18-0058/"
|
||||
#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/17-0059/"
|
||||
|
||||
#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node
|
||||
#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node
|
||||
|
||||
#define PSU1_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/18-0050/"
|
||||
#define PSU2_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/17-0051/"
|
||||
|
||||
#define PSU1_AC_EEPROM_NODE(node) PSU1_AC_EEPROM_PREFIX#node
|
||||
#define PSU2_AC_EEPROM_NODE(node) PSU2_AC_EEPROM_PREFIX#node
|
||||
|
||||
#define FAN_BOARD_PATH "/sys/bus/i2c/devices/9-0066/"
|
||||
#define FAN_NODE(node) FAN_BOARD_PATH#node
|
||||
|
||||
#define IDPROM_PATH "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
|
||||
enum onlp_thermal_id
|
||||
{
|
||||
THERMAL_RESERVED = 0,
|
||||
THERMAL_CPU_CORE,
|
||||
THERMAL_1_ON_MAIN_BROAD,
|
||||
THERMAL_2_ON_MAIN_BROAD,
|
||||
THERMAL_3_ON_MAIN_BROAD,
|
||||
THERMAL_4_ON_MAIN_BROAD,
|
||||
THERMAL_5_ON_MAIN_BROAD,
|
||||
THERMAL_6_ON_MAIN_BROAD,
|
||||
THERMAL_1_ON_PSU1,
|
||||
THERMAL_1_ON_PSU2,
|
||||
};
|
||||
|
||||
typedef enum psu_type {
|
||||
PSU_TYPE_UNKNOWN,
|
||||
PSU_TYPE_AC_DPS850_F2B,
|
||||
PSU_TYPE_AC_DPS850_B2F
|
||||
} psu_type_t;
|
||||
|
||||
typedef enum port_type {
|
||||
PORT_TYPE_Q28,
|
||||
PORT_TYPE_ACO_200G,
|
||||
PORT_TYPE_DCO_200G,
|
||||
PORT_TYPE_UNKNOWN
|
||||
} port_type_t;
|
||||
|
||||
//int get_port_number(void);
|
||||
port_type_t get_port_type(int port);
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);
|
||||
int get_psu_serial_number(int id, char *serial, int serial_len);
|
||||
int psu_dps850_pmbus_info_get(int id, char *node, int *value);
|
||||
|
||||
struct dsp_ctrl_s
|
||||
{
|
||||
char *type;
|
||||
unsigned int value1;
|
||||
unsigned int value2;
|
||||
unsigned int value3;
|
||||
unsigned int value4;
|
||||
};
|
||||
|
||||
int dsp_initialize(int dsp_bus);
|
||||
int dsp_exec_read(int bus, struct dsp_ctrl_s* dsp_ctrl, int *ret_val);
|
||||
int cfp_eeprom_read(int port, uint8_t data[256]);
|
||||
|
||||
#define DEBUG_MODE 0
|
||||
|
||||
#if (DEBUG_MODE == 1)
|
||||
#define DEBUG_PRINT(fmt, args...) \
|
||||
printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args)
|
||||
#else
|
||||
#define DEBUG_PRINT(fmt, args...)
|
||||
#endif
|
||||
|
||||
#endif /* __PLATFORM_LIB_H__ */
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include <onlplib/file.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PSU_STATUS_PRESENT 1
|
||||
#define PSU_STATUS_POWER_GOOD 1
|
||||
#define PSU_NODE_MAX_PATH_LEN 64
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_PSU(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
psu_status_info_get(int id, char *node, int *value)
|
||||
{
|
||||
char *prefix = NULL;
|
||||
|
||||
*value = 0;
|
||||
|
||||
prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX;
|
||||
if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) {
|
||||
AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
psu_dps850_info_get(onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int index = ONLP_OID_ID_GET(info->hdr.id);
|
||||
|
||||
/* Set capability
|
||||
*/
|
||||
info->caps = ONLP_PSU_CAPS_AC;
|
||||
|
||||
if (info->status & ONLP_PSU_STATUS_FAILED) {
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* Set the associated oid_table */
|
||||
info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);
|
||||
info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT);
|
||||
|
||||
/* Read voltage, current and power */
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_v_out", &val) == 0) {
|
||||
info->mvout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_VOUT;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_v_in", &val) == 0) {
|
||||
info->mvin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_VIN;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_i_out", &val) == 0) {
|
||||
info->miout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_IOUT;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_i_in", &val) == 0) {
|
||||
info->miin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_IIN;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_p_out", &val) == 0) {
|
||||
info->mpout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_POUT;
|
||||
}
|
||||
|
||||
if (psu_dps850_pmbus_info_get(index, "psu_p_in", &val) == 0) {
|
||||
info->mpin = val;
|
||||
info->caps |= ONLP_PSU_CAPS_PIN;
|
||||
}
|
||||
|
||||
get_psu_serial_number(index, info->serial, sizeof(info->serial));
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get all information about the given PSU oid.
|
||||
*/
|
||||
static onlp_psu_info_t pinfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 },
|
||||
},
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 },
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int index = ONLP_OID_ID_GET(id);
|
||||
psu_type_t psu_type;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
memset(info, 0, sizeof(onlp_psu_info_t));
|
||||
*info = pinfo[index]; /* Set the onlp_oid_hdr_t */
|
||||
|
||||
/* Get the present state */
|
||||
if (psu_status_info_get(index, "psu_present", &val) != 0) {
|
||||
printf("Unable to read PSU(%d) node(psu_present)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_PRESENT) {
|
||||
info->status &= ~ONLP_PSU_STATUS_PRESENT;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
info->status |= ONLP_PSU_STATUS_PRESENT;
|
||||
|
||||
|
||||
/* Get power good status */
|
||||
if (psu_status_info_get(index, "psu_power_good", &val) != 0) {
|
||||
printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_POWER_GOOD) {
|
||||
info->status |= ONLP_PSU_STATUS_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* Get PSU type
|
||||
*/
|
||||
psu_type = get_psu_type(index, info->model, sizeof(info->model));
|
||||
|
||||
switch (psu_type) {
|
||||
case PSU_TYPE_AC_DPS850_F2B:
|
||||
case PSU_TYPE_AC_DPS850_B2F:
|
||||
ret = psu_dps850_info_get(info);
|
||||
break;
|
||||
case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/
|
||||
info->status |= ONLP_PSU_STATUS_UNPLUGGED;
|
||||
info->status &= ~ONLP_PSU_STATUS_FAILED;
|
||||
ret = ONLP_STATUS_OK;
|
||||
break;
|
||||
default:
|
||||
ret = ONLP_STATUS_E_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2017 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/sfpi.h>
|
||||
#include <onlplib/i2c.h>
|
||||
#include <onlplib/file.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define MAX_PORT_PATH 64
|
||||
#define NUM_OF_PORT 32
|
||||
static const int qsfp_mux_index[] = {
|
||||
29, 30, 31, 32, 34, 33, 36, 35,
|
||||
25, 26, 27, 28, 37, 38, 39, 40,
|
||||
42, 41, 44, 43, 46, 45, 48, 47,
|
||||
50, 49, 52, 51, 54, 53, 56, 55
|
||||
};
|
||||
|
||||
#define QSFP_BUS_INDEX(port) (qsfp_mux_index[port])
|
||||
#define QSFP_PORT_FORMAT "/sys/bus/i2c/devices/%d-0050/%s"
|
||||
|
||||
#define BIT_INDEX(i) (1ULL << (i))
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* 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;
|
||||
AIM_BITMAP_CLR_ALL(bmap);
|
||||
|
||||
for(p = 0; p < NUM_OF_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 = 0;
|
||||
port_type_t type = get_port_type(port);
|
||||
|
||||
//printf("%s(%d):Port Type = (%d)\r\n", __FUNCTION__, __LINE__, type);
|
||||
if (port >= 24 && type != PORT_TYPE_Q28) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (onlp_file_read_int(&present, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(port), "sfp_is_present") < 0) {
|
||||
AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return present;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
{
|
||||
uint32_t bytes[4];
|
||||
char path[MAX_PORT_PATH] = {0};
|
||||
FILE* fp;
|
||||
|
||||
sprintf(path, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(0), "sfp_is_present_all");
|
||||
fp = fopen(path, "r");
|
||||
|
||||
if(fp == NULL) {
|
||||
AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file.");
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
int count = fscanf(fp, "%x %x %x %x", bytes+0, bytes+1, bytes+2, bytes+3);
|
||||
fclose(fp);
|
||||
if(count != AIM_ARRAYSIZE(bytes)) {
|
||||
/* Likely a CPLD read timeout. */
|
||||
AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file.");
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
/* Convert to 64 bit integer in port order */
|
||||
int i = 0;
|
||||
uint32_t presence_all = 0 ;
|
||||
for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) {
|
||||
presence_all <<= 8;
|
||||
presence_all |= bytes[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_OF_PORT; i++) {
|
||||
port_type_t type = get_port_type(i);
|
||||
|
||||
if (i >= 24 && type != PORT_TYPE_Q28) {
|
||||
presence_all &= ~BIT_INDEX(i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Populate bitmap */
|
||||
for(i = 0; presence_all; i++) {
|
||||
AIM_BITMAP_MOD(dst, i, (presence_all & 1));
|
||||
presence_all >>= 1;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
int ret = ONLP_STATUS_OK;
|
||||
port_type_t port_type = get_port_type(port);
|
||||
|
||||
if (PORT_TYPE_UNKNOWN == port_type) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (PORT_TYPE_Q28 == port_type) {
|
||||
int size = 0;
|
||||
|
||||
if(onlp_file_read(data, 256, &size, QSFP_PORT_FORMAT, QSFP_BUS_INDEX(port), "sfp_eeprom") == ONLP_STATUS_OK) {
|
||||
ret = (size == 256) ? ONLP_STATUS_OK : ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
else {
|
||||
ret = ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return cfp_eeprom_read(port, data);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = QSFP_BUS_INDEX(port);
|
||||
return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
int bus = QSFP_BUS_INDEX(port);
|
||||
return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = QSFP_BUS_INDEX(port);
|
||||
return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
int bus = QSFP_BUS_INDEX(port);
|
||||
return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_denit(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,357 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2017 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <onlplib/file.h>
|
||||
#include <onlplib/i2c.h>
|
||||
#include <onlp/platformi/sysi.h>
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#include "x86_64_accton_as7716_24xc_int.h"
|
||||
#include "x86_64_accton_as7716_24xc_log.h"
|
||||
|
||||
#define CPLD_VERSION_FORMAT "/sys/bus/i2c/devices/%s/version"
|
||||
#define NUM_OF_CPLD 3
|
||||
|
||||
static char* cpld_path[NUM_OF_CPLD] =
|
||||
{
|
||||
"11-0060",
|
||||
"12-0062",
|
||||
"13-0064"
|
||||
};
|
||||
|
||||
const char*
|
||||
onlp_sysi_platform_get(void)
|
||||
{
|
||||
return "x86-64-accton-as7716-24xc-r0";
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
onlp_sysi_init(void)
|
||||
{
|
||||
/* init dsp */
|
||||
int i = 0, ret;
|
||||
int dsp_busses[] = {41, 43, 45, 47, 49, 51, 53, 55};
|
||||
|
||||
for (i = 0; i < AIM_ARRAYSIZE(dsp_busses); i++) {
|
||||
printf("%s(%d)\r\n", __FUNCTION__, __LINE__);
|
||||
ret = dsp_initialize(dsp_busses[i]);
|
||||
if (ret < 0) {
|
||||
DEBUG_PRINT("%s(%d): dsp_initialize failed, dsp_id(%d), bus(%d), error code(%d)\r\n", __FUNCTION__, __LINE__, i, dsp_busses[i], ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%s(%d)\r\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
onlp_sysi_onie_data_get(uint8_t** data, int* size)
|
||||
{
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int i = 0;
|
||||
uint8_t* rdata = aim_zmalloc(256);
|
||||
|
||||
for (i = 0; i < 128; i++) {
|
||||
ret = onlp_i2c_readw(0, 0x56, i*2, ONLP_I2C_F_FORCE);
|
||||
if (ret < 0) {
|
||||
aim_free(rdata);
|
||||
*size = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdata[i*2] = ret & 0xff;
|
||||
rdata[i*2+1] = (ret >> 8) & 0xff;
|
||||
}
|
||||
|
||||
*size = 256;
|
||||
*data = rdata;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* PSUs on the chassis */
|
||||
for (i = 1; i <= CHASSIS_PSU_COUNT; i++) {
|
||||
*e++ = ONLP_PSU_ID_CREATE(i);
|
||||
}
|
||||
|
||||
/* Fans on the chassis */
|
||||
for (i = 1; i <= CHASSIS_FAN_COUNT; i++) {
|
||||
*e++ = ONLP_FAN_ID_CREATE(i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
|
||||
{
|
||||
int i, v[NUM_OF_CPLD] = {0};
|
||||
|
||||
for (i = 0; i < AIM_ARRAYSIZE(cpld_path); i++) {
|
||||
v[i] = 0;
|
||||
|
||||
if(onlp_file_read_int(v+i, CPLD_VERSION_FORMAT , cpld_path[i]) < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
pi->cpld_versions = aim_fstrdup("%d.%d.%d", v[0], v[1], v[2]);
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
|
||||
{
|
||||
aim_free(pi->cpld_versions);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_manage_init(void)
|
||||
{
|
||||
/*
|
||||
* Bring the fan to max.
|
||||
* These will be reduced after the first platform management sequence.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FAN_DUTY_MAX (100)
|
||||
#define FAN_DUTY_MIN (52)
|
||||
|
||||
static int
|
||||
sysi_fanctrl_fan_fault_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted)
|
||||
{
|
||||
int i;
|
||||
*adjusted = 0;
|
||||
|
||||
/* Bring fan speed to FAN_DUTY_MAX if any fan is not operational */
|
||||
for (i = 0; i < CHASSIS_FAN_COUNT; i++) {
|
||||
if (!(fi[i].status & ONLP_FAN_STATUS_FAILED)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*adjusted = 1;
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
sysi_fanctrl_fan_absent_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted)
|
||||
{
|
||||
int i;
|
||||
*adjusted = 0;
|
||||
|
||||
/* Bring fan speed to FAN_DUTY_MAX if fan is not present */
|
||||
for (i = 0; i < CHASSIS_FAN_COUNT; i++) {
|
||||
if (fi[i].status & ONLP_FAN_STATUS_PRESENT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*adjusted = 1;
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
sysi_fanctrl_fan_unknown_speed_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted)
|
||||
{
|
||||
int i, match = 0;
|
||||
int fanduty;
|
||||
int legal_duties[] = {FAN_DUTY_MIN, 64, 76, 88, FAN_DUTY_MAX};
|
||||
|
||||
*adjusted = 0;
|
||||
|
||||
if (onlp_file_read_int(&fanduty, FAN_NODE(fan_duty_cycle_percentage)) < 0) {
|
||||
*adjusted = 1;
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MIN);
|
||||
}
|
||||
|
||||
/* Bring fan speed to min if current speed is not expected
|
||||
*/
|
||||
for (i = 0; i < AIM_ARRAYSIZE(legal_duties); i++) {
|
||||
if (fanduty != legal_duties[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
*adjusted = 1;
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MIN);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
struct thermal_threshold {
|
||||
int tid; /* thermal id */
|
||||
int threshold[4];
|
||||
};
|
||||
|
||||
struct thermal_threshold threshold_data[CHASSIS_THERMAL_COUNT] = {
|
||||
{ /* Not Used*/ },
|
||||
{ THERMAL_1_ON_MAIN_BROAD, {38000, 42000, 46000, 50000}},
|
||||
{ THERMAL_2_ON_MAIN_BROAD, {48000, 51000, 54000, 57000}},
|
||||
{ THERMAL_3_ON_MAIN_BROAD, {40000, 43000, 48000, 52000}},
|
||||
{ THERMAL_4_ON_MAIN_BROAD, {40000, 48000, 53000, 60000}},
|
||||
{ THERMAL_5_ON_MAIN_BROAD, {64000, 66000, 68000, 70000}},
|
||||
{ /* Not Used*/ },
|
||||
};
|
||||
|
||||
static int
|
||||
sysi_fanctrl_overall_thermal_sensor_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted)
|
||||
{
|
||||
int i, new_duty = FAN_DUTY_MIN;
|
||||
|
||||
*adjusted = 1;
|
||||
|
||||
for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_5_ON_MAIN_BROAD); i++) {
|
||||
if (ti[i-1].mcelsius > threshold_data[i-1].threshold[3]) {
|
||||
new_duty = FAN_DUTY_MAX;
|
||||
}
|
||||
else if (ti[i-1].mcelsius > threshold_data[i-1].threshold[2]) {
|
||||
new_duty = (new_duty > 88) ? new_duty : 88;
|
||||
}
|
||||
else if (ti[i-1].mcelsius > threshold_data[i-1].threshold[1]) {
|
||||
new_duty = (new_duty > 76) ? new_duty : 76;
|
||||
}
|
||||
else if (ti[i-1].mcelsius > threshold_data[i-1].threshold[0]) {
|
||||
new_duty = (new_duty > 64) ? new_duty : 64;
|
||||
}
|
||||
}
|
||||
|
||||
return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty);
|
||||
}
|
||||
|
||||
typedef int (*fan_control_policy)(onlp_fan_info_t fi[CHASSIS_FAN_COUNT],
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT],
|
||||
int *adjusted);
|
||||
|
||||
fan_control_policy fan_control_policies[] = {
|
||||
sysi_fanctrl_fan_fault_policy,
|
||||
sysi_fanctrl_fan_absent_policy,
|
||||
sysi_fanctrl_fan_unknown_speed_policy,
|
||||
sysi_fanctrl_overall_thermal_sensor_policy,
|
||||
};
|
||||
|
||||
int
|
||||
onlp_sysi_platform_manage_fans(void)
|
||||
{
|
||||
int i, rc;
|
||||
onlp_fan_info_t fi[CHASSIS_FAN_COUNT];
|
||||
onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT];
|
||||
|
||||
memset(fi, 0, sizeof(fi));
|
||||
memset(ti, 0, sizeof(ti));
|
||||
|
||||
/* Get fan status
|
||||
*/
|
||||
for (i = 0; i < CHASSIS_FAN_COUNT; i++) {
|
||||
rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fi[i]);
|
||||
|
||||
if (rc != ONLP_STATUS_OK) {
|
||||
onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX);
|
||||
AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i+1);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get thermal sensor status
|
||||
*/
|
||||
for (i = 0; i < CHASSIS_THERMAL_COUNT; i++) {
|
||||
rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i+1), &ti[i]);
|
||||
|
||||
if (rc != ONLP_STATUS_OK) {
|
||||
onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX);
|
||||
AIM_LOG_ERROR("Unable to get thermal(%d) status\r\n", i+1);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Apply thermal policy according the policy list,
|
||||
* If fan duty is adjusted by one of the policies, skip the others
|
||||
*/
|
||||
for (i = 0; i < AIM_ARRAYSIZE(fan_control_policies); i++) {
|
||||
int adjusted = 0;
|
||||
|
||||
rc = fan_control_policies[i](fi, ti, &adjusted);
|
||||
if (!adjusted) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_manage_leds(void)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Thermal Sensor Platform Implementation.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_THERMAL(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static char* devfiles__[] = /* must map with onlp_thermal_id */
|
||||
{
|
||||
"reserved",
|
||||
NULL, /* CPU_CORE files */
|
||||
"/sys/bus/i2c/devices/10-0048*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-0049*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-004a*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-004c*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-004d*temp1_input",
|
||||
"/sys/bus/i2c/devices/10-004b*temp1_input",
|
||||
"/sys/bus/i2c/devices/18-0058/psu_temp1_input",
|
||||
"/sys/bus/i2c/devices/17-0059/psu_temp1_input",
|
||||
};
|
||||
static char* cpu_coretemp_files[] =
|
||||
{
|
||||
"/sys/devices/platform/coretemp.0*temp2_input",
|
||||
"/sys/devices/platform/coretemp.0*temp3_input",
|
||||
"/sys/devices/platform/coretemp.0*temp4_input",
|
||||
"/sys/devices/platform/coretemp.0*temp5_input",
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Static values */
|
||||
static onlp_thermal_info_t linfo[] = {
|
||||
{ }, /* Not used */
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "Chassis Thermal Sensor 1", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "Chassis Thermal Sensor 2", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 3", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "Chassis Thermal Sensor 4", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "Chassis Thermal Sensor 5", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* This will be called to intiialize the thermali subsystem.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the information structure for the given thermal OID.
|
||||
*
|
||||
* If the OID is invalid, return ONLP_E_STATUS_INVALID.
|
||||
* If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
|
||||
* Otherwise, return ONLP_STATUS_OK with the OID's information.
|
||||
*
|
||||
* Note -- it is expected that you fill out the information
|
||||
* structure even if the sensor described by the OID is not present.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
|
||||
{
|
||||
int tid;
|
||||
VALIDATE(id);
|
||||
|
||||
tid = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[tid];
|
||||
|
||||
if(tid == THERMAL_CPU_CORE) {
|
||||
int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return onlp_file_read_int(&info->mcelsius, devfiles__[tid]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24xc/x86_64_accton_as7716_24xc_config.h>
|
||||
|
||||
/* <auto.start.cdefs(X86_64_ACCTON_AS7716_24XC_CONFIG_HEADER).source> */
|
||||
#define __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(_x) #_x
|
||||
#define __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE(_x) __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(_x)
|
||||
x86_64_accton_as7716_24xc_config_settings_t x86_64_accton_as7716_24xc_config_settings[] =
|
||||
{
|
||||
#ifdef X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_LOGGING
|
||||
{ __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_LOGGING) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as7716_24xc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
{ __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as7716_24xc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT
|
||||
{ __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as7716_24xc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
{ __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as7716_24xc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB
|
||||
{ __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB), __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_STDLIB(__x86_64_accton_as7716_24xc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
{ __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24XC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as7716_24xc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI
|
||||
{ __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME(X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI), __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE(X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI) },
|
||||
#else
|
||||
{ X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI(__x86_64_accton_as7716_24xc_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
{ NULL, NULL }
|
||||
};
|
||||
#undef __x86_64_accton_as7716_24xc_config_STRINGIFY_VALUE
|
||||
#undef __x86_64_accton_as7716_24xc_config_STRINGIFY_NAME
|
||||
|
||||
const char*
|
||||
x86_64_accton_as7716_24xc_config_lookup(const char* setting)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; x86_64_accton_as7716_24xc_config_settings[i].name; i++) {
|
||||
if(strcmp(x86_64_accton_as7716_24xc_config_settings[i].name, setting)) {
|
||||
return x86_64_accton_as7716_24xc_config_settings[i].value;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
x86_64_accton_as7716_24xc_config_show(struct aim_pvs_s* pvs)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; x86_64_accton_as7716_24xc_config_settings[i].name; i++) {
|
||||
aim_printf(pvs, "%s = %s\n", x86_64_accton_as7716_24xc_config_settings[i].name, x86_64_accton_as7716_24xc_config_settings[i].value);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/* <auto.end.cdefs(X86_64_ACCTON_AS7716_24XC_CONFIG_HEADER).source> */
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24xc/x86_64_accton_as7716_24xc_config.h>
|
||||
|
||||
/* <--auto.start.enum(ALL).source> */
|
||||
/* <auto.end.enum(ALL).source> */
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_accton_as7716_24xc Internal Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24XC_INT_H__
|
||||
#define __X86_64_ACCTON_AS7716_24XC_INT_H__
|
||||
|
||||
#include <x86_64_accton_as7716_24xc/x86_64_accton_as7716_24xc_config.h>
|
||||
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24XC_INT_H__ */
|
||||
@@ -0,0 +1,18 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24xc/x86_64_accton_as7716_24xc_config.h>
|
||||
|
||||
#include "x86_64_accton_as7716_24xc_log.h"
|
||||
/*
|
||||
* x86_64_accton_as7716_24xc log struct.
|
||||
*/
|
||||
AIM_LOG_STRUCT_DEFINE(
|
||||
X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_OPTIONS_DEFAULT,
|
||||
X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_BITS_DEFAULT,
|
||||
NULL, /* Custom log map */
|
||||
X86_64_ACCTON_AS7716_24XC_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __X86_64_ACCTON_AS7716_24XC_LOG_H__
|
||||
#define __X86_64_ACCTON_AS7716_24XC_LOG_H__
|
||||
|
||||
#define AIM_LOG_MODULE_NAME x86_64_accton_as7716_24xc
|
||||
#include <AIM/aim_log.h>
|
||||
|
||||
#endif /* __X86_64_ACCTON_AS7716_24XC_LOG_H__ */
|
||||
@@ -0,0 +1,24 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24xc/x86_64_accton_as7716_24xc_config.h>
|
||||
|
||||
#include "x86_64_accton_as7716_24xc_log.h"
|
||||
|
||||
static int
|
||||
datatypes_init__(void)
|
||||
{
|
||||
#define X86_64_ACCTON_AS7716_24XC_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
|
||||
#include <x86_64_accton_as7716_24xc/x86_64_accton_as7716_24xc.x>
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __x86_64_accton_as7716_24xc_module_init__(void)
|
||||
{
|
||||
AIM_LOG_STRUCT_REGISTER();
|
||||
datatypes_init__();
|
||||
}
|
||||
|
||||
int __onlp_platform_version__ = 1;
|
||||
@@ -0,0 +1,50 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_24xc/x86_64_accton_as7716_24xc_config.h>
|
||||
|
||||
#if X86_64_ACCTON_AS7716_24XC_CONFIG_INCLUDE_UCLI == 1
|
||||
|
||||
#include <uCli/ucli.h>
|
||||
#include <uCli/ucli_argparse.h>
|
||||
#include <uCli/ucli_handler_macros.h>
|
||||
|
||||
static ucli_status_t
|
||||
x86_64_accton_as7716_24xc_ucli_ucli__config__(ucli_context_t* uc)
|
||||
{
|
||||
UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as7716_24xc)
|
||||
}
|
||||
|
||||
/* <auto.ucli.handlers.start> */
|
||||
/* <auto.ucli.handlers.end> */
|
||||
|
||||
static ucli_module_t
|
||||
x86_64_accton_as7716_24xc_ucli_module__ =
|
||||
{
|
||||
"x86_64_accton_as7716_24xc_ucli",
|
||||
NULL,
|
||||
x86_64_accton_as7716_24xc_ucli_ucli_handlers__,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
ucli_node_t*
|
||||
x86_64_accton_as7716_24xc_ucli_node_create(void)
|
||||
{
|
||||
ucli_node_t* n;
|
||||
ucli_module_init(&x86_64_accton_as7716_24xc_ucli_module__);
|
||||
n = ucli_node_create("x86_64_accton_as7716_24xc", NULL, &x86_64_accton_as7716_24xc_ucli_module__);
|
||||
ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as7716_24xc"));
|
||||
return n;
|
||||
}
|
||||
|
||||
#else
|
||||
void*
|
||||
x86_64_accton_as7716_24xc_ucli_node_create(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as7716-24xc REVISION=r0
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# platform-config for AS7716
|
||||
#
|
||||
######################################################################
|
||||
|
||||
x86-64-accton-as7716-24xc-r0:
|
||||
|
||||
grub:
|
||||
|
||||
serial: >-
|
||||
--port=0x3f8
|
||||
--speed=115200
|
||||
--word=8
|
||||
--parity=no
|
||||
--stop=1
|
||||
|
||||
kernel:
|
||||
<<: *kernel-4-14
|
||||
|
||||
args: >-
|
||||
nopat
|
||||
console=ttyS0,115200n8
|
||||
tg3.short_preamble=1
|
||||
tg3.bcm5718s_reset=1
|
||||
|
||||
##network:
|
||||
## interfaces:
|
||||
## ma1:
|
||||
## name: ~
|
||||
## syspath: pci0000:00/0000:00:1c.0/0000:0a:00.0
|
||||
@@ -0,0 +1,104 @@
|
||||
from onl.platform.base import *
|
||||
from onl.platform.accton import *
|
||||
|
||||
class OnlPlatform_x86_64_accton_as7716_24xc_r0(OnlPlatformAccton,
|
||||
OnlPlatformPortConfig_32x100):
|
||||
PLATFORM='x86-64-accton-as7716-24xc-r0'
|
||||
MODEL="AS7716-24xc"
|
||||
SYS_OBJECT_ID=".7716.24"
|
||||
|
||||
def baseconfig(self):
|
||||
|
||||
self.insmod('accton_i2c_cpld')
|
||||
self.insmod('dps850')
|
||||
self.insmod_platform()
|
||||
|
||||
########### initialize I2C bus 0 ###########
|
||||
self.new_i2c_devices([
|
||||
# initialize multiplexer (PCA9548)
|
||||
('pca9548', 0x77, 0),
|
||||
|
||||
# initiate leaf multiplexer (PCA9548)
|
||||
('pca9548', 0x70, 1),
|
||||
|
||||
# initiate chassis fan
|
||||
('as7716_24xc_fan', 0x66, 9),
|
||||
|
||||
# inititate LM75
|
||||
('lm75', 0x48, 10),
|
||||
('lm75', 0x49, 10),
|
||||
('lm75', 0x4a, 10),
|
||||
('lm75', 0x4b, 10),
|
||||
('lm75', 0x4c, 10),
|
||||
('lm75', 0x4d, 10),
|
||||
|
||||
#initiate CPLD
|
||||
('accton_i2c_cpld', 0x60, 11),
|
||||
('accton_i2c_cpld', 0x62, 12),
|
||||
('accton_i2c_cpld', 0x64, 13),
|
||||
|
||||
# initiate leaf multiplexer (PCA9548)
|
||||
('pca9548', 0x71, 2),
|
||||
|
||||
# initiate PSU-1
|
||||
('as7716_24xc_psu1', 0x50, 18),
|
||||
('dps850', 0x58, 18),
|
||||
|
||||
# initiate PSU-2
|
||||
('as7716_24xc_psu2', 0x51, 17),
|
||||
('dps850', 0x59, 17),
|
||||
|
||||
# initiate leaf multiplexer (PCA9548)
|
||||
('pca9548', 0x72, 2),
|
||||
('pca9548', 0x73, 2),
|
||||
('pca9548', 0x74, 2),
|
||||
('pca9548', 0x75, 2),
|
||||
|
||||
# initialize QSFP port 1-32
|
||||
('as7716_24xc_port9', 0x50, 25),
|
||||
('as7716_24xc_port10', 0x50, 26),
|
||||
('as7716_24xc_port11', 0x50, 27),
|
||||
('as7716_24xc_port12', 0x50, 28),
|
||||
('as7716_24xc_port1', 0x50, 29),
|
||||
('as7716_24xc_port2', 0x50, 30),
|
||||
('as7716_24xc_port3', 0x50, 31),
|
||||
('as7716_24xc_port4', 0x50, 32),
|
||||
('as7716_24xc_port6', 0x50, 33),
|
||||
('as7716_24xc_port5', 0x50, 34),
|
||||
('as7716_24xc_port8', 0x50, 35),
|
||||
('as7716_24xc_port7', 0x50, 36),
|
||||
('as7716_24xc_port13', 0x50, 37),
|
||||
('as7716_24xc_port14', 0x50, 38),
|
||||
('as7716_24xc_port15', 0x50, 39),
|
||||
('as7716_24xc_port16', 0x50, 40),
|
||||
('as7716_24xc_port18', 0x50, 41),
|
||||
('as7716_24xc_port17', 0x50, 42),
|
||||
('as7716_24xc_port20', 0x50, 43),
|
||||
('as7716_24xc_port19', 0x50, 44),
|
||||
('as7716_24xc_port22', 0x50, 45),
|
||||
('as7716_24xc_port21', 0x50, 46),
|
||||
('as7716_24xc_port24', 0x50, 47),
|
||||
('as7716_24xc_port23', 0x50, 48),
|
||||
('as7716_24xc_port26', 0x50, 49),
|
||||
('as7716_24xc_port25', 0x50, 50),
|
||||
('as7716_24xc_port28', 0x50, 51),
|
||||
('as7716_24xc_port27', 0x50, 52),
|
||||
('as7716_24xc_port30', 0x50, 53),
|
||||
('as7716_24xc_port29', 0x50, 54),
|
||||
('as7716_24xc_port32', 0x50, 55),
|
||||
('as7716_24xc_port31', 0x50, 56),
|
||||
|
||||
# initialize expansion card
|
||||
('as7716_24xc_excard1', 0x6a, 41),
|
||||
('as7716_24xc_excard2', 0x6a, 43),
|
||||
('as7716_24xc_excard3', 0x6a, 45),
|
||||
('as7716_24xc_excard4', 0x6a, 47),
|
||||
('as7716_24xc_excard5', 0x6a, 49),
|
||||
('as7716_24xc_excard6', 0x6a, 51),
|
||||
('as7716_24xc_excard7', 0x6a, 53),
|
||||
('as7716_24xc_excard8', 0x6a, 55),
|
||||
|
||||
('24c02', 0x56, 0),
|
||||
])
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user