phy: adin: fix broken support for adi,phy-mode-override
Subsystems (3)
PATCH 1/1 phy: adin: fix broken support for adi,phy-mode-override
Currently, the adin driver fails to compile.
The original patch introducing the adin driver used the function phy_get_interface_by_name to support the adi,phy-mode-override property. Unfortunately, a few days before the adin patch
was accepted, another patch removed support for phy_get_interface_by_name:
https://github.com/u-boot/u-boot/commit/123ca114e07ecf28aa2538748d733e2b22d8b8b5
This patch refactors adin_get_phy_mode_override, implementing the logic in the new function, ofnode_read_phy_mode, from the patch above.
--- drivers/net/phy/adin.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/net/phy/adin.c +11 -11
@@ -100,27 +100,27 @@ static u32 adin_get_reg_value(struct phy_device *phydev,* The function gets phy-mode string from property 'adi,phy-mode-override' * and return its index in phy_interface_strings table, or -1 in error case. */ -int adin_get_phy_mode_override (struct phy_device *phydev) +phy_interface_t adin_get_phy_mode_override (struct phy_device *phydev) {ofnode node =phy_get_ofnode (phydev);const char *phy_mode_override;const char *prop_phy_mode_override ="adi,phy-mode-override" ; -int override_interface; +int i; phy_mode_override =ofnode_read_string (node, prop_phy_mode_override);if (!phy_mode_override) -return -ENODEV ; +return PHY_INTERFACE_MODE_NA ;debug ("%s: %s = '%s'\n" , __func__, prop_phy_mode_override, phy_mode_override); - override_interface =phy_get_interface_by_name (phy_mode_override); +for (i =0 ; i <PHY_INTERFACE_MODE_MAX ; i++) +if (!strcmp (phy_mode_override, phy_interface_strings[i])) +return (phy_interface_t ) i; -if (override_interface <0 ) -printf ("%s: %s = '%s' is not valid\n" , - __func__, prop_phy_mode_override, phy_mode_override); +printf ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode_override); -return override_interface; +return PHY_INTERFACE_MODE_NA ; }static u16 adin_ext_read (struct phy_device *phydev,const u32 regnum)
@@ -148,10 +148,10 @@ static int adin_config_rgmii_mode(struct phy_device *phydev) {u16 reg_val;u32 val; -int phy_mode_override =adin_get_phy_mode_override (phydev); +phy_interface_t phy_mode_override =adin_get_phy_mode_override (phydev); -if (phy_mode_override >=0 ) { - phydev->interface = (phy_interface_t ) phy_mode_override; +if (phy_mode_override !=PHY_INTERFACE_MODE_NA ) { + phydev->interface = phy_mode_override; } reg_val =adin_ext_read (phydev,ADIN1300_GE_RGMII_CFG );
Signature · 1 line
2.25.1
Hi Nate,
That was quick! I have rebased my changes on top of this patch, and can confirm that the adin phy driver compiles, and still works.
I did not test setting adi,[rt]x-internal-delay-ps in dts though.
So, I guess you can add my superficial
[PATCH 0/5] mx6cuboxi: add eth support for SoMs revision 1.9+ patches 2-5 apply cleanly, so I won't immediately roll a v2.
Am 07.05.22 um 00:52 schrieb Nate Drude:
Quoted 61 lines
Currently, the adin driver fails to compile.
The original patch introducing the adin driver used the function
phy_get_interface_by_nameto support the adi,phy-mode-override property. Unfortunately, a few days before the adin patch
was accepted, another patch removed support forphy_get_interface_by_name:https://github.com/u-boot/u-boot/commit/123ca114e07ecf28aa2538748d733e2b22d8b8b5
This patch refactors
adin_get_phy_mode_override, implementing the logic in the new function,ofnode_read_phy_mode, from the patch above.Signed-off-by Nate Drude <[email protected]>--- drivers/net/phy/adin.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)drivers/net/phy/adin.c +8
-8@@ -100,27 +100,27 @@ static u32 adin_get_reg_value(struct phy_device *phydev,* The function gets phy-mode string from property 'adi,phy-mode-override' * and return its index in phy_interface_strings table, or -1 in error case. */ -int adin_get_phy_mode_override (struct phy_device *phydev) +phy_interface_t adin_get_phy_mode_override (struct phy_device *phydev) {ofnode node =phy_get_ofnode (phydev);const char *phy_mode_override;const char *prop_phy_mode_override ="adi,phy-mode-override" ; -int override_interface; +int i; phy_mode_override =ofnode_read_string (node, prop_phy_mode_override);if (!phy_mode_override) -return -ENODEV ; +return PHY_INTERFACE_MODE_NA ;debug ("%s: %s = '%s'\n" , __func__, prop_phy_mode_override, phy_mode_override); - override_interface =phy_get_interface_by_name (phy_mode_override); +for (i =0 ; i <PHY_INTERFACE_MODE_MAX ; i++) +if (!strcmp (phy_mode_override, phy_interface_strings[i])) +return (phy_interface_t ) i; -if (override_interface <0 ) -printf ("%s: %s = '%s' is not valid\n" , - __func__, prop_phy_mode_override, phy_mode_override); +printf ("%s: Invalid PHY interface '%s'\n" , __func__, phy_mode_override); -return override_interface; +return PHY_INTERFACE_MODE_NA ; }static u16 adin_ext_read (struct phy_device *phydev,const u32 regnum)@@ -148,10 +148,10 @@ static int adin_config_rgmii_mode(struct phy_device *phydev) {u16 reg_val;u32 val;
drivers/net/phy/adin.c static int adin_config_rgmii_mode(struct phy_device *phydev) · line 157
Quoted 10 lines
drivers/net/phy/adin.c +3
-3-int phy_mode_override =adin_get_phy_mode_override (phydev); +phy_interface_t phy_mode_override =adin_get_phy_mode_override (phydev); -if (phy_mode_override >=0 ) { - phydev->interface = (phy_interface_t ) phy_mode_override; +if (phy_mode_override !=PHY_INTERFACE_MODE_NA ) { + phydev->interface = phy_mode_override; } reg_val =adin_ext_read (phydev,ADIN1300_GE_RGMII_CFG );
- Josua Mayer