net: phy: at803x: move at8031 functions in dedicated section
Move at8031 functions in dedicated section with dedicated at8031 parse_dt and probe. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a5ab9d8e7a
commit
f932a6dc8b
@ -583,139 +583,6 @@ static int at803x_resume(struct phy_device *phydev)
|
||||
return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0);
|
||||
}
|
||||
|
||||
static int at8031_rgmii_reg_set_voltage_sel(struct regulator_dev *rdev,
|
||||
unsigned int selector)
|
||||
{
|
||||
struct phy_device *phydev = rdev_get_drvdata(rdev);
|
||||
|
||||
if (selector)
|
||||
return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F,
|
||||
0, AT803X_DEBUG_RGMII_1V8);
|
||||
else
|
||||
return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F,
|
||||
AT803X_DEBUG_RGMII_1V8, 0);
|
||||
}
|
||||
|
||||
static int at8031_rgmii_reg_get_voltage_sel(struct regulator_dev *rdev)
|
||||
{
|
||||
struct phy_device *phydev = rdev_get_drvdata(rdev);
|
||||
int val;
|
||||
|
||||
val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F);
|
||||
if (val < 0)
|
||||
return val;
|
||||
|
||||
return (val & AT803X_DEBUG_RGMII_1V8) ? 1 : 0;
|
||||
}
|
||||
|
||||
static const struct regulator_ops vddio_regulator_ops = {
|
||||
.list_voltage = regulator_list_voltage_table,
|
||||
.set_voltage_sel = at8031_rgmii_reg_set_voltage_sel,
|
||||
.get_voltage_sel = at8031_rgmii_reg_get_voltage_sel,
|
||||
};
|
||||
|
||||
static const unsigned int vddio_voltage_table[] = {
|
||||
1500000,
|
||||
1800000,
|
||||
};
|
||||
|
||||
static const struct regulator_desc vddio_desc = {
|
||||
.name = "vddio",
|
||||
.of_match = of_match_ptr("vddio-regulator"),
|
||||
.n_voltages = ARRAY_SIZE(vddio_voltage_table),
|
||||
.volt_table = vddio_voltage_table,
|
||||
.ops = &vddio_regulator_ops,
|
||||
.type = REGULATOR_VOLTAGE,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct regulator_ops vddh_regulator_ops = {
|
||||
};
|
||||
|
||||
static const struct regulator_desc vddh_desc = {
|
||||
.name = "vddh",
|
||||
.of_match = of_match_ptr("vddh-regulator"),
|
||||
.n_voltages = 1,
|
||||
.fixed_uV = 2500000,
|
||||
.ops = &vddh_regulator_ops,
|
||||
.type = REGULATOR_VOLTAGE,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int at8031_register_regulators(struct phy_device *phydev)
|
||||
{
|
||||
struct at803x_priv *priv = phydev->priv;
|
||||
struct device *dev = &phydev->mdio.dev;
|
||||
struct regulator_config config = { };
|
||||
|
||||
config.dev = dev;
|
||||
config.driver_data = phydev;
|
||||
|
||||
priv->vddio_rdev = devm_regulator_register(dev, &vddio_desc, &config);
|
||||
if (IS_ERR(priv->vddio_rdev)) {
|
||||
phydev_err(phydev, "failed to register VDDIO regulator\n");
|
||||
return PTR_ERR(priv->vddio_rdev);
|
||||
}
|
||||
|
||||
priv->vddh_rdev = devm_regulator_register(dev, &vddh_desc, &config);
|
||||
if (IS_ERR(priv->vddh_rdev)) {
|
||||
phydev_err(phydev, "failed to register VDDH regulator\n");
|
||||
return PTR_ERR(priv->vddh_rdev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int at8031_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)
|
||||
{
|
||||
struct phy_device *phydev = upstream;
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(phy_support);
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support);
|
||||
DECLARE_PHY_INTERFACE_MASK(interfaces);
|
||||
phy_interface_t iface;
|
||||
|
||||
linkmode_zero(phy_support);
|
||||
phylink_set(phy_support, 1000baseX_Full);
|
||||
phylink_set(phy_support, 1000baseT_Full);
|
||||
phylink_set(phy_support, Autoneg);
|
||||
phylink_set(phy_support, Pause);
|
||||
phylink_set(phy_support, Asym_Pause);
|
||||
|
||||
linkmode_zero(sfp_support);
|
||||
sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces);
|
||||
/* Some modules support 10G modes as well as others we support.
|
||||
* Mask out non-supported modes so the correct interface is picked.
|
||||
*/
|
||||
linkmode_and(sfp_support, phy_support, sfp_support);
|
||||
|
||||
if (linkmode_empty(sfp_support)) {
|
||||
dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
iface = sfp_select_interface(phydev->sfp_bus, sfp_support);
|
||||
|
||||
/* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes
|
||||
* interface for use with SFP modules.
|
||||
* However, some copper modules detected as having a preferred SGMII
|
||||
* interface do default to and function in 1000Base-X mode, so just
|
||||
* print a warning and allow such modules, as they may have some chance
|
||||
* of working.
|
||||
*/
|
||||
if (iface == PHY_INTERFACE_MODE_SGMII)
|
||||
dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n");
|
||||
else if (iface != PHY_INTERFACE_MODE_1000BASEX)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct sfp_upstream_ops at8031_sfp_ops = {
|
||||
.attach = phy_sfp_attach,
|
||||
.detach = phy_sfp_detach,
|
||||
.module_insert = at8031_sfp_insert,
|
||||
};
|
||||
|
||||
static int at803x_parse_dt(struct phy_device *phydev)
|
||||
{
|
||||
struct device_node *node = phydev->mdio.dev.of_node;
|
||||
@ -1498,6 +1365,139 @@ static int at803x_cable_test_start(struct phy_device *phydev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int at8031_rgmii_reg_set_voltage_sel(struct regulator_dev *rdev,
|
||||
unsigned int selector)
|
||||
{
|
||||
struct phy_device *phydev = rdev_get_drvdata(rdev);
|
||||
|
||||
if (selector)
|
||||
return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F,
|
||||
0, AT803X_DEBUG_RGMII_1V8);
|
||||
else
|
||||
return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F,
|
||||
AT803X_DEBUG_RGMII_1V8, 0);
|
||||
}
|
||||
|
||||
static int at8031_rgmii_reg_get_voltage_sel(struct regulator_dev *rdev)
|
||||
{
|
||||
struct phy_device *phydev = rdev_get_drvdata(rdev);
|
||||
int val;
|
||||
|
||||
val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F);
|
||||
if (val < 0)
|
||||
return val;
|
||||
|
||||
return (val & AT803X_DEBUG_RGMII_1V8) ? 1 : 0;
|
||||
}
|
||||
|
||||
static const struct regulator_ops vddio_regulator_ops = {
|
||||
.list_voltage = regulator_list_voltage_table,
|
||||
.set_voltage_sel = at8031_rgmii_reg_set_voltage_sel,
|
||||
.get_voltage_sel = at8031_rgmii_reg_get_voltage_sel,
|
||||
};
|
||||
|
||||
static const unsigned int vddio_voltage_table[] = {
|
||||
1500000,
|
||||
1800000,
|
||||
};
|
||||
|
||||
static const struct regulator_desc vddio_desc = {
|
||||
.name = "vddio",
|
||||
.of_match = of_match_ptr("vddio-regulator"),
|
||||
.n_voltages = ARRAY_SIZE(vddio_voltage_table),
|
||||
.volt_table = vddio_voltage_table,
|
||||
.ops = &vddio_regulator_ops,
|
||||
.type = REGULATOR_VOLTAGE,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static const struct regulator_ops vddh_regulator_ops = {
|
||||
};
|
||||
|
||||
static const struct regulator_desc vddh_desc = {
|
||||
.name = "vddh",
|
||||
.of_match = of_match_ptr("vddh-regulator"),
|
||||
.n_voltages = 1,
|
||||
.fixed_uV = 2500000,
|
||||
.ops = &vddh_regulator_ops,
|
||||
.type = REGULATOR_VOLTAGE,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int at8031_register_regulators(struct phy_device *phydev)
|
||||
{
|
||||
struct at803x_priv *priv = phydev->priv;
|
||||
struct device *dev = &phydev->mdio.dev;
|
||||
struct regulator_config config = { };
|
||||
|
||||
config.dev = dev;
|
||||
config.driver_data = phydev;
|
||||
|
||||
priv->vddio_rdev = devm_regulator_register(dev, &vddio_desc, &config);
|
||||
if (IS_ERR(priv->vddio_rdev)) {
|
||||
phydev_err(phydev, "failed to register VDDIO regulator\n");
|
||||
return PTR_ERR(priv->vddio_rdev);
|
||||
}
|
||||
|
||||
priv->vddh_rdev = devm_regulator_register(dev, &vddh_desc, &config);
|
||||
if (IS_ERR(priv->vddh_rdev)) {
|
||||
phydev_err(phydev, "failed to register VDDH regulator\n");
|
||||
return PTR_ERR(priv->vddh_rdev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int at8031_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)
|
||||
{
|
||||
struct phy_device *phydev = upstream;
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(phy_support);
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support);
|
||||
DECLARE_PHY_INTERFACE_MASK(interfaces);
|
||||
phy_interface_t iface;
|
||||
|
||||
linkmode_zero(phy_support);
|
||||
phylink_set(phy_support, 1000baseX_Full);
|
||||
phylink_set(phy_support, 1000baseT_Full);
|
||||
phylink_set(phy_support, Autoneg);
|
||||
phylink_set(phy_support, Pause);
|
||||
phylink_set(phy_support, Asym_Pause);
|
||||
|
||||
linkmode_zero(sfp_support);
|
||||
sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces);
|
||||
/* Some modules support 10G modes as well as others we support.
|
||||
* Mask out non-supported modes so the correct interface is picked.
|
||||
*/
|
||||
linkmode_and(sfp_support, phy_support, sfp_support);
|
||||
|
||||
if (linkmode_empty(sfp_support)) {
|
||||
dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
iface = sfp_select_interface(phydev->sfp_bus, sfp_support);
|
||||
|
||||
/* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes
|
||||
* interface for use with SFP modules.
|
||||
* However, some copper modules detected as having a preferred SGMII
|
||||
* interface do default to and function in 1000Base-X mode, so just
|
||||
* print a warning and allow such modules, as they may have some chance
|
||||
* of working.
|
||||
*/
|
||||
if (iface == PHY_INTERFACE_MODE_SGMII)
|
||||
dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n");
|
||||
else if (iface != PHY_INTERFACE_MODE_1000BASEX)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct sfp_upstream_ops at8031_sfp_ops = {
|
||||
.attach = phy_sfp_attach,
|
||||
.detach = phy_sfp_detach,
|
||||
.module_insert = at8031_sfp_insert,
|
||||
};
|
||||
|
||||
static int at8031_parse_dt(struct phy_device *phydev)
|
||||
{
|
||||
struct device_node *node = phydev->mdio.dev.of_node;
|
||||
|
Loading…
x
Reference in New Issue
Block a user