Skip to content

Commit 2e1c5a0

Browse files
Ansuelfrank-w
authored andcommitted
net: phy: add PHY_DETACH_NO_HW_RESET PHY flag
Some PHY require a firmware to correctly work and such firmware might get reset when the GPIO reset is assert. This is the case for the Aeonsemi PHY where when the PHY is torn down, phy_detach() is called that assert the GPIO reset pin resetting the firmware. To handle this introduce a flag, PHY_DETACH_NO_HW_RESET that instruct phy_detach() to skip asserting the GPIO reset on detaching the PHY. The PHY is still reset in all other case where it's removed or the PHY fails to probe. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1 parent 9a00656 commit 2e1c5a0

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

drivers/net/phy/as21xxx.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ static struct phy_driver as21xxx_drivers[] = {
965965
.led_hw_control_set = as21xxx_led_hw_control_set,
966966
.led_hw_control_get = as21xxx_led_hw_control_get,
967967
.led_polarity_set = as21xxx_led_polarity_set,
968+
.flags = PHY_DETACH_NO_RESET,
968969
},
969970
{
970971
PHY_ID_MATCH_EXACT(PHY_ID_AS21011PB1),
@@ -977,6 +978,7 @@ static struct phy_driver as21xxx_drivers[] = {
977978
.led_hw_control_set = as21xxx_led_hw_control_set,
978979
.led_hw_control_get = as21xxx_led_hw_control_get,
979980
.led_polarity_set = as21xxx_led_polarity_set,
981+
.flags = PHY_DETACH_NO_RESET,
980982
},
981983
{
982984
PHY_ID_MATCH_EXACT(PHY_ID_AS21010PB1),
@@ -989,6 +991,7 @@ static struct phy_driver as21xxx_drivers[] = {
989991
.led_hw_control_set = as21xxx_led_hw_control_set,
990992
.led_hw_control_get = as21xxx_led_hw_control_get,
991993
.led_polarity_set = as21xxx_led_polarity_set,
994+
.flags = PHY_DETACH_NO_RESET,
992995
},
993996
{
994997
PHY_ID_MATCH_EXACT(PHY_ID_AS21010JB1),
@@ -1001,6 +1004,7 @@ static struct phy_driver as21xxx_drivers[] = {
10011004
.led_hw_control_set = as21xxx_led_hw_control_set,
10021005
.led_hw_control_get = as21xxx_led_hw_control_get,
10031006
.led_polarity_set = as21xxx_led_polarity_set,
1007+
.flags = PHY_DETACH_NO_RESET,
10041008
},
10051009
{
10061010
PHY_ID_MATCH_EXACT(PHY_ID_AS21210PB1),
@@ -1013,6 +1017,7 @@ static struct phy_driver as21xxx_drivers[] = {
10131017
.led_hw_control_set = as21xxx_led_hw_control_set,
10141018
.led_hw_control_get = as21xxx_led_hw_control_get,
10151019
.led_polarity_set = as21xxx_led_polarity_set,
1020+
.flags = PHY_DETACH_NO_RESET,
10161021
},
10171022
{
10181023
PHY_ID_MATCH_EXACT(PHY_ID_AS21510JB1),
@@ -1025,6 +1030,7 @@ static struct phy_driver as21xxx_drivers[] = {
10251030
.led_hw_control_set = as21xxx_led_hw_control_set,
10261031
.led_hw_control_get = as21xxx_led_hw_control_get,
10271032
.led_polarity_set = as21xxx_led_polarity_set,
1033+
.flags = PHY_DETACH_NO_RESET,
10281034
},
10291035
{
10301036
PHY_ID_MATCH_EXACT(PHY_ID_AS21510PB1),
@@ -1037,6 +1043,7 @@ static struct phy_driver as21xxx_drivers[] = {
10371043
.led_hw_control_set = as21xxx_led_hw_control_set,
10381044
.led_hw_control_get = as21xxx_led_hw_control_get,
10391045
.led_polarity_set = as21xxx_led_polarity_set,
1046+
.flags = PHY_DETACH_NO_RESET,
10401047
},
10411048
{
10421049
PHY_ID_MATCH_EXACT(PHY_ID_AS21511JB1),
@@ -1049,6 +1056,7 @@ static struct phy_driver as21xxx_drivers[] = {
10491056
.led_hw_control_set = as21xxx_led_hw_control_set,
10501057
.led_hw_control_get = as21xxx_led_hw_control_get,
10511058
.led_polarity_set = as21xxx_led_polarity_set,
1059+
.flags = PHY_DETACH_NO_RESET,
10521060
},
10531061
{
10541062
PHY_ID_MATCH_EXACT(PHY_ID_AS21210JB1),
@@ -1061,6 +1069,7 @@ static struct phy_driver as21xxx_drivers[] = {
10611069
.led_hw_control_set = as21xxx_led_hw_control_set,
10621070
.led_hw_control_get = as21xxx_led_hw_control_get,
10631071
.led_polarity_set = as21xxx_led_polarity_set,
1072+
.flags = PHY_DETACH_NO_RESET,
10641073
},
10651074
{
10661075
PHY_ID_MATCH_EXACT(PHY_ID_AS21511PB1),
@@ -1073,6 +1082,7 @@ static struct phy_driver as21xxx_drivers[] = {
10731082
.led_hw_control_set = as21xxx_led_hw_control_set,
10741083
.led_hw_control_get = as21xxx_led_hw_control_get,
10751084
.led_polarity_set = as21xxx_led_polarity_set,
1085+
.flags = PHY_DETACH_NO_RESET,
10761086
},
10771087
};
10781088
module_phy_driver(as21xxx_drivers);

drivers/net/phy/phy_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,8 @@ void phy_detach(struct phy_device *phydev)
18841884
}
18851885

18861886
/* Assert the reset signal */
1887-
phy_device_reset(phydev, 1);
1887+
if (!(phydev->drv->flags & PHY_DETACH_NO_HW_RESET))
1888+
phy_device_reset(phydev, 1);
18881889

18891890
/*
18901891
* The phydev might go away on the put_device() below, so avoid

include/linux/phy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extern const int phy_basic_ports_array[3];
6464
#define PHY_RST_AFTER_CLK_EN 0x00000002
6565
#define PHY_POLL_CABLE_TEST 0x00000004
6666
#define PHY_ALWAYS_CALL_SUSPEND 0x00000008
67+
#define PHY_DETACH_NO_HW_RESET 0x00000010
6768
#define MDIO_DEVICE_IS_PHY 0x80000000
6869

6970
/**

0 commit comments

Comments
 (0)