Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Ethernet45 73 tenGigE46 46 10000
Ethernet46 76 tenGigE47 47 10000
Ethernet47 75 tenGigE48 48 10000
Ethernet48 37,38,39,40 hundredGigE49 49 100000
Ethernet52 29,30,31,32 hundredGigE50 53 100000
Ethernet56 33,34,35,36 hundredGigE51 57 100000
Ethernet60 49,50,51,52 hundredGigE52 61 100000
Ethernet64 45,46,47,48 hundredGigE53 65 100000
Ethernet68 41,42,43,44 hundredGigE54 69 100000
Ethernet52 29,30,31,32 hundredGigE50 50 100000
Ethernet56 33,34,35,36 hundredGigE51 51 100000
Ethernet60 49,50,51,52 hundredGigE52 52 100000
Ethernet64 45,46,47,48 hundredGigE53 53 100000
Ethernet68 41,42,43,44 hundredGigE54 54 100000
67 changes: 67 additions & 0 deletions device/accton/x86_64-accton_as5835_54t-r0/pddf/pd-plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{

"XCVR":
{
"xcvr_present":
{
"i2c":
{
"valmap-SFP": {"1":true, "0":false },
"valmap-SFP28": {"1":true, "0":false },
"valmap-QSFP28": {"1":true, "0":false}
}
}
},
"PSU":
{
"psu_present":
{
"i2c":
{
"valmap": { "1":true, "0":false }
}
},

"psu_power_good":
{
"i2c":
{
"valmap": { "1": true, "0":false }
}
},

"psu_fan_dir":
{
"i2c":
{
"valmap": { "F2B":"EXHAUST", "B2F":"INTAKE" }
}
},

"PSU_FAN_MAX_SPEED":"18000"
},

"FAN":
{
"direction":
{
"i2c":
{
"valmap": {"1":"INTAKE", "0":"EXHAUST"}
}
},

"present":
{
"i2c":
{
"valmap": {"1":true, "0":false}
}
},

"duty_cycle_to_pwm": "lambda dc: (dc/5)",

"pwm_to_duty_cycle": "lambda pwm: (pwm*5)"
}

}
690 changes: 690 additions & 0 deletions device/accton/x86_64-accton_as5835_54t-r0/pddf/pddf-device.json

Large diffs are not rendered by default.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ifneq ($(KERNELRELEASE),)
obj-m:= accton_as5835_54t_cpld.o accton_as5835_54t_psu.o \
accton_as5835_54t_fan.o accton_as5835_54t_leds.o \
ym2651y.o
ym2651y.o pddf_custom_psu.o

else
ifeq (,$(KERNEL_SRC))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#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/delay.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
#include <linux/slab.h>
#include <linux/dmi.h>
#include "../../../../pddf/i2c/modules/include/pddf_psu_defs.h"

ssize_t pddf_show_custom_psu_v_out(struct device *dev, struct device_attribute *da, char *buf);
extern PSU_SYSFS_ATTR_DATA access_psu_v_out;

static int two_complement_to_int(u16 data, u8 valid_bit, int mask)
{
u16 valid_data = data & mask;
bool is_negative = valid_data >> (valid_bit - 1);

return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data;
}

static u8 psu_get_vout_mode(struct i2c_client *client)
{
u8 status = 0, retry = 10;
uint8_t offset = 0x20; // VOUT_MODE

while (retry) {
status = i2c_smbus_read_byte_data((struct i2c_client *)client, offset);
if (unlikely(status < 0)) {
msleep(60);
retry--;
continue;
}
break;
}

if (status < 0)
{
printk(KERN_ERR "%s: Get PSU Vout mode failed\n", __func__);
return 0;
}
else
{
/*printk(KERN_ERR "%s: vout_mode reg value 0x%x\n", __func__, status);*/
return status;
}
}

static u16 psu_get_v_out(struct i2c_client *client)
{
u16 status = 0, retry = 10;
uint8_t offset = 0x8b; // READ_VOUT

while (retry) {
status = i2c_smbus_read_word_data((struct i2c_client *)client, offset);
if (unlikely(status < 0)) {
msleep(60);
retry--;
continue;
}
break;
}

if (status < 0)
{
printk(KERN_ERR "%s: Get PSU Vout failed\n", __func__);
return 0;
}
else
{
/*printk(KERN_ERR "%s: vout reg value 0x%x\n", __func__, status);*/
return status;
}
}

ssize_t pddf_show_custom_psu_v_out(struct device *dev, struct device_attribute *da, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
int exponent, mantissa;
int multiplier = 1000;

u16 value = psu_get_v_out(client);
u8 vout_mode = psu_get_vout_mode(client);

if ((vout_mode >> 5) == 0)
exponent = two_complement_to_int(vout_mode & 0x1f, 5, 0x1f);
else
{
printk(KERN_ERR "%s: Only support linear mode for vout mode\n", __func__);
exponent = 0;
}
mantissa = value;
if (exponent >= 0)
return sprintf(buf, "%d\n", (mantissa << exponent) * multiplier);
else
return sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent));
}



static int __init pddf_custom_psu_init(void)
{
access_psu_v_out.show = pddf_show_custom_psu_v_out;
access_psu_v_out.do_get = NULL;
return 0;
}

static void __exit pddf_custom_psu_exit(void)
{
return;
}

MODULE_AUTHOR("Broadcom");
MODULE_DESCRIPTION("pddf custom psu api");
MODULE_LICENSE("GPL");

module_init(pddf_custom_psu_init);
module_exit(pddf_custom_psu_exit);

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Accton AS5835-54T Platform Monitoring service
Before=pmon.service
After=pddf-platform-init.service
DefaultDependencies=no

[Service]
ExecStart=/usr/local/bin/accton_as5835_54t_pddf_monitor.py
KillSignal=SIGKILL
SuccessExitStatus=SIGKILL

# Resource Limitations
LimitCORE=infinity

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from setuptools import setup

setup(
name='sonic-platform',
version='1.0',
description='SONiC platform API implementation on Accton Platforms',
license='Apache 2.0',
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
url='https://github.com/Azure/sonic-buildimage',
packages=['sonic_platform'],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Plugins',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.7',
'Topic :: Utilities',
],
keywords='sonic SONiC platform PLATFORM',
)
Loading