Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[as7946-74xkb] Add QSFP Transceiver LP mode #1007

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -80,6 +80,7 @@ static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
#define TRANSCEIVER_RESET_ATTR_ID(index) MODULE_RESET_##index
#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index
#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index
#define TRANSCEIVER_LPMODE_ATTR_ID(index) MODULE_LPMODE_##index

enum as7946_74xkb_cpld_sysfs_attributes {
/* transceiver attributes */
Expand Down Expand Up @@ -167,6 +168,16 @@ enum as7946_74xkb_cpld_sysfs_attributes {
TRANSCEIVER_RESET_ATTR_ID(8),
TRANSCEIVER_RESET_ATTR_ID(9),
TRANSCEIVER_RESET_ATTR_ID(10),
TRANSCEIVER_LPMODE_ATTR_ID(1),
TRANSCEIVER_LPMODE_ATTR_ID(2),
TRANSCEIVER_LPMODE_ATTR_ID(3),
TRANSCEIVER_LPMODE_ATTR_ID(4),
TRANSCEIVER_LPMODE_ATTR_ID(5),
TRANSCEIVER_LPMODE_ATTR_ID(6),
TRANSCEIVER_LPMODE_ATTR_ID(7),
TRANSCEIVER_LPMODE_ATTR_ID(8),
TRANSCEIVER_LPMODE_ATTR_ID(9),
TRANSCEIVER_LPMODE_ATTR_ID(10),
TRANSCEIVER_TXDISABLE_ATTR_ID(11),
TRANSCEIVER_TXDISABLE_ATTR_ID(12),
TRANSCEIVER_TXDISABLE_ATTR_ID(13),
Expand Down Expand Up @@ -308,20 +319,25 @@ enum as7946_74xkb_cpld_sysfs_attributes {
static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, \
NULL, MODULE_PRESENT_##index); \
static SENSOR_DEVICE_ATTR(module_reset_##index, S_IRUGO | S_IWUSR, \
show_status, set_control, MODULE_RESET_##index)
show_status, set_control, MODULE_RESET_##index); \
static SENSOR_DEVICE_ATTR(module_lpmode_##index, S_IRUGO | S_IWUSR, \
show_status, set_control, MODULE_LPMODE_##index);
#define DECLARE_QSFP28_TRANSCEIVER_ATTR(index) \
&sensor_dev_attr_module_present_##index.dev_attr.attr, \
&sensor_dev_attr_module_reset_##index.dev_attr.attr
&sensor_dev_attr_module_reset_##index.dev_attr.attr, \
&sensor_dev_attr_module_lpmode_##index.dev_attr.attr

#define DECLARE_QSFPDD_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \
static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, \
show_status, NULL, MODULE_PRESENT_##index); \
static SENSOR_DEVICE_ATTR(module_reset_##index, S_IRUGO | S_IWUSR, \
show_status, set_control, MODULE_RESET_##index)
show_status, set_control, MODULE_RESET_##index); \
static SENSOR_DEVICE_ATTR(module_lpmode_##index, S_IRUGO | S_IWUSR, \
show_status, set_control, MODULE_LPMODE_##index);
#define DECLARE_QSFPDD_TRANSCEIVER_ATTR(index) \
&sensor_dev_attr_module_present_##index.dev_attr.attr, \
&sensor_dev_attr_module_reset_##index.dev_attr.attr

&sensor_dev_attr_module_reset_##index.dev_attr.attr, \
&sensor_dev_attr_module_lpmode_##index.dev_attr.attr
/* sfp transceiver attributes */
#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \
static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, \
Expand Down Expand Up @@ -644,6 +660,15 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da,
reg = 0x9;
mask = 0x1 << (attr->index - MODULE_RESET_9);
break;
/* lpmode */
case MODULE_LPMODE_1 ... MODULE_LPMODE_8:
reg = 0xC;
mask = 0x1 << (attr->index - MODULE_LPMODE_1);
break;
case MODULE_LPMODE_9 ... MODULE_LPMODE_10:
reg = 0xD;
mask = 0x1 << (attr->index - MODULE_LPMODE_9);
break;
case MODULE_TXDISABLE_11 ... MODULE_TXDISABLE_18:
reg = 0xA;
mask = 0x1 << (attr->index - MODULE_TXDISABLE_11);
Expand Down Expand Up @@ -941,6 +966,14 @@ static ssize_t set_control(struct device *dev, struct device_attribute *da,
reg = 0x9;
mask = 0x1 << (attr->index - MODULE_RESET_9);
break;
case MODULE_LPMODE_1 ... MODULE_LPMODE_8:/*QSFP*/
reg = 0xC;
mask = 0x1 << (attr->index - MODULE_LPMODE_1);
break;
case MODULE_LPMODE_9 ... MODULE_LPMODE_10:/*QSFP*/
reg = 0xD;
mask = 0x1 << (attr->index - MODULE_LPMODE_9);
break;
default:
return -ENXIO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static const int port_bus_index[NUM_OF_SFP_PORT] = {
#define MODULE_RESET_MAIN_BOARD_CPLD1_FORMAT "/sys/bus/i2c/devices/12-0061/module_reset_%d"
#define MODULE_RESET_MAIN_BOARD_CPLD2_FORMAT "/sys/bus/i2c/devices/13-0062/module_reset_%d"
#define MODULE_RESET_MAIN_BOARD_CPLD3_FORMAT "/sys/bus/i2c/devices/16-0063/module_reset_%d"
#define MODULE_LPMODE_MAIN_BOARD_CPLD1_FORMAT "/sys/bus/i2c/devices/12-0061/module_lpmode_%d"
#define MODULE_PRESENT_MAIN_BOARD_CPLD1_FORMAT "/sys/bus/i2c/devices/12-0061/module_present_%d"
#define MODULE_PRESENT_MAIN_BOARD_CPLD2_FORMAT "/sys/bus/i2c/devices/13-0062/module_present_%d"
#define MODULE_PRESENT_MAIN_BOARD_CPLD3_FORMAT "/sys/bus/i2c/devices/16-0063/module_present_%d"
Expand All @@ -71,7 +72,6 @@ static const int port_bus_index[NUM_OF_SFP_PORT] = {
#define MODULE_TXDISABLE_MAIN_BOARD_CPLD2_FORMAT "/sys/bus/i2c/devices/13-0062/module_tx_disable_%d"
#define MODULE_TXDISABLE_MAIN_BOARD_CPLD3_FORMAT "/sys/bus/i2c/devices/16-0063/module_tx_disable_%d"


/************************************************************
*
* SFPI Entry Points
Expand Down Expand Up @@ -308,6 +308,23 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
}
break;
}
case ONLP_SFP_CONTROL_LP_MODE:
{
VALIDATE_QSFP(port);

switch (port) {
case 0 ... 9:
path = MODULE_LPMODE_MAIN_BOARD_CPLD1_FORMAT;
break;
default:
break;
}
if (onlp_file_write_int(value, path, (port+1)) < 0) {
AIM_LOG_ERROR("Unable to write LP mode status to port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
break;
}
default:
rv = ONLP_STATUS_E_UNSUPPORTED;
break;
Expand Down Expand Up @@ -393,6 +410,24 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
}
break;
}
case ONLP_SFP_CONTROL_LP_MODE:
{
VALIDATE_QSFP(port);

switch (port) {
case 0 ... 9:
path = MODULE_LPMODE_MAIN_BOARD_CPLD1_FORMAT;
break;
default:
break;
}

if (onlp_file_read_int(value, path, (port+1)) < 0) {
AIM_LOG_ERROR("Unable to read LP mode status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
break;
}
default:
rv = ONLP_STATUS_E_UNSUPPORTED;
break;
Expand Down