1 From f932a6dc8bae0dae9645b5b1b4c65aed8a8acb2a Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 8 Dec 2023 15:51:58 +0100
4 Subject: [PATCH 11/13] net: phy: at803x: move at8031 functions in dedicated
7 Move at8031 functions in dedicated section with dedicated at8031
10 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
13 drivers/net/phy/at803x.c | 266 +++++++++++++++++++--------------------
14 1 file changed, 133 insertions(+), 133 deletions(-)
16 --- a/drivers/net/phy/at803x.c
17 +++ b/drivers/net/phy/at803x.c
18 @@ -583,139 +583,6 @@ static int at803x_resume(struct phy_devi
19 return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0);
22 -static int at8031_rgmii_reg_set_voltage_sel(struct regulator_dev *rdev,
23 - unsigned int selector)
25 - struct phy_device *phydev = rdev_get_drvdata(rdev);
28 - return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F,
29 - 0, AT803X_DEBUG_RGMII_1V8);
31 - return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F,
32 - AT803X_DEBUG_RGMII_1V8, 0);
35 -static int at8031_rgmii_reg_get_voltage_sel(struct regulator_dev *rdev)
37 - struct phy_device *phydev = rdev_get_drvdata(rdev);
40 - val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F);
44 - return (val & AT803X_DEBUG_RGMII_1V8) ? 1 : 0;
47 -static const struct regulator_ops vddio_regulator_ops = {
48 - .list_voltage = regulator_list_voltage_table,
49 - .set_voltage_sel = at8031_rgmii_reg_set_voltage_sel,
50 - .get_voltage_sel = at8031_rgmii_reg_get_voltage_sel,
53 -static const unsigned int vddio_voltage_table[] = {
58 -static const struct regulator_desc vddio_desc = {
60 - .of_match = of_match_ptr("vddio-regulator"),
61 - .n_voltages = ARRAY_SIZE(vddio_voltage_table),
62 - .volt_table = vddio_voltage_table,
63 - .ops = &vddio_regulator_ops,
64 - .type = REGULATOR_VOLTAGE,
65 - .owner = THIS_MODULE,
68 -static const struct regulator_ops vddh_regulator_ops = {
71 -static const struct regulator_desc vddh_desc = {
73 - .of_match = of_match_ptr("vddh-regulator"),
75 - .fixed_uV = 2500000,
76 - .ops = &vddh_regulator_ops,
77 - .type = REGULATOR_VOLTAGE,
78 - .owner = THIS_MODULE,
81 -static int at8031_register_regulators(struct phy_device *phydev)
83 - struct at803x_priv *priv = phydev->priv;
84 - struct device *dev = &phydev->mdio.dev;
85 - struct regulator_config config = { };
88 - config.driver_data = phydev;
90 - priv->vddio_rdev = devm_regulator_register(dev, &vddio_desc, &config);
91 - if (IS_ERR(priv->vddio_rdev)) {
92 - phydev_err(phydev, "failed to register VDDIO regulator\n");
93 - return PTR_ERR(priv->vddio_rdev);
96 - priv->vddh_rdev = devm_regulator_register(dev, &vddh_desc, &config);
97 - if (IS_ERR(priv->vddh_rdev)) {
98 - phydev_err(phydev, "failed to register VDDH regulator\n");
99 - return PTR_ERR(priv->vddh_rdev);
105 -static int at8031_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)
107 - struct phy_device *phydev = upstream;
108 - __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_support);
109 - __ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support);
110 - DECLARE_PHY_INTERFACE_MASK(interfaces);
111 - phy_interface_t iface;
113 - linkmode_zero(phy_support);
114 - phylink_set(phy_support, 1000baseX_Full);
115 - phylink_set(phy_support, 1000baseT_Full);
116 - phylink_set(phy_support, Autoneg);
117 - phylink_set(phy_support, Pause);
118 - phylink_set(phy_support, Asym_Pause);
120 - linkmode_zero(sfp_support);
121 - sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces);
122 - /* Some modules support 10G modes as well as others we support.
123 - * Mask out non-supported modes so the correct interface is picked.
125 - linkmode_and(sfp_support, phy_support, sfp_support);
127 - if (linkmode_empty(sfp_support)) {
128 - dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
132 - iface = sfp_select_interface(phydev->sfp_bus, sfp_support);
134 - /* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes
135 - * interface for use with SFP modules.
136 - * However, some copper modules detected as having a preferred SGMII
137 - * interface do default to and function in 1000Base-X mode, so just
138 - * print a warning and allow such modules, as they may have some chance
141 - if (iface == PHY_INTERFACE_MODE_SGMII)
142 - dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n");
143 - else if (iface != PHY_INTERFACE_MODE_1000BASEX)
149 -static const struct sfp_upstream_ops at8031_sfp_ops = {
150 - .attach = phy_sfp_attach,
151 - .detach = phy_sfp_detach,
152 - .module_insert = at8031_sfp_insert,
155 static int at803x_parse_dt(struct phy_device *phydev)
157 struct device_node *node = phydev->mdio.dev.of_node;
158 @@ -1498,6 +1365,139 @@ static int at803x_cable_test_start(struc
162 +static int at8031_rgmii_reg_set_voltage_sel(struct regulator_dev *rdev,
163 + unsigned int selector)
165 + struct phy_device *phydev = rdev_get_drvdata(rdev);
168 + return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F,
169 + 0, AT803X_DEBUG_RGMII_1V8);
171 + return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F,
172 + AT803X_DEBUG_RGMII_1V8, 0);
175 +static int at8031_rgmii_reg_get_voltage_sel(struct regulator_dev *rdev)
177 + struct phy_device *phydev = rdev_get_drvdata(rdev);
180 + val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F);
184 + return (val & AT803X_DEBUG_RGMII_1V8) ? 1 : 0;
187 +static const struct regulator_ops vddio_regulator_ops = {
188 + .list_voltage = regulator_list_voltage_table,
189 + .set_voltage_sel = at8031_rgmii_reg_set_voltage_sel,
190 + .get_voltage_sel = at8031_rgmii_reg_get_voltage_sel,
193 +static const unsigned int vddio_voltage_table[] = {
198 +static const struct regulator_desc vddio_desc = {
200 + .of_match = of_match_ptr("vddio-regulator"),
201 + .n_voltages = ARRAY_SIZE(vddio_voltage_table),
202 + .volt_table = vddio_voltage_table,
203 + .ops = &vddio_regulator_ops,
204 + .type = REGULATOR_VOLTAGE,
205 + .owner = THIS_MODULE,
208 +static const struct regulator_ops vddh_regulator_ops = {
211 +static const struct regulator_desc vddh_desc = {
213 + .of_match = of_match_ptr("vddh-regulator"),
215 + .fixed_uV = 2500000,
216 + .ops = &vddh_regulator_ops,
217 + .type = REGULATOR_VOLTAGE,
218 + .owner = THIS_MODULE,
221 +static int at8031_register_regulators(struct phy_device *phydev)
223 + struct at803x_priv *priv = phydev->priv;
224 + struct device *dev = &phydev->mdio.dev;
225 + struct regulator_config config = { };
228 + config.driver_data = phydev;
230 + priv->vddio_rdev = devm_regulator_register(dev, &vddio_desc, &config);
231 + if (IS_ERR(priv->vddio_rdev)) {
232 + phydev_err(phydev, "failed to register VDDIO regulator\n");
233 + return PTR_ERR(priv->vddio_rdev);
236 + priv->vddh_rdev = devm_regulator_register(dev, &vddh_desc, &config);
237 + if (IS_ERR(priv->vddh_rdev)) {
238 + phydev_err(phydev, "failed to register VDDH regulator\n");
239 + return PTR_ERR(priv->vddh_rdev);
245 +static int at8031_sfp_insert(void *upstream, const struct sfp_eeprom_id *id)
247 + struct phy_device *phydev = upstream;
248 + __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_support);
249 + __ETHTOOL_DECLARE_LINK_MODE_MASK(sfp_support);
250 + DECLARE_PHY_INTERFACE_MASK(interfaces);
251 + phy_interface_t iface;
253 + linkmode_zero(phy_support);
254 + phylink_set(phy_support, 1000baseX_Full);
255 + phylink_set(phy_support, 1000baseT_Full);
256 + phylink_set(phy_support, Autoneg);
257 + phylink_set(phy_support, Pause);
258 + phylink_set(phy_support, Asym_Pause);
260 + linkmode_zero(sfp_support);
261 + sfp_parse_support(phydev->sfp_bus, id, sfp_support, interfaces);
262 + /* Some modules support 10G modes as well as others we support.
263 + * Mask out non-supported modes so the correct interface is picked.
265 + linkmode_and(sfp_support, phy_support, sfp_support);
267 + if (linkmode_empty(sfp_support)) {
268 + dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n");
272 + iface = sfp_select_interface(phydev->sfp_bus, sfp_support);
274 + /* Only 1000Base-X is supported by AR8031/8033 as the downstream SerDes
275 + * interface for use with SFP modules.
276 + * However, some copper modules detected as having a preferred SGMII
277 + * interface do default to and function in 1000Base-X mode, so just
278 + * print a warning and allow such modules, as they may have some chance
281 + if (iface == PHY_INTERFACE_MODE_SGMII)
282 + dev_warn(&phydev->mdio.dev, "module may not function if 1000Base-X not supported\n");
283 + else if (iface != PHY_INTERFACE_MODE_1000BASEX)
289 +static const struct sfp_upstream_ops at8031_sfp_ops = {
290 + .attach = phy_sfp_attach,
291 + .detach = phy_sfp_detach,
292 + .module_insert = at8031_sfp_insert,
295 static int at8031_parse_dt(struct phy_device *phydev)
297 struct device_node *node = phydev->mdio.dev.of_node;