diff --git a/include/generic-phy.h b/include/generic-phy.h index eaab749166..d4dac4975c 100644 --- a/include/generic-phy.h +++ b/include/generic-phy.h @@ -185,6 +185,10 @@ struct phy_ops { * Return: 0 if OK, or a negative error code */ int (*set_speed)(struct phy *phy, int speed); + + unsigned long (*set_pll)(struct phy *phy, unsigned long rate); + int (*set_bus_width)(struct phy *phy, u32 bus_width); + long (*round_rate)(struct phy *phy, unsigned long rate); }; /** @@ -429,6 +433,12 @@ int generic_setup_phy(struct udevice *dev, struct phy *phy, int index); */ int generic_shutdown_phy(struct phy *phy); +unsigned long generic_phy_set_pll(struct phy *phy, unsigned long rate); + +int generic_phy_set_bus_width(struct phy *phy, u32 bus_width); + +long generic_phy_round_rate(struct phy *phy, unsigned long rate); + #else /* CONFIG_PHY */ static inline int generic_phy_init(struct phy *phy) diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 0dcfe258bc..e824ff7b9e 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -225,6 +225,54 @@ int generic_phy_get_by_name(struct udevice *dev, const char *phy_name, return generic_phy_get_by_index(dev, index, phy); } +unsigned long generic_phy_set_pll(struct phy *phy, unsigned long rate) +{ + struct phy_ops const *ops; + int ret; + + if (!generic_phy_valid(phy)) + return 0; + ops = phy_dev_ops(phy->dev); + if (!ops->set_pll) + return 0; + ret = ops->set_pll(phy, rate); + if (ret) + dev_err(phy->dev, "PHY: Failed to set_pll %s: %d.\n", + phy->dev->name, ret); + + return ret; +} + +int generic_phy_set_bus_width(struct phy *phy, u32 bus_width) +{ + struct phy_ops const *ops; + int ret; + + if (!generic_phy_valid(phy)) + return 0; + ops = phy_dev_ops(phy->dev); + if (!ops->set_bus_width) + return 0; + ret = ops->set_bus_width(phy, bus_width); + if (ret) + dev_err(phy->dev, "PHY: Failed to set_bus_width %s: %d.\n", + phy->dev->name, ret); + + return ret; +} + +long generic_phy_round_rate(struct phy *phy, unsigned long rate) +{ + struct phy_ops const *ops; + + if (!generic_phy_valid(phy)) + return 0; + ops = phy_dev_ops(phy->dev); + if (!ops->round_rate) + return 0; + return ops->round_rate(phy, rate); +} + int generic_phy_init(struct phy *phy) { struct phy_counts *counts;