[Accton/PDDF] Support pddf to as4630/as7816/as7326 (#10340)

Why I did it
Support pddf to as4630/as7816/as7326

How I did it
Send needed file to the PR for these platform

How to verify it
Test sensors and show platform cmd.
root@as7326-56x-3:/home/admin# show platform psustatus
PSU Model Serial HW Rev Voltage (V) Current (A) Power (W) Status LED

PSU 1 FSF045-611 FSF0451912000505 N/A 12.06 5.50 66.00 OK green
PSU 2 FSF045-611 FSF0451912000568 N/A 12.00 5.50 66.00 OK green

root@as7326-56x-3:/home/admin# sensors
lm75-i2c-15-4a
Adapter: i2c-1-mux (chan_id 6)
Main Board Temperature: +35.5 C (high = +80.0 C, hyst = +75.0 C)

lm75-i2c-15-4b
Adapter: i2c-1-mux (chan_id 6)
CPU Board Temperature: +29.0 C (high = +80.0 C, hyst = +75.0 C)

fan_ctrl-i2c-11-66
Adapter: i2c-1-mux (chan_id 2)
fan1: 9100 RPM
fan2: 9400 RPM
fan3: 9300 RPM
fan4: 9600 RPM
fan5: 9000 RPM
fan6: 9100 RPM
fan7: 9100 RPM
fan8: 9300 RPM
fan9: 9200 RPM
fan10: 9400 RPM
fan11: 9200 RPM
fan12: 9400 RPM

pch_haswell-virtual-0
Adapter: Virtual device
temp1: +43.0 C

psu_pmbus-i2c-17-59
Adapter: i2c-1-mux (chan_id 0)
in3: +12.06 V
fan1: 6272 RPM
temp1: +37.0 C
power2: 60.00 W
curr2: +6.00 A

lm75-i2c-15-49
Adapter: i2c-1-mux (chan_id 6)
Main Board Temperature: +40.0 C (high = +80.0 C, hyst = +75.0 C)

lm75-i2c-15-48
Adapter: i2c-1-mux (chan_id 6)
Main Board Temperature: +39.0 C (high = +80.0 C, hyst = +75.0 C)

psu_pmbus-i2c-13-5b
Adapter: i2c-1-mux (chan_id 4)
in3: +12.00 V
fan1: 6144 RPM
temp1: +36.0 C
power2: 66.00 W
curr2: +5.50 A

coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +50.0 C (high = +82.0 C, crit = +104.0 C)
Core 0: +50.0 C (high = +82.0 C, crit = +104.0 C)
Core 1: +50.0 C (high = +82.0 C, crit = +104.0 C)
Core 2: +50.0 C (high = +82.0 C, crit = +104.0 C)
Core 3: +50.0 C (high = +82.0 C, crit = +104.0 C)

Signed-off-by: Jostar Yang <jostar_yang@accton.com.tw>
This commit is contained in:
jostar-yang 2022-04-02 00:55:04 +08:00 committed by GitHub
parent ddc269ac81
commit b39b7a3f2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 3467 additions and 51 deletions

View File

@ -0,0 +1,66 @@
{
"XCVR":
{
"xcvr_present":
{
"i2c":
{
"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":"EXHAUST", "0":"INTAKE"}
}
},
"present":
{
"i2c":
{
"valmap": {"1":true, "0":false}
}
},
"duty_cycle_to_pwm": "lambda dc: ((dc*100.0)/625)",
"pwm_to_duty_cycle": "lambda pwm: ((pwm*625.0)/100)"
}
}

View File

@ -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*100)/625 -1)",
"pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625+75)/100)"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -48,7 +48,7 @@
"duty_cycle_to_pwm": "lambda dc: ((dc*100.0)/625 - 1)",
"pwm_to_duty_cycle": "lambda pwm: math.ceil(((pwm+1)*625.0)/100)"
"pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625.0)/100)"
}
}

View File

@ -0,0 +1,64 @@
{
"XCVR":
{
"xcvr_present":
{
"i2c":
{
"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 - 10) / 6)",
"pwm_to_duty_cycle": "lambda pwm: ( (pwm * 6) + 10)"
}
}

View File

@ -114,7 +114,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x0", "dev_addr":"0x77", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x1"},
"dev_attr": { "virt_bus":"0x1", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"MUX2" },
@ -137,7 +137,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x1", "dev_addr":"0x71", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x9"},
"dev_attr": { "virt_bus":"0x9", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PSU2"},
@ -249,7 +249,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x1", "dev_addr":"0x76", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x11"},
"dev_attr": { "virt_bus":"0x11", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"TEMP1" },
@ -464,7 +464,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x1", "dev_addr":"0x73", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x19"},
"dev_attr": { "virt_bus":"0x19", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PORT61" },
@ -484,7 +484,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x2", "dev_addr":"0x70", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x21"},
"dev_attr": { "virt_bus":"0x21", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PORT9" },
@ -504,7 +504,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x2", "dev_addr":"0x71", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x29"},
"dev_attr": { "virt_bus":"0x29", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PORT6" },
@ -524,7 +524,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x2", "dev_addr":"0x72", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x31"},
"dev_attr": { "virt_bus":"0x31", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PORT17" },
@ -544,7 +544,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x2", "dev_addr":"0x73", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x39"},
"dev_attr": { "virt_bus":"0x39", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PORT29" },
@ -564,7 +564,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x2", "dev_addr":"0x74", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x41"},
"dev_attr": { "virt_bus":"0x41", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PORT41" },
@ -584,7 +584,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x2", "dev_addr":"0x75", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x49"},
"dev_attr": { "virt_bus":"0x49", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PORT45" },
@ -604,7 +604,7 @@
"i2c":
{
"topo_info": { "parent_bus":"0x2", "dev_addr":"0x76", "dev_type":"pca9548"},
"dev_attr": { "virt_bus":"0x51"},
"dev_attr": { "virt_bus":"0x51", "idle_state":"-2"},
"channel":
[
{ "chn":"0", "dev":"PORT57" },

View File

@ -0,0 +1 @@
../../../../pddf/i2c/service/pddf-platform-init.service

View File

@ -1,23 +1,14 @@
from setuptools import setup
DEVICE_NAME = 'accton'
HW_SKU = 'x86_64-accton_as4630_54pe-r0'
setup(
name='sonic-platform',
version='1.0',
description='SONiC platform API implementation on Accton Platforms',
description='SONiC platform API implementation on Accton Platforms using PDDF',
license='Apache 2.0',
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
url='https://github.com/Azure/sonic-buildimage',
maintainer='Jostar Yang',
maintainer_email='jostar_yang@edge-core.com',
packages=[
'sonic_platform',
],
package_dir={
'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)},
packages=['sonic_platform'],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Plugins',

View File

@ -1,7 +1,12 @@
ifneq ($(KERNELRELEASE),)
obj-m:= accton_i2c_cpld.o \
accton_as7326_56x_fan.o accton_as7326_56x_leds.o \
accton_as7326_56x_psu.o ym2651y.o
accton_as7326_56x_psu.o ym2651y.o \
pddf_custom_psu.o
CFLAGS_pddf_custom_psu.o := -I$(M)/../../../../pddf/i2c/modules/include
KBUILD_EXTRA_SYMBOLS := $(M)/../../../../pddf/i2c/Module.symvers.PDDF
else
ifeq (,$(KERNEL_SRC))

View File

@ -0,0 +1,206 @@
#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_psu_defs.h"
ssize_t pddf_get_custom_psu_model_name(struct device *dev, struct device_attribute *da, char *buf);
ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf);
extern PSU_SYSFS_ATTR_DATA access_psu_model_name;
extern PSU_SYSFS_ATTR_DATA access_psu_serial_num;
#define MAX_MODEL_NAME 16
#define MAX_SERIAL_NUMBER 19
enum psu_type {
PSU_TYPE_AC_110V,
PSU_TYPE_DC_48V,
PSU_TYPE_DC_12V,
PSU_TYPE_AC_ACBEL_FSF019,
PSU_TYPE_AC_ACBEL_FSF045
};
struct model_name_info {
enum psu_type type;
u8 offset;
u8 length;
u8 chk_length;
char* model_name;
};
struct serial_number_info {
enum psu_type type;
u8 offset;
u8 length;
u8 chk_length;
char* serial_number;
};
struct model_name_info models[] = {
{PSU_TYPE_AC_110V, 0x20, 8, 8, "YM-2651Y"},
{PSU_TYPE_DC_48V, 0x20, 8, 8, "YM-2651V"},
{PSU_TYPE_DC_12V, 0x00, 11, 11, "PSU-12V-750"},
{PSU_TYPE_AC_ACBEL_FSF019, 0x15, 10, 7, "FSF019-"},
{PSU_TYPE_AC_ACBEL_FSF045, 0x15, 10, 7, "FSF045-"}
};
struct serial_number_info serials[] = {
{PSU_TYPE_AC_110V, 0x2e, 18, 18, "YM-2651Y"},
{PSU_TYPE_DC_48V, 0x2e, 18, 18, "YM-2651V"},
{PSU_TYPE_DC_12V, 0x2e, 18, 18, "PSU-12V-750"},
{PSU_TYPE_AC_ACBEL_FSF019, 0x2e, 16, 16, "FSF019-"},
{PSU_TYPE_AC_ACBEL_FSF019, 0x2e, 16, 16, "FSF045-"}
};
struct pddf_psu_data {
char model_name[MAX_MODEL_NAME+1];
char serial_number[MAX_SERIAL_NUMBER+1];
};
static int pddf_psu_read_block(struct i2c_client *client, u8 command, u8 *data,
int data_len)
{
int result = 0;
int retry_count = 10;
while (retry_count) {
retry_count--;
result = i2c_smbus_read_i2c_block_data(client, command, data_len, data);
if (unlikely(result < 0)) {
msleep(10);
continue;
}
if (unlikely(result != data_len)) {
result = -EIO;
msleep(10);
continue;
}
result = 0;
break;
}
return result;
}
ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct pddf_psu_data data;
int i, status;
for (i = 0; i < ARRAY_SIZE(models); i++) {
memset(data.serial_number, 0, sizeof(data.serial_number));
status = pddf_psu_read_block(client, models[i].offset,
data.model_name, models[i].length);
if (status < 0) {
data.model_name[0] = '\0';
dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x%x)\n",
client->addr, models[i].offset);
return status;
}
else {
data.model_name[models[i].length] = '\0';
}
/* Determine if the model name is known, if not, read next index
*/
if (strncmp(data.model_name, models[i].model_name, models[i].chk_length) == 0) {
status = pddf_psu_read_block(client, serials[i].offset,
data.serial_number, serials[i].length);
if (status < 0) {
data.serial_number[0] = '\0';
dev_dbg(&client->dev, "unable to read serial num from (0x%x) offset(0x%x)\n",
client->addr, serials[i].offset);
return status;
}
else {
data.serial_number[serials[i].length] = '\0';
return sprintf(buf, "%s\n", data.serial_number);
}
return 0;
}
else {
data.serial_number[0] = '\0';
}
}
return -ENODATA;
}
ssize_t pddf_get_custom_psu_model_name(struct device *dev, struct device_attribute *da, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct pddf_psu_data data;
int i, status;
for (i = 0; i < ARRAY_SIZE(models); i++) {
memset(data.model_name, 0, sizeof(data.model_name));
status = pddf_psu_read_block(client, models[i].offset,
data.model_name, models[i].length);
if (status < 0) {
data.model_name[0] = '\0';
dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x%x)\n",
client->addr, models[i].offset);
return status;
}
else {
data.model_name[models[i].length] = '\0';
}
/* Determine if the model name is known, if not, read next index
*/
if (strncmp(data.model_name, models[i].model_name, models[i].chk_length) == 0) {
return sprintf(buf, "%s\n", data.model_name);
}
else {
data.model_name[0] = '\0';
}
}
return -ENODATA;
}
static int __init pddf_custom_psu_init(void)
{
access_psu_serial_num.show = pddf_get_custom_psu_serial_num;
access_psu_serial_num.do_get = NULL;
access_psu_model_name.show = pddf_get_custom_psu_model_name;
access_psu_model_name.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);

View File

@ -0,0 +1,16 @@
[Unit]
Description=Accton AS7326-56X Platform Monitoring service
Before=pmon.service
After=pddf-platform-init.service
DefaultDependencies=no
[Service]
ExecStart=/usr/local/bin/accton_as7326_pddf_monitor.py
KillSignal=SIGKILL
SuccessExitStatus=SIGKILL
# Resource Limitations
LimitCORE=infinity
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1 @@
../../../../pddf/i2c/service/pddf-platform-init.service

View File

@ -1,8 +1,5 @@
from setuptools import setup
DEVICE_NAME = 'accton'
HW_SKU = 'x86_64-accton_as7326_56x-r0'
setup(
name='sonic-platform',
version='1.0',
@ -11,11 +8,7 @@ setup(
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
url='https://github.com/Azure/sonic-buildimage',
packages=[
'sonic_platform'
],
package_dir={
'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)},
packages=['sonic_platform'],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Plugins',

View File

@ -0,0 +1,23 @@
#!/bin/bash
dis_i2c_ir3570a()
{
local addr=$1
i2cset -y -a 0 $addr 0xE5 0x01 &>/dev/null
i2cset -y -a 0 $addr 0x12 0x02 &>/dev/null
}
ir3570_check()
{
dump=`i2cdump -y 0 0x42 s 0x9a |awk 'END {print $2}'`
if [ $dump -eq 24 ]; then
echo "Disabling i2c function of ir3570a"
dis_i2c_ir3570a 0x4
fi
}
ir3570_check
echo "AS7326 post PDDF driver install completed"

View File

@ -4,8 +4,8 @@ dis_i2c_ir3570a()
{
local addr=$1
i2cset -y 0 $addr 0xE5 0x01 &>/dev/null
i2cset -y 0 $addr 0x12 0x02 &>/dev/null
i2cset -y -a 0 $addr 0xE5 0x01 &>/dev/null
i2cset -y -a 0 $addr 0x12 0x02 &>/dev/null
}

View File

@ -0,0 +1,16 @@
[Unit]
Description=Accton AS7816-64X Platform Monitoring service
Before=pmon.service
After=pddf-platform-init.service
DefaultDependencies=no
[Service]
ExecStart=/usr/local/bin/accton_as7816_pddf_monitor.py
KillSignal=SIGKILL
SuccessExitStatus=SIGKILL
# Resource Limitations
LimitCORE=infinity
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1 @@
../../../../pddf/i2c/service/pddf-platform-init.service

View File

@ -1,8 +1,5 @@
from setuptools import setup
DEVICE_NAME = 'accton'
HW_SKU = 'x86_64-accton_as7816_64x-r0'
setup(
name='sonic-platform',
version='1.0',
@ -11,13 +8,7 @@ setup(
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
url='https://github.com/Azure/sonic-buildimage',
maintainer='Jostar Yang',
maintainer_email='jostar_yang@edge-core.com',
packages=[
'sonic_platform',
],
package_dir={
'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)},
packages=['sonic_platform'],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Plugins',

View File

@ -0,0 +1,23 @@
#!/bin/bash
dis_i2c_ir3570a()
{
local addr=$1
i2cset -y -a 0 $addr 0xE5 0x01 &>/dev/null
i2cset -y -a 0 $addr 0x12 0x02 &>/dev/null
}
ir3570_check()
{
dump=`i2cdump -y 0 0x42 s 0x9a |awk 'END {print $2}'`
if [ $dump -eq 24 ]; then
echo "Disabling i2c function of ir3570a"
dis_i2c_ir3570a 0x4
fi
}
ir3570_check
echo "AS7816 post PDDF driver install completed"

View File

@ -4,8 +4,8 @@ dis_i2c_ir3570a()
{
local addr=$1
i2cset -y 0 $addr 0xE5 0x01 &>/dev/null
i2cset -y 0 $addr 0x12 0x02 &>/dev/null
i2cset -y -a 0 $addr 0xE5 0x01 &>/dev/null
i2cset -y -a 0 $addr 0x12 0x02 &>/dev/null
}

View File

@ -1 +1 @@
as4630-54pe/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as4630_54pe-r0
as4630-54pe/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as4630_54pe-r0/pddf

View File

@ -0,0 +1,8 @@
# Special arrangement to make PDDF mode default
# Disable monitor, monitor-fan, monitor-psu (not enabling them would imply they will be disabled by default)
# Enable pddf-platform-monitor
depmod -a
systemctl enable pddf-platform-init.service
systemctl start pddf-platform-init.service
systemctl enable as4630-54pe-pddf-platform-monitor.service
systemctl start as4630-54pe-pddf-platform-monitor.service

View File

@ -1,2 +1 @@
as7326-56x/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as7326_56x-r0
as7326-56x/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as7326_56x-r0/pddf

View File

@ -2,6 +2,8 @@
# Disable monitor, monitor-fan, monitor-psu (not enabling them would imply they will be disabled by default)
# Enable pddf-platform-monitor
depmod -a
systemctl enable as7726-32x-platform-handle_mac.service
systemctl start as7726-32x-platform-handle_mac.service
systemctl enable pddf-platform-init.service
systemctl start pddf-platform-init.service
systemctl enable as7726-32x-pddf-platform-monitor.service

View File

@ -1,2 +1 @@
as7816-64x/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as7816_64x-r0
as7816-64x/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as7816_64x-r0/pddf