aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>2022-08-09 13:53:30 +0200
committerTom Rini <trini@konsulko.com>2023-01-26 14:26:17 -0500
commit4f4d3b51f5c1f7551b2c7086bb2c529b218e7b5b (patch)
tree5a3981fccf6e8780e4ec6c64f6d558b4ee57ab07
parentd4c80fc2ed5e9e9037566e17a30139bd5e15cfdf (diff)
downloadu-boot-WIP/2023-01-26-assorted-updates.zip
u-boot-WIP/2023-01-26-assorted-updates.tar.gz
u-boot-WIP/2023-01-26-assorted-updates.tar.bz2
phy: add of_set_phy_supported() helper, call from phy_config()WIP/2023-01-26-assorted-updates
Currently, U-Boot doesn't parse a "max-speed" DT property in a phy's DT node. That property is a standard binding which should be honoured, and in linux that is done by the core phy code via a call to an of_set_phy_supported() helper. (Some ethernet drivers support a max-speed property in their DT node, but that's orthogonal to what the phy supports.) Add a similar helper in U-Boot, and call it from phy_config(). Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
-rw-r--r--drivers/net/phy/phy.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 80230b9..c793694 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -602,6 +602,20 @@ int phy_register(struct phy_driver *drv)
return 0;
}
+static int of_set_phy_supported(struct phy_device *phydev)
+{
+ ofnode node = phy_get_ofnode(phydev);
+ u32 max_speed;
+
+ if (!ofnode_valid(node))
+ return 0;
+
+ if (!ofnode_read_u32(node, "max-speed", &max_speed))
+ return phy_set_supported(phydev, max_speed);
+
+ return 0;
+}
+
int phy_set_supported(struct phy_device *phydev, u32 max_speed)
{
/* The default values for phydev->supported are provided by the PHY
@@ -1060,6 +1074,12 @@ __weak int board_phy_config(struct phy_device *phydev)
int phy_config(struct phy_device *phydev)
{
+ int ret;
+
+ ret = of_set_phy_supported(phydev);
+ if (ret)
+ return ret;
+
/* Invoke an optional board-specific helper */
return board_phy_config(phydev);
}