Commit 96dbdc5d authored by David S. Miller's avatar David S. Miller

Merge branch 'net-phy-Reduce-duplication'

Florian Fainelli says:

====================
net: phy: Reduce duplication

This patch series reduces the duplication among 10G PHY drivers that just
essentially stub most functions, but do that while replicating what the existing
generic functions do.

Changes in v3:

- removed unused "reg" variable in teranetics.c
- fixed subject for patch 5 since we actually use gen10g_no_soft_reset()

Changes in v2:

- rename gen10g_soft_reset() to gen10g_no_soft_reset() to better illustrate
  what it does (or does not)
- removed stray comment in marvell10g.c
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 5697b3e1 56847704
...@@ -38,14 +38,6 @@ static int aquantia_config_aneg(struct phy_device *phydev) ...@@ -38,14 +38,6 @@ static int aquantia_config_aneg(struct phy_device *phydev)
return 0; return 0;
} }
static int aquantia_aneg_done(struct phy_device *phydev)
{
int reg;
reg = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
return (reg < 0) ? reg : (reg & BMSR_ANEGCOMPLETE);
}
static int aquantia_config_intr(struct phy_device *phydev) static int aquantia_config_intr(struct phy_device *phydev)
{ {
int err; int err;
...@@ -125,7 +117,7 @@ static struct phy_driver aquantia_driver[] = { ...@@ -125,7 +117,7 @@ static struct phy_driver aquantia_driver[] = {
.name = "Aquantia AQ1202", .name = "Aquantia AQ1202",
.features = PHY_AQUANTIA_FEATURES, .features = PHY_AQUANTIA_FEATURES,
.flags = PHY_HAS_INTERRUPT, .flags = PHY_HAS_INTERRUPT,
.aneg_done = aquantia_aneg_done, .aneg_done = genphy_c45_aneg_done,
.config_aneg = aquantia_config_aneg, .config_aneg = aquantia_config_aneg,
.config_intr = aquantia_config_intr, .config_intr = aquantia_config_intr,
.ack_interrupt = aquantia_ack_interrupt, .ack_interrupt = aquantia_ack_interrupt,
...@@ -137,7 +129,7 @@ static struct phy_driver aquantia_driver[] = { ...@@ -137,7 +129,7 @@ static struct phy_driver aquantia_driver[] = {
.name = "Aquantia AQ2104", .name = "Aquantia AQ2104",
.features = PHY_AQUANTIA_FEATURES, .features = PHY_AQUANTIA_FEATURES,
.flags = PHY_HAS_INTERRUPT, .flags = PHY_HAS_INTERRUPT,
.aneg_done = aquantia_aneg_done, .aneg_done = genphy_c45_aneg_done,
.config_aneg = aquantia_config_aneg, .config_aneg = aquantia_config_aneg,
.config_intr = aquantia_config_intr, .config_intr = aquantia_config_intr,
.ack_interrupt = aquantia_ack_interrupt, .ack_interrupt = aquantia_ack_interrupt,
...@@ -149,7 +141,7 @@ static struct phy_driver aquantia_driver[] = { ...@@ -149,7 +141,7 @@ static struct phy_driver aquantia_driver[] = {
.name = "Aquantia AQR105", .name = "Aquantia AQR105",
.features = PHY_AQUANTIA_FEATURES, .features = PHY_AQUANTIA_FEATURES,
.flags = PHY_HAS_INTERRUPT, .flags = PHY_HAS_INTERRUPT,
.aneg_done = aquantia_aneg_done, .aneg_done = genphy_c45_aneg_done,
.config_aneg = aquantia_config_aneg, .config_aneg = aquantia_config_aneg,
.config_intr = aquantia_config_intr, .config_intr = aquantia_config_intr,
.ack_interrupt = aquantia_ack_interrupt, .ack_interrupt = aquantia_ack_interrupt,
...@@ -161,7 +153,7 @@ static struct phy_driver aquantia_driver[] = { ...@@ -161,7 +153,7 @@ static struct phy_driver aquantia_driver[] = {
.name = "Aquantia AQR106", .name = "Aquantia AQR106",
.features = PHY_AQUANTIA_FEATURES, .features = PHY_AQUANTIA_FEATURES,
.flags = PHY_HAS_INTERRUPT, .flags = PHY_HAS_INTERRUPT,
.aneg_done = aquantia_aneg_done, .aneg_done = genphy_c45_aneg_done,
.config_aneg = aquantia_config_aneg, .config_aneg = aquantia_config_aneg,
.config_intr = aquantia_config_intr, .config_intr = aquantia_config_intr,
.ack_interrupt = aquantia_ack_interrupt, .ack_interrupt = aquantia_ack_interrupt,
...@@ -173,7 +165,7 @@ static struct phy_driver aquantia_driver[] = { ...@@ -173,7 +165,7 @@ static struct phy_driver aquantia_driver[] = {
.name = "Aquantia AQR107", .name = "Aquantia AQR107",
.features = PHY_AQUANTIA_FEATURES, .features = PHY_AQUANTIA_FEATURES,
.flags = PHY_HAS_INTERRUPT, .flags = PHY_HAS_INTERRUPT,
.aneg_done = aquantia_aneg_done, .aneg_done = genphy_c45_aneg_done,
.config_aneg = aquantia_config_aneg, .config_aneg = aquantia_config_aneg,
.config_intr = aquantia_config_intr, .config_intr = aquantia_config_intr,
.ack_interrupt = aquantia_ack_interrupt, .ack_interrupt = aquantia_ack_interrupt,
...@@ -185,7 +177,7 @@ static struct phy_driver aquantia_driver[] = { ...@@ -185,7 +177,7 @@ static struct phy_driver aquantia_driver[] = {
.name = "Aquantia AQR405", .name = "Aquantia AQR405",
.features = PHY_AQUANTIA_FEATURES, .features = PHY_AQUANTIA_FEATURES,
.flags = PHY_HAS_INTERRUPT, .flags = PHY_HAS_INTERRUPT,
.aneg_done = aquantia_aneg_done, .aneg_done = genphy_c45_aneg_done,
.config_aneg = aquantia_config_aneg, .config_aneg = aquantia_config_aneg,
.config_intr = aquantia_config_intr, .config_intr = aquantia_config_intr,
.ack_interrupt = aquantia_ack_interrupt, .ack_interrupt = aquantia_ack_interrupt,
......
...@@ -30,14 +30,6 @@ static int cortina_read_reg(struct phy_device *phydev, u16 regnum) ...@@ -30,14 +30,6 @@ static int cortina_read_reg(struct phy_device *phydev, u16 regnum)
MII_ADDR_C45 | regnum); MII_ADDR_C45 | regnum);
} }
static int cortina_config_aneg(struct phy_device *phydev)
{
phydev->supported = SUPPORTED_10000baseT_Full;
phydev->advertising = SUPPORTED_10000baseT_Full;
return 0;
}
static int cortina_read_status(struct phy_device *phydev) static int cortina_read_status(struct phy_device *phydev)
{ {
int gpio_int_status, ret = 0; int gpio_int_status, ret = 0;
...@@ -61,11 +53,6 @@ static int cortina_read_status(struct phy_device *phydev) ...@@ -61,11 +53,6 @@ static int cortina_read_status(struct phy_device *phydev)
return ret; return ret;
} }
static int cortina_soft_reset(struct phy_device *phydev)
{
return 0;
}
static int cortina_probe(struct phy_device *phydev) static int cortina_probe(struct phy_device *phydev)
{ {
u32 phy_id = 0; u32 phy_id = 0;
...@@ -101,9 +88,10 @@ static struct phy_driver cortina_driver[] = { ...@@ -101,9 +88,10 @@ static struct phy_driver cortina_driver[] = {
.phy_id = PHY_ID_CS4340, .phy_id = PHY_ID_CS4340,
.phy_id_mask = 0xffffffff, .phy_id_mask = 0xffffffff,
.name = "Cortina CS4340", .name = "Cortina CS4340",
.config_aneg = cortina_config_aneg, .config_init = gen10g_config_init,
.config_aneg = gen10g_config_aneg,
.read_status = cortina_read_status, .read_status = cortina_read_status,
.soft_reset = cortina_soft_reset, .soft_reset = gen10g_no_soft_reset,
.probe = cortina_probe, .probe = cortina_probe,
}, },
}; };
......
...@@ -71,15 +71,6 @@ static int mv3310_probe(struct phy_device *phydev) ...@@ -71,15 +71,6 @@ static int mv3310_probe(struct phy_device *phydev)
return 0; return 0;
} }
/*
* Resetting the MV88X3310 causes it to become non-responsive. Avoid
* setting the reset bit(s).
*/
static int mv3310_soft_reset(struct phy_device *phydev)
{
return 0;
}
static int mv3310_config_init(struct phy_device *phydev) static int mv3310_config_init(struct phy_device *phydev)
{ {
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, }; __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
...@@ -377,7 +368,7 @@ static struct phy_driver mv3310_drivers[] = { ...@@ -377,7 +368,7 @@ static struct phy_driver mv3310_drivers[] = {
SUPPORTED_10000baseT_Full | SUPPORTED_10000baseT_Full |
SUPPORTED_Backplane, SUPPORTED_Backplane,
.probe = mv3310_probe, .probe = mv3310_probe,
.soft_reset = mv3310_soft_reset, .soft_reset = gen10g_no_soft_reset,
.config_init = mv3310_config_init, .config_init = mv3310_config_init,
.config_aneg = mv3310_config_aneg, .config_aneg = mv3310_config_aneg,
.aneg_done = mv3310_aneg_done, .aneg_done = mv3310_aneg_done,
......
...@@ -268,12 +268,13 @@ EXPORT_SYMBOL_GPL(genphy_c45_read_mdix); ...@@ -268,12 +268,13 @@ EXPORT_SYMBOL_GPL(genphy_c45_read_mdix);
/* The gen10g_* functions are the old Clause 45 stub */ /* The gen10g_* functions are the old Clause 45 stub */
static int gen10g_config_aneg(struct phy_device *phydev) int gen10g_config_aneg(struct phy_device *phydev)
{ {
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(gen10g_config_aneg);
static int gen10g_read_status(struct phy_device *phydev) int gen10g_read_status(struct phy_device *phydev)
{ {
u32 mmd_mask = phydev->c45_ids.devices_in_package; u32 mmd_mask = phydev->c45_ids.devices_in_package;
int ret; int ret;
...@@ -291,14 +292,16 @@ static int gen10g_read_status(struct phy_device *phydev) ...@@ -291,14 +292,16 @@ static int gen10g_read_status(struct phy_device *phydev)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(gen10g_read_status);
static int gen10g_soft_reset(struct phy_device *phydev) int gen10g_no_soft_reset(struct phy_device *phydev)
{ {
/* Do nothing for now */ /* Do nothing for now */
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(gen10g_no_soft_reset);
static int gen10g_config_init(struct phy_device *phydev) int gen10g_config_init(struct phy_device *phydev)
{ {
/* Temporarily just say we support everything */ /* Temporarily just say we support everything */
phydev->supported = SUPPORTED_10000baseT_Full; phydev->supported = SUPPORTED_10000baseT_Full;
...@@ -306,22 +309,25 @@ static int gen10g_config_init(struct phy_device *phydev) ...@@ -306,22 +309,25 @@ static int gen10g_config_init(struct phy_device *phydev)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(gen10g_config_init);
static int gen10g_suspend(struct phy_device *phydev) int gen10g_suspend(struct phy_device *phydev)
{ {
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(gen10g_suspend);
static int gen10g_resume(struct phy_device *phydev) int gen10g_resume(struct phy_device *phydev)
{ {
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(gen10g_resume);
struct phy_driver genphy_10g_driver = { struct phy_driver genphy_10g_driver = {
.phy_id = 0xffffffff, .phy_id = 0xffffffff,
.phy_id_mask = 0xffffffff, .phy_id_mask = 0xffffffff,
.name = "Generic 10G PHY", .name = "Generic 10G PHY",
.soft_reset = gen10g_soft_reset, .soft_reset = gen10g_no_soft_reset,
.config_init = gen10g_config_init, .config_init = gen10g_config_init,
.features = 0, .features = 0,
.config_aneg = gen10g_config_aneg, .config_aneg = gen10g_config_aneg,
......
...@@ -34,39 +34,17 @@ MODULE_LICENSE("GPL v2"); ...@@ -34,39 +34,17 @@ MODULE_LICENSE("GPL v2");
MDIO_PHYXS_LNSTAT_SYNC3 | \ MDIO_PHYXS_LNSTAT_SYNC3 | \
MDIO_PHYXS_LNSTAT_ALIGN) MDIO_PHYXS_LNSTAT_ALIGN)
static int teranetics_config_init(struct phy_device *phydev)
{
phydev->supported = SUPPORTED_10000baseT_Full;
phydev->advertising = SUPPORTED_10000baseT_Full;
return 0;
}
static int teranetics_soft_reset(struct phy_device *phydev)
{
return 0;
}
static int teranetics_aneg_done(struct phy_device *phydev) static int teranetics_aneg_done(struct phy_device *phydev)
{ {
int reg;
/* auto negotiation state can only be checked when using copper /* auto negotiation state can only be checked when using copper
* port, if using fiber port, just lie it's done. * port, if using fiber port, just lie it's done.
*/ */
if (!phy_read_mmd(phydev, MDIO_MMD_VEND1, 93)) { if (!phy_read_mmd(phydev, MDIO_MMD_VEND1, 93))
reg = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1); return genphy_c45_aneg_done(phydev);
return (reg < 0) ? reg : (reg & BMSR_ANEGCOMPLETE);
}
return 1; return 1;
} }
static int teranetics_config_aneg(struct phy_device *phydev)
{
return 0;
}
static int teranetics_read_status(struct phy_device *phydev) static int teranetics_read_status(struct phy_device *phydev)
{ {
int reg; int reg;
...@@ -102,10 +80,10 @@ static struct phy_driver teranetics_driver[] = { ...@@ -102,10 +80,10 @@ static struct phy_driver teranetics_driver[] = {
.phy_id = PHY_ID_TN2020, .phy_id = PHY_ID_TN2020,
.phy_id_mask = 0xffffffff, .phy_id_mask = 0xffffffff,
.name = "Teranetics TN2020", .name = "Teranetics TN2020",
.soft_reset = teranetics_soft_reset, .soft_reset = gen10g_no_soft_reset,
.aneg_done = teranetics_aneg_done, .aneg_done = teranetics_aneg_done,
.config_init = teranetics_config_init, .config_init = gen10g_config_init,
.config_aneg = teranetics_config_aneg, .config_aneg = gen10g_config_aneg,
.read_status = teranetics_read_status, .read_status = teranetics_read_status,
.match_phy_device = teranetics_match_phy_device, .match_phy_device = teranetics_match_phy_device,
}, },
......
...@@ -994,6 +994,14 @@ int genphy_c45_pma_setup_forced(struct phy_device *phydev); ...@@ -994,6 +994,14 @@ int genphy_c45_pma_setup_forced(struct phy_device *phydev);
int genphy_c45_an_disable_aneg(struct phy_device *phydev); int genphy_c45_an_disable_aneg(struct phy_device *phydev);
int genphy_c45_read_mdix(struct phy_device *phydev); int genphy_c45_read_mdix(struct phy_device *phydev);
/* The gen10g_* functions are the old Clause 45 stub */
int gen10g_config_aneg(struct phy_device *phydev);
int gen10g_read_status(struct phy_device *phydev);
int gen10g_no_soft_reset(struct phy_device *phydev);
int gen10g_config_init(struct phy_device *phydev);
int gen10g_suspend(struct phy_device *phydev);
int gen10g_resume(struct phy_device *phydev);
static inline int phy_read_status(struct phy_device *phydev) static inline int phy_read_status(struct phy_device *phydev)
{ {
if (!phydev->drv) if (!phydev->drv)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment