net: phy: dp83867: add some fixes
Subsystems (3)
v2 cover net: phy: dp83867: add some fixes
v2: fix minor comments by Heiner Kallweit and Florian Fainelli.
Max Uvarov (4):
net: phy: dp83867: fix speed 10 in sgmii mode
net: phy: dp83867: increase SGMII autoneg timer duration
net: phy: dp83867: do not call config_init twice
net: phy: dp83867: Set up RGMII TX delay
drivers/net/phy/dp83867.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/4 net: phy: dp83867: fix speed 10 in sgmii mode
For support 10Mps sped in SGMII mode DP83867_10M_SGMII_RATE_ADAPT bit of DP83867_10M_SGMII_CFG register has to be cleared by software. That does not affect speeds 100 and 1000 so can be done on init.
--- drivers/net/phy/dp83867.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/net/phy/dp83867.c +20 -0
@@ -30,6 +30,7 @@#define DP83867_STRAP_STS1 0x006E#define DP83867_RGMIIDCTL 0x0086#define DP83867_IO_MUX_CFG 0x0170 +#define DP83867_10M_SGMII_CFG 0x016F#define DP83867_SW_RESET BIT(15)#define DP83867_SW_RESTART BIT(14)
@@ -74,6 +75,9 @@/* CFG4 bits */ #define DP83867_CFG4_PORT_MIRROR_EN BIT(0) +/* 10M_SGMII_CFG bits */ +#define DP83867_10M_SGMII_RATE_ADAPT BIT(7) +enum {DP83867_PORT_MIRROING_KEEP ,DP83867_PORT_MIRROING_EN ,
@@ -277,6 +281,22 @@ static int dp83867_config_init(struct phy_device *phydev) DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL); } +if (phydev->interface ==PHY_INTERFACE_MODE_SGMII ) { +/* For support SPEED_10 in SGMII mode +* DP83867_10M_SGMII_RATE_ADAPT bit +* has to be cleared by software. That +* does not affect SPEED_100 and +* SPEED_1000. +*/ + val =phy_read_mmd (phydev,DP83867_DEVADDR , +DP83867_10M_SGMII_CFG ); + val &= ~DP83867_10M_SGMII_RATE_ADAPT ; + ret =phy_write_mmd (phydev,DP83867_DEVADDR , +DP83867_10M_SGMII_CFG , val); +if (ret) +return ret; + } +/* Enable Interrupt output INT_OE in CFG3 register */ if (phy_interrupt_is_valid (phydev)) { val =phy_read (phydev,DP83867_CFG3 );
Signature · 1 line
2.17.1
Heiner Kallweit
maintainerRe: [PATCH v2 1/4] net: phy: dp83867: fix speed 10 in sgmii mode
Quoted 38 lines · Max Uvarov
For support 10Mps sped in SGMII mode
DP83867_10M_SGMII_RATE_ADAPTbit ofDP83867_10M_SGMII_CFGregister has to be cleared by software. That does not affect speeds 100 and 1000 so can be done on init.Signed-off-by Max Uvarov <[email protected]>Cc Heiner Kallweit <[email protected]>--- drivers/net/phy/dp83867.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/net/phy/dp83867.c +6
-0@@ -30,6 +30,7 @@#define DP83867_STRAP_STS1 0x006E#define DP83867_RGMIIDCTL 0x0086#define DP83867_IO_MUX_CFG 0x0170 +#define DP83867_10M_SGMII_CFG 0x016F#define DP83867_SW_RESET BIT(15)#define DP83867_SW_RESTART BIT(14)@@ -74,6 +75,9 @@/* CFG4 bits */ #define DP83867_CFG4_PORT_MIRROR_EN BIT(0) +/* 10M_SGMII_CFG bits */ +#define DP83867_10M_SGMII_RATE_ADAPT BIT(7) +enum {DP83867_PORT_MIRROING_KEEP ,DP83867_PORT_MIRROING_EN ,@@ -277,6 +281,22 @@ static int dp83867_config_init(struct phy_device *phydev) DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL); } +if (phydev->interface ==PHY_INTERFACE_MODE_SGMII ) { +/* For support SPEED_10 in SGMII mode
drivers/net/phy/dp83867.c static int dp83867_config_init(struct phy_device *phydev) · line 295
Quoted 10 lines
drivers/net/phy/dp83867.c +10
-0+* DP83867_10M_SGMII_RATE_ADAPT bit +* has to be cleared by software. That +* does not affect SPEED_100 and +* SPEED_1000. +*/ + val =phy_read_mmd (phydev,DP83867_DEVADDR , +DP83867_10M_SGMII_CFG ); + val &= ~DP83867_10M_SGMII_RATE_ADAPT ; + ret =phy_write_mmd (phydev,DP83867_DEVADDR , +DP83867_10M_SGMII_CFG , val);
I think I mentioned it before: This can be simplified by using phy_modify_mmd(). Same applies to patch 2.
Quoted 8 lines
drivers/net/phy/dp83867.c +4
-0+if (ret) +return ret; + } +/* Enable Interrupt output INT_OE in CFG3 register */ if (phy_interrupt_is_valid (phydev)) { val =phy_read (phydev,DP83867_CFG3 );
Re: [PATCH v2 1/4] net: phy: dp83867: fix speed 10 in sgmii mode
In reply to Max UvarovQuoted 3 lines · Max Uvarov
For support 10Mps sped in SGMII mode
DP83867_10M_SGMII_RATE_ADAPTbit ofDP83867_10M_SGMII_CFGregister has to be cleared by software. That does not affect speeds 100 and 1000 so can be done on init.
s/support/supporting/
s/sped/speed/
Quoted 30 lines
Signed-off-by Max Uvarov <[email protected]>Cc Heiner Kallweit <[email protected]>--- drivers/net/phy/dp83867.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)drivers/net/phy/dp83867.c +4
-0@@ -30,6 +30,7 @@#define DP83867_STRAP_STS1 0x006E#define DP83867_RGMIIDCTL 0x0086#define DP83867_IO_MUX_CFG 0x0170 +#define DP83867_10M_SGMII_CFG 0x016F#define DP83867_SW_RESET BIT(15)#define DP83867_SW_RESTART BIT(14)@@ -74,6 +75,9 @@/* CFG4 bits */ #define DP83867_CFG4_PORT_MIRROR_EN BIT(0) +/* 10M_SGMII_CFG bits */ +#define DP83867_10M_SGMII_RATE_ADAPT BIT(7) +enum {DP83867_PORT_MIRROING_KEEP ,DP83867_PORT_MIRROING_EN ,
drivers/net/phy/dp83867.c static int dp83867_config_init(struct phy_device *phydev) · line 289
Quoted 9 lines
drivers/net/phy/dp83867.c +6
-0@@ -277,6 +281,22 @@ static int dp83867_config_init(struct phy_device *phydev) DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL); } +if (phydev->interface ==PHY_INTERFACE_MODE_SGMII ) { +/* For support SPEED_10 in SGMII mode +* DP83867_10M_SGMII_RATE_ADAPT bit +* has to be cleared by software. That +* does not affect SPEED_100 and +* SPEED_1000.
Likewise, s/support/supporting/ with that and Heiner's suggestion to use phy_modify_mmd():
Quoted 14 lines
drivers/net/phy/dp83867.c +10
-0+*/ + val =phy_read_mmd (phydev,DP83867_DEVADDR , +DP83867_10M_SGMII_CFG ); + val &= ~DP83867_10M_SGMII_RATE_ADAPT ; + ret =phy_write_mmd (phydev,DP83867_DEVADDR , +DP83867_10M_SGMII_CFG , val); +if (ret) +return ret; + } +/* Enable Interrupt output INT_OE in CFG3 register */ if (phy_interrupt_is_valid (phydev)) { val =phy_read (phydev,DP83867_CFG3 );
Signature · 1 line
Florian
PATCH v2 2/4 net: phy: dp83867: increase SGMII autoneg timer duration
In reply to Max UvarovAfter reset SGMII Autoneg timer is set to 2us (bits 6 and 5 are 01). That us not enough to finalize autonegatiation on some devices. Increase this timer duration to maximum supported 16ms.
--- drivers/net/phy/dp83867.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/phy/dp83867.c +10 -0
@@ -295,6 +295,16 @@ static int dp83867_config_init(struct phy_device *phydev) DP83867_10M_SGMII_CFG, val);if (ret)return ret; + +/* After reset SGMII Autoneg timer is set to 2us (bits 6 and 5 +* are 01). That us not enough to finalize autoneg on some +* devices. Increase this timer duration to maximum 16ms. +*/ + val =phy_read_mmd (phydev,DP83867_DEVADDR ,DP83867_CFG4 ); + val &= ~(BIT (5 ) |BIT (6 )); + ret =phy_write_mmd (phydev,DP83867_DEVADDR ,DP83867_CFG4 , val); +if (ret) +return ret; }/* Enable Interrupt output INT_OE in CFG3 register */
Signature · 1 line
2.17.1
Heiner Kallweit
maintainerRe: [PATCH v2 2/4] net: phy: dp83867: increase SGMII autoneg timer duration
Quoted 15 lines · Max Uvarov
After reset SGMII Autoneg timer is set to 2us (bits 6 and 5 are 01). That us not enough to finalize autonegatiation on some devices. Increase this timer duration to maximum supported 16ms.
Signed-off-by Max Uvarov <[email protected]>Cc Heiner Kallweit <[email protected]>--- drivers/net/phy/dp83867.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/phy/dp83867.c +0
-0
drivers/net/phy/dp83867.c static int dp83867_config_init(struct phy_device *phydev) · line 304
Quoted 10 lines
drivers/net/phy/dp83867.c +7
-0@@ -295,6 +295,16 @@ static int dp83867_config_init(struct phy_device *phydev) DP83867_10M_SGMII_CFG, val);if (ret)return ret; + +/* After reset SGMII Autoneg timer is set to 2us (bits 6 and 5 +* are 01). That us not enough to finalize autoneg on some +* devices. Increase this timer duration to maximum 16ms. +*/ + val =phy_read_mmd (phydev,DP83867_DEVADDR ,DP83867_CFG4 ); + val &= ~(BIT (5 ) |BIT (6 ));
Using bit numbers directly isn't nice. Better define a mask and constants for the different combinations of bit 5 and 6 like:
#define FOO_SGMII_ANEG_TIMER_MASK 0x60
#define FOO_SGMII_ANEG_TIMER_2US 0x20
#define FOO_SGMII_ANEG_TIMER_16MS 0x60
And then use the constants in phy_modify_mmd().
Quoted 7 lines
drivers/net/phy/dp83867.c +3
-0+ ret =phy_write_mmd (phydev,DP83867_DEVADDR ,DP83867_CFG4 , val); +if (ret) +return ret; }/* Enable Interrupt output INT_OE in CFG3 register */
Re: [PATCH v2 2/4] net: phy: dp83867: increase SGMII autoneg timer duration
In reply to Max UvarovQuoted 2 lines · Max Uvarov
After reset SGMII Autoneg timer is set to 2us (bits 6 and 5 are 01). That us not enough to finalize autonegatiation on some devices.
s/us/is/
Quoted 16 lines
Increase this timer duration to maximum supported 16ms.
Signed-off-by Max Uvarov <[email protected]>Cc Heiner Kallweit <[email protected]>--- drivers/net/phy/dp83867.c | 10 ++++++++++ 1 file changed, 10 insertions(+)drivers/net/phy/dp83867.c +0
-0
drivers/net/phy/dp83867.c static int dp83867_config_init(struct phy_device *phydev) · line 300
Quoted 6 lines
drivers/net/phy/dp83867.c +3
-0@@ -295,6 +295,16 @@ static int dp83867_config_init(struct phy_device *phydev) DP83867_10M_SGMII_CFG, val);if (ret)return ret; + +/* After reset SGMII Autoneg timer is set to 2us (bits 6 and 5 +* are 01). That us not enough to finalize autoneg on some
Likewise, same typo was carried over here. With that fixed and Heiner's suggestions addressed:
Signature · 1 line
Florian
PATCH v2 3/4 net: phy: dp83867: do not call config_init twice
In reply to Max UvarovPhy state machine calls _config_init just after
reset.
--- drivers/net/phy/dp83867.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/dp83867.c +1 -1
@@ -337,7 +337,7 @@ static int dp83867_phy_reset(struct phy_device *phydev)usleep_range (10 ,20 ); -return dp83867_config_init (phydev); +return 0 ; }static struct phy_driver dp83867_driver[] = {
Signature · 1 line
2.17.1
Re: [PATCH v2 3/4] net: phy: dp83867: do not call config_init twice
Quoted 4 lines · Max Uvarov
Phy state machine calls
_config_initjust after
reset.Signed-off-by Max Uvarov <[email protected]>
Signature · 1 line
Florian
PATCH v2 4/4 net: phy: dp83867: Set up RGMII TX delay
In reply to Max UvarovPHY_INTERFACE_MODE_RGMII_RXID is less then TXID so code to set tx delay is never called.
--- drivers/net/phy/dp83867.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/phy/dp83867.c +1 -3
@@ -251,10 +251,8 @@ static int dp83867_config_init(struct phy_device *phydev) ret =phy_write (phydev,MII_DP83867_PHYCTRL , val);if (ret)return ret; - } -if ((phydev->interface >=PHY_INTERFACE_MODE_RGMII_ID ) && - (phydev->interface <=PHY_INTERFACE_MODE_RGMII_RXID )) { +/* Set up RGMII delays */ val =phy_read_mmd (phydev,DP83867_DEVADDR ,DP83867_RGMIICTL );if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID )
Signature · 1 line
2.17.1
Re: [PATCH v2 4/4] net: phy: dp83867: Set up RGMII TX delay
Quoted 6 lines · Max Uvarov
PHY_INTERFACE_MODE_RGMII_RXIDis less then TXID so code to set tx delay is never called.Fixes 2a10154abcb75 ("net: phy: dp83867: Add TI dp83867 phy")Signed-off-by Max Uvarov <[email protected]>Cc Florian Fainelli <[email protected]>
Signature · 1 line
Florian