Skip to content

Commit f42c033

Browse files
Ansuelfrank-w
authored andcommitted
net: phy: as21xxx: implement read workaround for C45 read
This PHY have lots of problems with MDIO read operation. We somehow workaround this with using C45 operation for pretty much everything but this is not enough. The reference code for this PHY makes a write to an unused PHY to workaround this read problem. This was also confirmed by Aeonsemi. Various test were made to try to workaround this ins alternative way than the random write. One effective solution was to limit the write only to BMSR. And also write to BMSR is safe since they are only read only registers. This is only done for read operation as write operation doesn't suffer from this problem. Worth to mention that when multiple Aeonsemi PHY are mounted, the workaround doesn't work if we write to another Aeonsemi PHY. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1 parent 4291488 commit f42c033

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

drivers/net/phy/as21xxx.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,21 @@ static int as21xxx_config_inband(struct phy_device *phydev,
978978
return 0;
979979
}
980980

981+
static int as21xxx_read_mmd(struct phy_device *phydev, int devad,
982+
u16 regnum)
983+
{
984+
struct mii_bus *bus = phydev->mdio.bus;
985+
int val;
986+
987+
val = __mdiobus_c45_read(bus, phydev->mdio.addr, devad,
988+
regnum);
989+
990+
/* FIXME: verify if it's actually ok to limit this to MII_BMSR */
991+
__mdiobus_write(bus, 0x0, MII_BMSR, 0x1);
992+
993+
return val;
994+
}
995+
981996
static struct phy_driver as21xxx_drivers[] = {
982997
{
983998
/* PHY expose in C45 as 0x7500 0x9410
@@ -997,6 +1012,7 @@ static struct phy_driver as21xxx_drivers[] = {
9971012
.config_inband = as21xxx_config_inband,
9981013
.match_phy_device = as21xxx_match_phy_device,
9991014
.read_status = as21xxx_read_status,
1015+
.read_mmd = as21xxx_read_mmd,
10001016
.led_brightness_set = as21xxx_led_brightness_set,
10011017
.led_hw_is_supported = as21xxx_led_hw_is_supported,
10021018
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1012,6 +1028,7 @@ static struct phy_driver as21xxx_drivers[] = {
10121028
.config_inband = as21xxx_config_inband,
10131029
.match_phy_device = as21xxx_match_phy_device,
10141030
.read_status = as21xxx_read_status,
1031+
.read_mmd = as21xxx_read_mmd,
10151032
.led_brightness_set = as21xxx_led_brightness_set,
10161033
.led_hw_is_supported = as21xxx_led_hw_is_supported,
10171034
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1027,6 +1044,7 @@ static struct phy_driver as21xxx_drivers[] = {
10271044
.config_inband = as21xxx_config_inband,
10281045
.match_phy_device = as21xxx_match_phy_device,
10291046
.read_status = as21xxx_read_status,
1047+
.read_mmd = as21xxx_read_mmd,
10301048
.led_brightness_set = as21xxx_led_brightness_set,
10311049
.led_hw_is_supported = as21xxx_led_hw_is_supported,
10321050
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1042,6 +1060,7 @@ static struct phy_driver as21xxx_drivers[] = {
10421060
.config_inband = as21xxx_config_inband,
10431061
.match_phy_device = as21xxx_match_phy_device,
10441062
.read_status = as21xxx_read_status,
1063+
.read_mmd = as21xxx_read_mmd,
10451064
.led_brightness_set = as21xxx_led_brightness_set,
10461065
.led_hw_is_supported = as21xxx_led_hw_is_supported,
10471066
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1057,6 +1076,7 @@ static struct phy_driver as21xxx_drivers[] = {
10571076
.config_inband = as21xxx_config_inband,
10581077
.match_phy_device = as21xxx_match_phy_device,
10591078
.read_status = as21xxx_read_status,
1079+
.read_mmd = as21xxx_read_mmd,
10601080
.led_brightness_set = as21xxx_led_brightness_set,
10611081
.led_hw_is_supported = as21xxx_led_hw_is_supported,
10621082
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1072,6 +1092,7 @@ static struct phy_driver as21xxx_drivers[] = {
10721092
.config_inband = as21xxx_config_inband,
10731093
.match_phy_device = as21xxx_match_phy_device,
10741094
.read_status = as21xxx_read_status,
1095+
.read_mmd = as21xxx_read_mmd,
10751096
.led_brightness_set = as21xxx_led_brightness_set,
10761097
.led_hw_is_supported = as21xxx_led_hw_is_supported,
10771098
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1087,6 +1108,7 @@ static struct phy_driver as21xxx_drivers[] = {
10871108
.config_inband = as21xxx_config_inband,
10881109
.match_phy_device = as21xxx_match_phy_device,
10891110
.read_status = as21xxx_read_status,
1111+
.read_mmd = as21xxx_read_mmd,
10901112
.led_brightness_set = as21xxx_led_brightness_set,
10911113
.led_hw_is_supported = as21xxx_led_hw_is_supported,
10921114
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1102,6 +1124,7 @@ static struct phy_driver as21xxx_drivers[] = {
11021124
.config_inband = as21xxx_config_inband,
11031125
.match_phy_device = as21xxx_match_phy_device,
11041126
.read_status = as21xxx_read_status,
1127+
.read_mmd = as21xxx_read_mmd,
11051128
.led_brightness_set = as21xxx_led_brightness_set,
11061129
.led_hw_is_supported = as21xxx_led_hw_is_supported,
11071130
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1117,6 +1140,7 @@ static struct phy_driver as21xxx_drivers[] = {
11171140
.config_inband = as21xxx_config_inband,
11181141
.match_phy_device = as21xxx_match_phy_device,
11191142
.read_status = as21xxx_read_status,
1143+
.read_mmd = as21xxx_read_mmd,
11201144
.led_brightness_set = as21xxx_led_brightness_set,
11211145
.led_hw_is_supported = as21xxx_led_hw_is_supported,
11221146
.led_hw_control_set = as21xxx_led_hw_control_set,
@@ -1132,6 +1156,7 @@ static struct phy_driver as21xxx_drivers[] = {
11321156
.config_inband = as21xxx_config_inband,
11331157
.match_phy_device = as21xxx_match_phy_device,
11341158
.read_status = as21xxx_read_status,
1159+
.read_mmd = as21xxx_read_mmd,
11351160
.led_brightness_set = as21xxx_led_brightness_set,
11361161
.led_hw_is_supported = as21xxx_led_hw_is_supported,
11371162
.led_hw_control_set = as21xxx_led_hw_control_set,

0 commit comments

Comments
 (0)