ethernet: fix wol_error when test eye_pattern

PD#166642: add eye pattern function for 4.9

Change-Id: If57f74262589c02e12cbff3f01745c70a687da9e
Signed-off-by: Zhuo Wang <zhuo.wang@amlogic.com>
This commit is contained in:
Zhuo Wang
2018-05-18 17:56:11 +08:00
committed by Yixun Lan
parent e9b555745a
commit 83fd37b084
3 changed files with 37 additions and 15 deletions

View File

@@ -126,6 +126,7 @@ void reset_internal_phy(struct phy_device *phydev)
pr_info("reset phy\n");
}
unsigned int enable_wol_check = 1;
static int internal_phy_read_status(struct phy_device *phydev)
{
int err;
@@ -142,22 +143,28 @@ static int internal_phy_read_status(struct phy_device *phydev)
/*Bit 9:5: Read Address*/
/*Bit 4:0: Write Address*/
/*read wol bank reg12*/
val = ((1 << 15) | (1 << 11) | (1 << 10) | (12 << 5));
phy_write(phydev, 0x14, val);
wol_reg12 = phy_read(phydev, 0x15);
if ((phydev->link) && (phydev->speed != SPEED_10)) {
if ((wol_reg12 & 0x1000))
/*add enable/disable to stop the check for debug*/
/*cause this part will involve many issue*/
if (enable_wol_check) {
val = ((1 << 15) | (1 << 11) | (1 << 10) | (12 << 5));
phy_write(phydev, 0x14, val);
wol_reg12 = phy_read(phydev, 0x15);
if ((phydev->link) && (phydev->speed != SPEED_10)) {
if ((wol_reg12 & 0x1000))
reg12_error_count = 0;
if (!(wol_reg12 & 0x1000)) {
reg12_error_count++;
pr_info("wol_reg12[12]==0, error\n");
}
if (reg12_error_count >=
(phydev->drv->features & 0xff)) {
reg12_error_count = 0;
reset_internal_phy(phydev);
}
} else {
reg12_error_count = 0;
if (!(wol_reg12 & 0x1000)) {
reg12_error_count++;
pr_info("wol_reg12[12]==0, error\n");
}
if (reg12_error_count >= (phydev->drv->features & 0xff)) {
reg12_error_count = 0;
reset_internal_phy(phydev);
}
} else {
reg12_error_count = 0;
}
linkup = phydev->link;
err = genphy_update_link(phydev);

View File

@@ -553,6 +553,8 @@ static void am_net_eye_pattern_on(void)
unsigned int value;
c_phy_dev->autoneg = AUTONEG_DISABLE;
/*stop check wol when doing eye pattern, otherwise it will reset phy*/
enable_wol_check = 0;
phy_write(c_phy_dev, 0, 0x2100);
value = phy_read(c_phy_dev, 17);
pr_info("0x11 %x\n", value);
@@ -563,12 +565,20 @@ static void am_net_eye_pattern_off(void)
unsigned int value;
c_phy_dev->autoneg = AUTONEG_ENABLE;
enable_wol_check = 1;
phy_write(c_phy_dev, 0, 0x1000);
value = phy_read(c_phy_dev, 17);
pr_info("0x11 %x\n", value);
phy_write(c_phy_dev, 17, (value & ~0x0004));
}
static void am_net_debug_mode(void)
{ /*disable autoneg*/
c_phy_dev->autoneg = AUTONEG_DISABLE;
/*disable wol check*/
enable_wol_check = 0;
}
static ssize_t eth_phyreg_func(
struct class *class, struct class_attribute *attr,
const char *buf, size_t count)
@@ -642,6 +652,10 @@ static ssize_t eth_phyreg_func(
am_net_eye_pattern_off();
break;
}
if (argv[0][1] == 'd' || argv[0][1] == 'D') {
am_net_debug_mode();
break;
}
break;
default:
goto end;

View File

@@ -36,7 +36,8 @@
#include <linux/net_tstamp.h>
#include "eth_reg.h"
/*add this to stop checking wol,which will reset phy*/
extern unsigned int enable_wol_check;
int gmac_create_sysfs(struct phy_device *phydev, void __iomem *ioaddr);
int gmac_remove_sysfs(struct phy_device *phydev);
#endif