Skip to content

Commit

Permalink
net: renesas: rswitch: Add "max-speed" handling
Browse files Browse the repository at this point in the history
The previous code set the speed by the interface mode of PHY.
Also this hardware has a restriction which cannot change the speed
at runtime. To use other speed, add "max-speed" handling to set
each port's speed if needed.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yoshihiro Shimoda authored and David S. Miller committed Feb 3, 2023
1 parent 5cb6309 commit 04c77d9
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/net/ethernet/renesas/rswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,13 +1072,23 @@ static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev)

static int rswitch_etha_get_params(struct rswitch_device *rdev)
{
u32 max_speed;
int err;

if (!rdev->np_port)
return 0; /* ignored */

err = of_get_phy_mode(rdev->np_port, &rdev->etha->phy_interface);
if (err)
return err;

err = of_property_read_u32(rdev->np_port, "max-speed", &max_speed);
if (!err) {
rdev->etha->speed = max_speed;
return 0;
}

/* if no "max-speed" property, let's use default speed */
switch (rdev->etha->phy_interface) {
case PHY_INTERFACE_MODE_MII:
rdev->etha->speed = SPEED_100;
Expand All @@ -1090,11 +1100,10 @@ static int rswitch_etha_get_params(struct rswitch_device *rdev)
rdev->etha->speed = SPEED_2500;
break;
default:
err = -EINVAL;
break;
return -EINVAL;
}

return err;
return 0;
}

static int rswitch_mii_register(struct rswitch_device *rdev)
Expand Down

0 comments on commit 04c77d9

Please sign in to comment.