The optoe change for the AS4610 has been been temporarily reverted to unblock to transition to the 4.14 kernel.

Revert "[as4610] Add support for OOM optoe driver"
This reverts commit c1b7904d34.
This commit is contained in:
Jeffrey Townsend
2018-12-24 15:44:23 +00:00
parent 1e9fbe9932
commit f1e7d728fe
6 changed files with 2020 additions and 2026 deletions

View File

@@ -868,7 +868,7 @@ CONFIG_EEPROM_AT25=y
# CONFIG_EEPROM_93CX6 is not set
# CONFIG_EEPROM_93XX46 is not set
# CONFIG_EEPROM_SFF_8436 is not set
CONFIG_EEPROM_OPTOE=y
CONFIG_EEPROM_ACCTON_AS4610_SFP=y
# CONFIG_CB710_CORE is not set
# CONFIG_IWMC3200TOP is not set
@@ -1497,7 +1497,7 @@ CONFIG_SENSORS_W83781D=y
# CONFIG_SENSORS_W83L786NG is not set
# CONFIG_SENSORS_W83627HF is not set
# CONFIG_SENSORS_W83627EHF is not set
CONFIG_SENSORS_ACCTON_AS4610_CPLD=y
CONFIG_SENSORS_ACCTON_I2C_CPLD=y
CONFIG_SENSORS_ACCTON_AS4610_FAN=y
CONFIG_SENSORS_ACCTON_AS4610_PSU=y
CONFIG_SENSORS_YM2651Y=y

View File

@@ -1,6 +1,6 @@
--- /dev/null
+++ b/arch/arm/boot/dts/accton_as4610_54.dts
@@ -0,0 +1,256 @@
@@ -0,0 +1,250 @@
+/*
+ * Accton AS4610 54 Device Tree Source
+ *
@@ -117,7 +117,7 @@
+ cpld@1,0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "accton,as4610_54_cpld";
+ compatible = "accton,as4610-54-cpld";
+ label = "cpld";
+ reg = <0x30>;
+ };
@@ -142,8 +142,8 @@
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0>;
+ optoe@50 {
+ compatible = "optoe2";
+ sfp_eeprom@50 {
+ compatible = "at,24c04";
+ reg = <0x50>;
+ label = "port49";
+ };
@@ -154,8 +154,8 @@
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <1>;
+ optoe@50 {
+ compatible = "optoe2";
+ sfp_eeprom@50 {
+ compatible = "at,24c04";
+ reg = <0x50>;
+ label = "port50";
+ };
@@ -166,8 +166,8 @@
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <2>;
+ optoe@50 {
+ compatible = "optoe2";
+ sfp_eeprom@50 {
+ compatible = "at,24c04";
+ reg = <0x50>;
+ label = "port51";
+ };
@@ -178,8 +178,8 @@
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <3>;
+ optoe@50 {
+ compatible = "optoe2";
+ sfp_eeprom@50 {
+ compatible = "at,24c04";
+ reg = <0x50>;
+ label = "port52";
+ };
@@ -190,10 +190,9 @@
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <4>;
+ optoe@50 {
+ compatible = "optoe1";
+ sfp_eeprom@50 {
+ compatible = "at,24c04";
+ reg = <0x50>;
+ label = "port53";
+ };
+ };
+
@@ -202,10 +201,9 @@
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <5>;
+ optoe@50 {
+ compatible = "optoe1";
+ sfp_eeprom@50 {
+ compatible = "at,24c04";
+ reg = <0x50>;
+ label = "port54";
+ };
+ };
+
@@ -214,21 +212,17 @@
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <6>;
+ psu1_eeprom@50 {
+ compatible = "accton,as4610_psu1";
+ psu_eeprom@50 {
+ compatible = "at,24c02";
+ reg = <0x50>;
+ label = "psu1_eeprom";
+ read-only;
+ };
+ psu1_pmbus@58 {
+ compatible = "3y-power,ym1921";
+ reg = <0x58>;
+ };
+ psu2_eeprom@51 {
+ compatible = "accton,as4610_psu2";
+ psu_eeprom@51 {
+ compatible = "at,24c02";
+ reg = <0x51>;
+ };
+ psu2_pmbus@59 {
+ compatible = "3y-power,ym1921";
+ reg = <0x59>;
+ label = "psu2_eeprom";
+ read-only;
+ };
+ };
+

View File

@@ -139,8 +139,8 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <0>;
optoe@50 {
compatible = "optoe2";
sfp_eeprom@50 {
compatible = "at,as4610_sfp1";
reg = <0x50>;
label = "port49";
};
@@ -151,8 +151,8 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <1>;
optoe@50 {
compatible = "optoe2";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp2";
reg = <0x50>;
label = "port50";
};
@@ -163,8 +163,8 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <2>;
optoe@50 {
compatible = "optoe2";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp3";
reg = <0x50>;
label = "port51";
};
@@ -175,8 +175,8 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <3>;
optoe@50 {
compatible = "optoe2";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp4";
reg = <0x50>;
label = "port52";
};
@@ -187,10 +187,9 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <4>;
optoe@50 {
compatible = "optoe1";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp5";
reg = <0x50>;
label = "port53";
};
};
@@ -199,10 +198,9 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <5>;
optoe@50 {
compatible = "optoe1";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp6";
reg = <0x50>;
label = "port54";
};
};

View File

@@ -139,8 +139,8 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <0>;
optoe@50 {
compatible = "optoe2";
sfp_eeprom@50 {
compatible = "at,as4610_sfp1";
reg = <0x50>;
label = "port49";
};
@@ -151,8 +151,8 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <1>;
optoe@50 {
compatible = "optoe2";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp2";
reg = <0x50>;
label = "port50";
};
@@ -163,8 +163,8 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <2>;
optoe@50 {
compatible = "optoe2";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp3";
reg = <0x50>;
label = "port51";
};
@@ -175,8 +175,8 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <3>;
optoe@50 {
compatible = "optoe2";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp4";
reg = <0x50>;
label = "port52";
};
@@ -187,10 +187,9 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <4>;
optoe@50 {
compatible = "optoe1";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp5";
reg = <0x50>;
label = "port53";
};
};
@@ -199,10 +198,9 @@
#address-cells = <1>;
#size-cells = <0>;
reg = <5>;
optoe@50 {
compatible = "optoe1";
sfp_eeprom@50 {
compatible = "accton,as4610_sfp6";
reg = <0x50>;
label = "port54";
};
};

View File

@@ -24,31 +24,50 @@
*
***********************************************************/
#include <onlp/platformi/sfpi.h>
#include <onlplib/file.h>
#include "platform_lib.h"
#include <arm_accton_as4610/arm_accton_as4610_config.h>
#include "arm_accton_as4610_log.h"
#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom"
#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/0-0030/module_present_%d"
#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/0-0030/module_rx_los_%d"
#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/0-0030/module_tx_fault_%d"
#define MODULE_PRESENT_ALL_ATTR_CPLD "/sys/bus/i2c/devices/0-0030/module_present_all"
#define MODULE_RXLOS_ALL_ATTR_CPLD "/sys/bus/i2c/devices/0-0030/module_rx_los_all"
#define MAX_SFP_PATH 64
static char sfp_node_path[MAX_SFP_PATH] = {0};
#define FRONT_PORT_MUX_INDEX(port) (port-46)
static int front_port_bus_index(int port)
static int
sfp_node_read_int(char *node_path, int *value, int data_len)
{
return (platform_id == PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0) ?
(port - 22) : /* PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0 */
(port - 46) ; /* PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0 */
int ret = 0;
char buf[8];
*value = 0;
ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len);
if (ret == 0) {
*value = atoi(buf);
}
return ret;
}
static int front_port_to_cpld_port(int port)
static char*
sfp_get_port_path_addr(int port, int addr, char *node_name)
{
return (platform_id == PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0) ?
(port - 23) : /* PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0 */
(port - 47) ; /* PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0 */
int front_port_mux_id;
if(platform_id == PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0)
front_port_mux_id = port - 22;
else /*PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0*/
front_port_mux_id = port - 46;
sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s",
front_port_mux_id, addr, node_name);
return sfp_node_path;
}
static char*
sfp_get_port_path(int port, char *node_name)
{
return sfp_get_port_path_addr(port, 50, node_name);
}
/************************************************************
@@ -96,9 +115,9 @@ onlp_sfpi_is_present(int port)
* Return < 0 if error.
*/
int present;
int cpld_port = front_port_to_cpld_port(port);
if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, cpld_port) < 0) {
char* path = sfp_get_port_path(port, "sfp_is_present");
if (sfp_node_read_int(path, &present, 0) != 0) {
AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
@@ -110,6 +129,7 @@ int
onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
{
uint32_t byte;
char* path;
FILE* fp;
int port;
@@ -120,18 +140,18 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
else /*PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0*/
port = 48;
/* Read present status of each port */
fp = fopen(MODULE_PRESENT_ALL_ATTR_CPLD, "r");
path = sfp_get_port_path(port, "sfp_is_present_all");
fp = fopen(path, "r");
if(fp == NULL) {
AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD.");
AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file.");
return ONLP_STATUS_E_INTERNAL;
}
int count = fscanf(fp, "%x", &byte);
fclose(fp);
if(count != 1) {
/* Likely a CPLD read timeout. */
AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD.");
AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file.");
return ONLP_STATUS_E_INTERNAL;
}
@@ -153,6 +173,7 @@ int
onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
{
uint32_t byte;
char* path;
FILE* fp;
int port;
@@ -161,18 +182,16 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
else /*PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0*/
port = 48;
/* Read present status of each port */
fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD, "r");
path = sfp_get_port_path(port, "sfp_rx_los_all");
fp = fopen(path, "r");
if(fp == NULL) {
AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD.");
AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file.");
return ONLP_STATUS_E_INTERNAL;
}
int count = fscanf(fp, "%x", &byte);
fclose(fp);
if(count != 1) {
/* Likely a CPLD read timeout. */
AIM_LOG_ERROR("Unable to read all fields the module_rx_los_all device file of CPLD.");
AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file.");
return ONLP_STATUS_E_INTERNAL;
}
@@ -193,51 +212,32 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
int
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
{
char* path = sfp_get_port_path(port, "sfp_eeprom");
/*
* Read the SFP eeprom into data[]
*
* Return MISSING if SFP is missing.
* Return OK if eeprom is read
*/
int size = 0;
memset(data, 0, 256);
if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, front_port_bus_index(port)) != ONLP_STATUS_OK) {
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
if (size != 256) {
AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_dom_read(int port, uint8_t data[256])
{
FILE* fp;
char file[64] = {0};
sprintf(file, PORT_EEPROM_FORMAT, front_port_bus_index(port));
fp = fopen(file, "r");
if(fp == NULL) {
AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port);
return ONLP_STATUS_E_INTERNAL;
}
char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom");
memset(data, 0, 256);
if (fseek(fp, 256, SEEK_CUR) != 0) {
fclose(fp);
AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port);
return ONLP_STATUS_E_INTERNAL;
}
int ret = fread(data, 1, 256, fp);
fclose(fp);
if (ret != 256) {
AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port);
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
@@ -247,24 +247,45 @@ onlp_sfpi_dom_read(int port, uint8_t data[256])
int
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
return ONLP_STATUS_E_UNSUPPORTED;
int rv;
switch(control)
{
case ONLP_SFP_CONTROL_TX_DISABLE:
{
char* path = sfp_get_port_path(port, "sfp_tx_disable");
if (deviceNodeWriteInt(path, value, 0) != 0) {
AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else {
rv = ONLP_STATUS_OK;
}
break;
}
default:
rv = ONLP_STATUS_E_UNSUPPORTED;
break;
}
return rv;
}
int
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
{
int rv;
int cpld_port = front_port_to_cpld_port(port);
if (cpld_port > 4) {
return ONLP_STATUS_E_UNSUPPORTED;
}
char* path = NULL;
switch(control)
{
case ONLP_SFP_CONTROL_RX_LOS:
{
if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, cpld_port) < 0) {
path = sfp_get_port_path(port, "sfp_rx_los");
if (sfp_node_read_int(path, value, 0) != 0) {
AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
@@ -276,7 +297,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
case ONLP_SFP_CONTROL_TX_FAULT:
{
if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, cpld_port) < 0) {
path = sfp_get_port_path(port, "sfp_tx_fault");
if (sfp_node_read_int(path, value, 0) != 0) {
AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
@@ -286,6 +309,20 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
break;
}
case ONLP_SFP_CONTROL_TX_DISABLE:
{
path = sfp_get_port_path(port, "sfp_tx_disable");
if (sfp_node_read_int(path, value, 0) != 0) {
AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else {
rv = ONLP_STATUS_OK;
}
break;
}
default:
rv = ONLP_STATUS_E_UNSUPPORTED;
}
@@ -293,9 +330,9 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
return rv;
}
int
onlp_sfpi_denit(void)
{
return ONLP_STATUS_OK;
}