2022-05-07 05:07:49

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v4 0/7] add ti dp83td510 support

changes v4:
- dp83td510: remove unused variables
- s/base1/baset1
- s/genphy_c45_baset1_read_master_slave/genphy_c45_pma_baset1_read_master_slave

changes v3:
- export reusable code snippets and make use of it in the dp83td510
driver

changes v2:
- rewrite the driver reduce usage of common code and to reduce amount of
quirks.
- add genphy_c45_baset1_an_config_aneg fix

Oleksij Rempel (7):
net: phy: genphy_c45_baset1_an_config_aneg: do no set unknown
configuration
net: phy: introduce genphy_c45_pma_baset1_setup_master_slave()
net: phy: genphy_c45_pma_baset1_setup_master_slave: do no set unknown
configuration
net: phy: introduce genphy_c45_pma_baset1_read_master_slave()
net: phy: genphy_c45_pma_baset1_read_master_slave: read actual
configuration
net: phy: export genphy_c45_baset1_read_status()
net: phy: dp83td510: Add support for the DP83TD510 Ethernet PHY

drivers/net/phy/Kconfig | 6 ++
drivers/net/phy/Makefile | 1 +
drivers/net/phy/dp83td510.c | 209 ++++++++++++++++++++++++++++++++++++
drivers/net/phy/phy-c45.c | 94 +++++++++++-----
include/linux/phy.h | 3 +
5 files changed, 286 insertions(+), 27 deletions(-)
create mode 100644 drivers/net/phy/dp83td510.c

--
2.30.2



2022-05-08 12:18:25

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v4 3/7] net: phy: genphy_c45_pma_baset1_setup_master_slave: do no set unknown configuration

Do not change default master/slave forced configuration if no changes was
requested.

Signed-off-by: Oleksij Rempel <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
---
drivers/net/phy/phy-c45.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index ffa2d5cd09fc..b1f7c63f66cd 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -86,9 +86,10 @@ int genphy_c45_pma_baset1_setup_master_slave(struct phy_device *phydev)
break;
case MASTER_SLAVE_CFG_SLAVE_FORCE:
case MASTER_SLAVE_CFG_SLAVE_PREFERRED:
+ break;
case MASTER_SLAVE_CFG_UNKNOWN:
case MASTER_SLAVE_CFG_UNSUPPORTED:
- break;
+ return 0;
default:
phydev_warn(phydev, "Unsupported Master/Slave mode\n");
return -EOPNOTSUPP;
--
2.30.2


2022-05-09 02:19:24

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v4 2/7] net: phy: introduce genphy_c45_pma_baset1_setup_master_slave()

Move baset1 specific part of genphy_c45_pma_setup_forced() code to
separate function to make it reusable by PHY drivers.

Signed-off-by: Oleksij Rempel <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
---
drivers/net/phy/phy-c45.c | 49 ++++++++++++++++++++++++---------------
include/linux/phy.h | 1 +
2 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 0014aa6e73c0..ffa2d5cd09fc 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -70,6 +70,35 @@ int genphy_c45_pma_suspend(struct phy_device *phydev)
}
EXPORT_SYMBOL_GPL(genphy_c45_pma_suspend);

+/**
+ * genphy_c45_pma_baset1_setup_master_slave - configures forced master/slave
+ * role of BaseT1 devices.
+ * @phydev: target phy_device struct
+ */
+int genphy_c45_pma_baset1_setup_master_slave(struct phy_device *phydev)
+{
+ int ctl = 0;
+
+ switch (phydev->master_slave_set) {
+ case MASTER_SLAVE_CFG_MASTER_PREFERRED:
+ case MASTER_SLAVE_CFG_MASTER_FORCE:
+ ctl = MDIO_PMA_PMD_BT1_CTRL_CFG_MST;
+ break;
+ case MASTER_SLAVE_CFG_SLAVE_FORCE:
+ case MASTER_SLAVE_CFG_SLAVE_PREFERRED:
+ case MASTER_SLAVE_CFG_UNKNOWN:
+ case MASTER_SLAVE_CFG_UNSUPPORTED:
+ break;
+ default:
+ phydev_warn(phydev, "Unsupported Master/Slave mode\n");
+ return -EOPNOTSUPP;
+ }
+
+ return phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1_CTRL,
+ MDIO_PMA_PMD_BT1_CTRL_CFG_MST, ctl);
+}
+EXPORT_SYMBOL_GPL(genphy_c45_pma_baset1_setup_master_slave);
+
/**
* genphy_c45_pma_setup_forced - configures a forced speed
* @phydev: target phy_device struct
@@ -141,25 +170,7 @@ int genphy_c45_pma_setup_forced(struct phy_device *phydev)
return ret;

if (genphy_c45_baset1_able(phydev)) {
- int ctl = 0;
-
- switch (phydev->master_slave_set) {
- case MASTER_SLAVE_CFG_MASTER_PREFERRED:
- case MASTER_SLAVE_CFG_MASTER_FORCE:
- ctl = MDIO_PMA_PMD_BT1_CTRL_CFG_MST;
- break;
- case MASTER_SLAVE_CFG_SLAVE_FORCE:
- case MASTER_SLAVE_CFG_SLAVE_PREFERRED:
- case MASTER_SLAVE_CFG_UNKNOWN:
- case MASTER_SLAVE_CFG_UNSUPPORTED:
- break;
- default:
- phydev_warn(phydev, "Unsupported Master/Slave mode\n");
- return -EOPNOTSUPP;
- }
-
- ret = phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1_CTRL,
- MDIO_PMA_PMD_BT1_CTRL_CFG_MST, ctl);
+ ret = genphy_c45_pma_baset1_setup_master_slave(phydev);
if (ret < 0)
return ret;
}
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 2d12054932ba..d3f924d3b235 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1614,6 +1614,7 @@ int genphy_c45_read_link(struct phy_device *phydev);
int genphy_c45_read_lpa(struct phy_device *phydev);
int genphy_c45_read_pma(struct phy_device *phydev);
int genphy_c45_pma_setup_forced(struct phy_device *phydev);
+int genphy_c45_pma_baset1_setup_master_slave(struct phy_device *phydev);
int genphy_c45_an_config_aneg(struct phy_device *phydev);
int genphy_c45_an_disable_aneg(struct phy_device *phydev);
int genphy_c45_read_mdix(struct phy_device *phydev);
--
2.30.2


2022-05-09 03:33:58

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v4 5/7] net: phy: genphy_c45_pma_baset1_read_master_slave: read actual configuration

Since MDIO_PMA_PMD_BT1_CTRL register shows actual configuration (and
forced state configuration is equal to the state), we should show
this configuration for ethtool.

Signed-off-by: Oleksij Rempel <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
---
drivers/net/phy/phy-c45.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index d440b76a18b4..a0684c716a2e 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -560,15 +560,19 @@ int genphy_c45_pma_baset1_read_master_slave(struct phy_device *phydev)
int val;

phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
+ phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN;

val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_PMD_BT1_CTRL);
if (val < 0)
return val;

- if (val & MDIO_PMA_PMD_BT1_CTRL_CFG_MST)
+ if (val & MDIO_PMA_PMD_BT1_CTRL_CFG_MST) {
+ phydev->master_slave_get = MASTER_SLAVE_CFG_MASTER_FORCE;
phydev->master_slave_state = MASTER_SLAVE_STATE_MASTER;
- else
+ } else {
+ phydev->master_slave_get = MASTER_SLAVE_CFG_SLAVE_FORCE;
phydev->master_slave_state = MASTER_SLAVE_STATE_SLAVE;
+ }

return 0;
}
--
2.30.2


2022-05-09 09:42:20

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v4 6/7] net: phy: export genphy_c45_baset1_read_status()

Export genphy_c45_baset1_read_status() to make it reusable by PHY drivers.

Signed-off-by: Oleksij Rempel <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
---
drivers/net/phy/phy-c45.c | 3 ++-
include/linux/phy.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index a0684c716a2e..29b1df03f3e8 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -785,7 +785,7 @@ EXPORT_SYMBOL_GPL(genphy_c45_pma_read_abilities);
* is forced or not, it is read from BASE-T1 AN advertisement
* register 7.514.
*/
-static int genphy_c45_baset1_read_status(struct phy_device *phydev)
+int genphy_c45_baset1_read_status(struct phy_device *phydev)
{
int ret;
int cfg;
@@ -815,6 +815,7 @@ static int genphy_c45_baset1_read_status(struct phy_device *phydev)

return 0;
}
+EXPORT_SYMBOL_GPL(genphy_c45_baset1_read_status);

/**
* genphy_c45_read_status - read PHY status
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 4713c95d65fb..508f1149665b 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1621,6 +1621,7 @@ int genphy_c45_read_mdix(struct phy_device *phydev);
int genphy_c45_pma_read_abilities(struct phy_device *phydev);
int genphy_c45_pma_baset1_read_master_slave(struct phy_device *phydev);
int genphy_c45_read_status(struct phy_device *phydev);
+int genphy_c45_baset1_read_status(struct phy_device *phydev);
int genphy_c45_config_aneg(struct phy_device *phydev);
int genphy_c45_loopback(struct phy_device *phydev, bool enable);
int genphy_c45_pma_resume(struct phy_device *phydev);
--
2.30.2


2022-05-09 09:48:53

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v4 1/7] net: phy: genphy_c45_baset1_an_config_aneg: do no set unknown configuration

Do not change default master/slave autoneg configuration if no
changes was requested.

Fixes: 3da8ffd8545f ("net: phy: Add 10BASE-T1L support in phy-c45")
Signed-off-by: Oleksij Rempel <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
---
drivers/net/phy/phy-c45.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index eefdd67d5556..0014aa6e73c0 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -191,8 +191,12 @@ static int genphy_c45_baset1_an_config_aneg(struct phy_device *phydev)
case MASTER_SLAVE_CFG_MASTER_PREFERRED:
case MASTER_SLAVE_CFG_SLAVE_PREFERRED:
break;
+ case MASTER_SLAVE_CFG_UNKNOWN:
+ case MASTER_SLAVE_CFG_UNSUPPORTED:
+ return 0;
default:
- break;
+ phydev_warn(phydev, "Unsupported Master/Slave mode\n");
+ return -EOPNOTSUPP;
}

switch (phydev->master_slave_set) {
--
2.30.2


2022-05-09 12:01:49

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH net-next v4 0/7] add ti dp83td510 support

Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <[email protected]>:

On Fri, 6 May 2022 06:23:50 +0200 you wrote:
> changes v4:
> - dp83td510: remove unused variables
> - s/base1/baset1
> - s/genphy_c45_baset1_read_master_slave/genphy_c45_pma_baset1_read_master_slave
>
> changes v3:
> - export reusable code snippets and make use of it in the dp83td510
> driver
>
> [...]

Here is the summary with links:
- [net-next,v4,1/7] net: phy: genphy_c45_baset1_an_config_aneg: do no set unknown configuration
https://git.kernel.org/netdev/net-next/c/a7f0e4bea8ed
- [net-next,v4,2/7] net: phy: introduce genphy_c45_pma_baset1_setup_master_slave()
https://git.kernel.org/netdev/net-next/c/90532850eb21
- [net-next,v4,3/7] net: phy: genphy_c45_pma_baset1_setup_master_slave: do no set unknown configuration
https://git.kernel.org/netdev/net-next/c/a04dd88f77a4
- [net-next,v4,4/7] net: phy: introduce genphy_c45_pma_baset1_read_master_slave()
https://git.kernel.org/netdev/net-next/c/b9a366f3d874
- [net-next,v4,5/7] net: phy: genphy_c45_pma_baset1_read_master_slave: read actual configuration
https://git.kernel.org/netdev/net-next/c/acb8c5aec2b1
- [net-next,v4,6/7] net: phy: export genphy_c45_baset1_read_status()
https://git.kernel.org/netdev/net-next/c/2013ad8836ac
- [net-next,v4,7/7] net: phy: dp83td510: Add support for the DP83TD510 Ethernet PHY
https://git.kernel.org/netdev/net-next/c/165cd04fe253

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html