From b0177a24d48e4ce13bfd7fce0d9c17dc0996f9a5 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 19 Mar 2023 18:09:42 +0100 Subject: phy: Add .set_mode and .set_speed callbacks Add two new callbacks matching the Linux ones. The .set_mode is used to set PHY mode and submode, where mode is either USB, Ethernet, and so on, while submode is e.g. for Ethernet case RGMII, RMII, and so on. The .set_speed is used to configure link speed into the PHY. Unlike the existing configure callback, which is used to pass arbitrary custom information to the PHY, these two callbacks are used to pass standardized set of information to the PHY. Signed-off-by: Marek Vasut Reviewed-by: Patrice Chotard --- drivers/phy/phy-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'drivers/phy') diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 3fef5135a9..83e4b63079 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -351,6 +351,28 @@ int generic_phy_configure(struct phy *phy, void *params) return ops->configure ? ops->configure(phy, params) : 0; } +int generic_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode) +{ + struct phy_ops const *ops; + + if (!generic_phy_valid(phy)) + return 0; + ops = phy_dev_ops(phy->dev); + + return ops->set_mode ? ops->set_mode(phy, mode, submode) : 0; +} + +int generic_phy_set_speed(struct phy *phy, int speed) +{ + struct phy_ops const *ops; + + if (!generic_phy_valid(phy)) + return 0; + ops = phy_dev_ops(phy->dev); + + return ops->set_speed ? ops->set_speed(phy, speed) : 0; +} + int generic_phy_get_bulk(struct udevice *dev, struct phy_bulk *bulk) { int i, ret, count; -- cgit v1.2.3