Skip to content

Commit 05bda8a

Browse files
Danielmachonkuba-moo
authored andcommitted
net: sparx5: use is_port_rgmii() throughout
Now that we can check if a given port is an RGMII port, use it in the following cases: - To set RGMII PHY modes for RGMII port devices. - To avoid checking for a SerDes node in the devicetree, when the port is an RGMII port. - To bail out of sparx5_port_init() when the common configuration is done. Reviewed-by: Steen Hegelund <[email protected]> Reviewed-by: Horatiu Vultur <[email protected]> Tested-by: Robert Marko <[email protected]> Signed-off-by: Daniel Machon <[email protected]> Link: https://patch.msgid.link/20241220-sparx5-lan969x-switch-driver-4-v5-3-fa8ba5dff732@microchip.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent dd2baee commit 05bda8a

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

drivers/net/ethernet/microchip/sparx5/sparx5_main.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,13 @@ static int sparx5_create_port(struct sparx5 *sparx5,
313313
struct initial_port_config *config)
314314
{
315315
struct sparx5_port *spx5_port;
316+
const struct sparx5_ops *ops;
316317
struct net_device *ndev;
317318
struct phylink *phylink;
318319
int err;
319320

321+
ops = sparx5->data->ops;
322+
320323
ndev = sparx5_create_netdev(sparx5, config->portno);
321324
if (IS_ERR(ndev)) {
322325
dev_err(sparx5->dev, "Could not create net device: %02u\n",
@@ -357,6 +360,9 @@ static int sparx5_create_port(struct sparx5 *sparx5,
357360
MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD |
358361
MAC_2500FD | MAC_5000FD | MAC_10000FD | MAC_25000FD;
359362

363+
if (ops->is_port_rgmii(spx5_port->portno))
364+
phy_interface_set_rgmii(spx5_port->phylink_config.supported_interfaces);
365+
360366
__set_bit(PHY_INTERFACE_MODE_SGMII,
361367
spx5_port->phylink_config.supported_interfaces);
362368
__set_bit(PHY_INTERFACE_MODE_QSGMII,
@@ -830,6 +836,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
830836
struct initial_port_config *configs, *config;
831837
struct device_node *np = pdev->dev.of_node;
832838
struct device_node *ports, *portnp;
839+
const struct sparx5_ops *ops;
833840
struct reset_control *reset;
834841
struct sparx5 *sparx5;
835842
int idx = 0, err = 0;
@@ -851,6 +858,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
851858
return -EINVAL;
852859

853860
regs = sparx5->data->regs;
861+
ops = sparx5->data->ops;
854862

855863
/* Do switch core reset if available */
856864
reset = devm_reset_control_get_optional_shared(&pdev->dev, "switch");
@@ -880,7 +888,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
880888

881889
for_each_available_child_of_node(ports, portnp) {
882890
struct sparx5_port_config *conf;
883-
struct phy *serdes;
891+
struct phy *serdes = NULL;
884892
u32 portno;
885893

886894
err = of_property_read_u32(portnp, "reg", &portno);
@@ -910,13 +918,17 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
910918
conf->sd_sgpio = ~0;
911919
else
912920
sparx5->sd_sgpio_remapping = true;
913-
serdes = devm_of_phy_get(sparx5->dev, portnp, NULL);
914-
if (IS_ERR(serdes)) {
915-
err = dev_err_probe(sparx5->dev, PTR_ERR(serdes),
916-
"port %u: missing serdes\n",
917-
portno);
918-
of_node_put(portnp);
919-
goto cleanup_config;
921+
/* There is no SerDes node for RGMII ports. */
922+
if (!ops->is_port_rgmii(portno)) {
923+
serdes = devm_of_phy_get(sparx5->dev, portnp, NULL);
924+
if (IS_ERR(serdes)) {
925+
err = dev_err_probe(sparx5->dev,
926+
PTR_ERR(serdes),
927+
"port %u: missing serdes\n",
928+
portno);
929+
of_node_put(portnp);
930+
goto cleanup_config;
931+
}
920932
}
921933
config->portno = portno;
922934
config->node = portnp;

drivers/net/ethernet/microchip/sparx5/sparx5_port.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,9 @@ int sparx5_port_init(struct sparx5 *sparx5,
10901090
ANA_CL_FILTER_CTRL_FILTER_SMAC_MC_DIS,
10911091
sparx5, ANA_CL_FILTER_CTRL(port->portno));
10921092

1093+
if (ops->is_port_rgmii(port->portno))
1094+
return 0; /* RGMII device - nothing more to configure */
1095+
10931096
/* Configure MAC vlan awareness */
10941097
err = sparx5_port_max_tags_set(sparx5, port);
10951098
if (err)

0 commit comments

Comments
 (0)