Commit 921690f2 authored by Russell King's avatar Russell King Committed by David S. Miller

net: phy: split out 10G genphy support

Move the old 10G genphy support to sit beside the new clause 45 library
functions, so all the 10G phy code is together.
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 002ba705
...@@ -232,3 +232,67 @@ int genphy_c45_read_pma(struct phy_device *phydev) ...@@ -232,3 +232,67 @@ int genphy_c45_read_pma(struct phy_device *phydev)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(genphy_c45_read_pma); EXPORT_SYMBOL_GPL(genphy_c45_read_pma);
/* The gen10g_* functions are the old Clause 45 stub */
static int gen10g_config_aneg(struct phy_device *phydev)
{
return 0;
}
static int gen10g_read_status(struct phy_device *phydev)
{
u32 mmd_mask = phydev->c45_ids.devices_in_package;
int ret;
/* For now just lie and say it's 10G all the time */
phydev->speed = SPEED_10000;
phydev->duplex = DUPLEX_FULL;
/* Avoid reading the vendor MMDs */
mmd_mask &= ~(BIT(MDIO_MMD_VEND1) | BIT(MDIO_MMD_VEND2));
ret = genphy_c45_read_link(phydev, mmd_mask);
phydev->link = ret > 0 ? 1 : 0;
return 0;
}
static int gen10g_soft_reset(struct phy_device *phydev)
{
/* Do nothing for now */
return 0;
}
static int gen10g_config_init(struct phy_device *phydev)
{
/* Temporarily just say we support everything */
phydev->supported = SUPPORTED_10000baseT_Full;
phydev->advertising = SUPPORTED_10000baseT_Full;
return 0;
}
static int gen10g_suspend(struct phy_device *phydev)
{
return 0;
}
static int gen10g_resume(struct phy_device *phydev)
{
return 0;
}
struct phy_driver genphy_10g_driver = {
.phy_id = 0xffffffff,
.phy_id_mask = 0xffffffff,
.name = "Generic 10G PHY",
.soft_reset = gen10g_soft_reset,
.config_init = gen10g_config_init,
.features = 0,
.config_aneg = gen10g_config_aneg,
.read_status = gen10g_read_status,
.suspend = gen10g_suspend,
.resume = gen10g_resume,
};
...@@ -69,13 +69,8 @@ static void phy_mdio_device_remove(struct mdio_device *mdiodev) ...@@ -69,13 +69,8 @@ static void phy_mdio_device_remove(struct mdio_device *mdiodev)
phy_device_remove(phydev); phy_device_remove(phydev);
} }
enum genphy_driver { static struct phy_driver genphy_driver;
GENPHY_DRV_1G, extern struct phy_driver genphy_10g_driver;
GENPHY_DRV_10G,
GENPHY_DRV_MAX
};
static struct phy_driver genphy_driver[GENPHY_DRV_MAX];
static LIST_HEAD(phy_fixup_list); static LIST_HEAD(phy_fixup_list);
static DEFINE_MUTEX(phy_fixup_lock); static DEFINE_MUTEX(phy_fixup_lock);
...@@ -928,11 +923,9 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, ...@@ -928,11 +923,9 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
*/ */
if (!d->driver) { if (!d->driver) {
if (phydev->is_c45) if (phydev->is_c45)
d->driver = d->driver = &genphy_10g_driver.mdiodrv.driver;
&genphy_driver[GENPHY_DRV_10G].mdiodrv.driver;
else else
d->driver = d->driver = &genphy_driver.mdiodrv.driver;
&genphy_driver[GENPHY_DRV_1G].mdiodrv.driver;
using_genphy = true; using_genphy = true;
} }
...@@ -1069,7 +1062,6 @@ void phy_detach(struct phy_device *phydev) ...@@ -1069,7 +1062,6 @@ void phy_detach(struct phy_device *phydev)
struct net_device *dev = phydev->attached_dev; struct net_device *dev = phydev->attached_dev;
struct module *ndev_owner = dev->dev.parent->driver->owner; struct module *ndev_owner = dev->dev.parent->driver->owner;
struct mii_bus *bus; struct mii_bus *bus;
int i;
if (phydev->sysfs_links) { if (phydev->sysfs_links) {
sysfs_remove_link(&dev->dev.kobj, "phydev"); sysfs_remove_link(&dev->dev.kobj, "phydev");
...@@ -1088,13 +1080,9 @@ void phy_detach(struct phy_device *phydev) ...@@ -1088,13 +1080,9 @@ void phy_detach(struct phy_device *phydev)
* from the generic driver so that there's a chance a * from the generic driver so that there's a chance a
* real driver could be loaded * real driver could be loaded
*/ */
for (i = 0; i < ARRAY_SIZE(genphy_driver); i++) { if (phydev->mdio.dev.driver == &genphy_10g_driver.mdiodrv.driver ||
if (phydev->mdio.dev.driver == phydev->mdio.dev.driver == &genphy_driver.mdiodrv.driver)
&genphy_driver[i].mdiodrv.driver) { device_release_driver(&phydev->mdio.dev);
device_release_driver(&phydev->mdio.dev);
break;
}
}
/* /*
* The phydev might go away on the put_device() below, so avoid * The phydev might go away on the put_device() below, so avoid
...@@ -1368,11 +1356,6 @@ int genphy_aneg_done(struct phy_device *phydev) ...@@ -1368,11 +1356,6 @@ int genphy_aneg_done(struct phy_device *phydev)
} }
EXPORT_SYMBOL(genphy_aneg_done); EXPORT_SYMBOL(genphy_aneg_done);
static int gen10g_config_aneg(struct phy_device *phydev)
{
return 0;
}
/** /**
* genphy_update_link - update link status in @phydev * genphy_update_link - update link status in @phydev
* @phydev: target phy_device struct * @phydev: target phy_device struct
...@@ -1506,25 +1489,6 @@ int genphy_read_status(struct phy_device *phydev) ...@@ -1506,25 +1489,6 @@ int genphy_read_status(struct phy_device *phydev)
} }
EXPORT_SYMBOL(genphy_read_status); EXPORT_SYMBOL(genphy_read_status);
static int gen10g_read_status(struct phy_device *phydev)
{
u32 mmd_mask = phydev->c45_ids.devices_in_package;
int ret;
/* For now just lie and say it's 10G all the time */
phydev->speed = SPEED_10000;
phydev->duplex = DUPLEX_FULL;
/* Avoid reading the vendor MMDs */
mmd_mask &= ~(BIT(MDIO_MMD_VEND1) | BIT(MDIO_MMD_VEND2));
ret = genphy_c45_read_link(phydev, mmd_mask);
phydev->link = ret > 0 ? 1 : 0;
return 0;
}
/** /**
* genphy_soft_reset - software reset the PHY via BMCR_RESET bit * genphy_soft_reset - software reset the PHY via BMCR_RESET bit
* @phydev: target phy_device struct * @phydev: target phy_device struct
...@@ -1590,21 +1554,6 @@ int genphy_config_init(struct phy_device *phydev) ...@@ -1590,21 +1554,6 @@ int genphy_config_init(struct phy_device *phydev)
} }
EXPORT_SYMBOL(genphy_config_init); EXPORT_SYMBOL(genphy_config_init);
static int gen10g_soft_reset(struct phy_device *phydev)
{
/* Do nothing for now */
return 0;
}
static int gen10g_config_init(struct phy_device *phydev)
{
/* Temporarily just say we support everything */
phydev->supported = SUPPORTED_10000baseT_Full;
phydev->advertising = SUPPORTED_10000baseT_Full;
return 0;
}
int genphy_suspend(struct phy_device *phydev) int genphy_suspend(struct phy_device *phydev)
{ {
int value; int value;
...@@ -1620,11 +1569,6 @@ int genphy_suspend(struct phy_device *phydev) ...@@ -1620,11 +1569,6 @@ int genphy_suspend(struct phy_device *phydev)
} }
EXPORT_SYMBOL(genphy_suspend); EXPORT_SYMBOL(genphy_suspend);
static int gen10g_suspend(struct phy_device *phydev)
{
return 0;
}
int genphy_resume(struct phy_device *phydev) int genphy_resume(struct phy_device *phydev)
{ {
int value; int value;
...@@ -1640,11 +1584,6 @@ int genphy_resume(struct phy_device *phydev) ...@@ -1640,11 +1584,6 @@ int genphy_resume(struct phy_device *phydev)
} }
EXPORT_SYMBOL(genphy_resume); EXPORT_SYMBOL(genphy_resume);
static int gen10g_resume(struct phy_device *phydev)
{
return 0;
}
static int __set_phy_supported(struct phy_device *phydev, u32 max_speed) static int __set_phy_supported(struct phy_device *phydev, u32 max_speed)
{ {
/* The default values for phydev->supported are provided by the PHY /* The default values for phydev->supported are provided by the PHY
...@@ -1876,8 +1815,7 @@ void phy_drivers_unregister(struct phy_driver *drv, int n) ...@@ -1876,8 +1815,7 @@ void phy_drivers_unregister(struct phy_driver *drv, int n)
} }
EXPORT_SYMBOL(phy_drivers_unregister); EXPORT_SYMBOL(phy_drivers_unregister);
static struct phy_driver genphy_driver[] = { static struct phy_driver genphy_driver = {
{
.phy_id = 0xffffffff, .phy_id = 0xffffffff,
.phy_id_mask = 0xffffffff, .phy_id_mask = 0xffffffff,
.name = "Generic PHY", .name = "Generic PHY",
...@@ -1891,18 +1829,7 @@ static struct phy_driver genphy_driver[] = { ...@@ -1891,18 +1829,7 @@ static struct phy_driver genphy_driver[] = {
.read_status = genphy_read_status, .read_status = genphy_read_status,
.suspend = genphy_suspend, .suspend = genphy_suspend,
.resume = genphy_resume, .resume = genphy_resume,
}, { };
.phy_id = 0xffffffff,
.phy_id_mask = 0xffffffff,
.name = "Generic 10G PHY",
.soft_reset = gen10g_soft_reset,
.config_init = gen10g_config_init,
.features = 0,
.config_aneg = gen10g_config_aneg,
.read_status = gen10g_read_status,
.suspend = gen10g_suspend,
.resume = gen10g_resume,
} };
static int __init phy_init(void) static int __init phy_init(void)
{ {
...@@ -1912,18 +1839,24 @@ static int __init phy_init(void) ...@@ -1912,18 +1839,24 @@ static int __init phy_init(void)
if (rc) if (rc)
return rc; return rc;
rc = phy_drivers_register(genphy_driver, rc = phy_driver_register(&genphy_10g_driver, THIS_MODULE);
ARRAY_SIZE(genphy_driver), THIS_MODULE);
if (rc) if (rc)
goto err_10g;
rc = phy_driver_register(&genphy_driver, THIS_MODULE);
if (rc) {
phy_driver_unregister(&genphy_10g_driver);
err_10g:
mdio_bus_exit(); mdio_bus_exit();
}
return rc; return rc;
} }
static void __exit phy_exit(void) static void __exit phy_exit(void)
{ {
phy_drivers_unregister(genphy_driver, phy_driver_unregister(&genphy_10g_driver);
ARRAY_SIZE(genphy_driver)); phy_driver_unregister(&genphy_driver);
mdio_bus_exit(); mdio_bus_exit();
} }
......
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