Add PHY_CADENCE_TORRENT_AUTO_PROBE configuration option to support
auto-probe of the Cadence Torrent PHY driver after binding. When enabled,
it sets DM_FLAG_PROBE_AFTER_BIND to ensure the Torrent PHY is probed
immediately after binding for the boards that require U-Boot to configure
the PHY unconditionally.

Signed-off-by: Aksh Garg <[email protected]>
---
 drivers/phy/cadence/Kconfig               |  7 +++++++
 drivers/phy/cadence/phy-cadence-torrent.c | 14 ++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/drivers/phy/cadence/Kconfig b/drivers/phy/cadence/Kconfig
index 8c0ab80fbbc7..c7d418432558 100644
--- a/drivers/phy/cadence/Kconfig
+++ b/drivers/phy/cadence/Kconfig
@@ -10,6 +10,13 @@ config PHY_CADENCE_TORRENT
        help
          Enable this to support the Cadence Torrent PHY driver
 
+config PHY_CADENCE_TORRENT_AUTO_PROBE
+       bool "Auto-probe Cadence Torrent PHY Driver after Binding"
+       depends on PHY_CADENCE_TORRENT
+       help
+         Enable this to auto-probe the Cadence Torrent PHY driver
+         after binding.
+
 config SPL_PHY_CADENCE_TORRENT
        bool "Cadence Torrent PHY Driver"
        depends on SPL_DM_RESET
diff --git a/drivers/phy/cadence/phy-cadence-torrent.c 
b/drivers/phy/cadence/phy-cadence-torrent.c
index 1f566d082f99..8228dad499ec 100644
--- a/drivers/phy/cadence/phy-cadence-torrent.c
+++ b/drivers/phy/cadence/phy-cadence-torrent.c
@@ -592,6 +592,19 @@ static int cdns_torrent_phy_configure_multilink(struct 
cdns_torrent_phy *cdns_ph
        return 0;
 }
 
+static int cdns_torrent_phy_bind(struct udevice *dev)
+{
+       /*
+        * Make sure that the Cadence Torrent PHY driver gets probed
+        * after binding, for the boards that require U-Boot to
+        * configure the PHY unconditionally.
+        */
+       if (IS_ENABLED(CONFIG_PHY_CADENCE_TORRENT_AUTO_PROBE))
+               dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+
+       return 0;
+}
+
 static int cdns_torrent_phy_probe(struct udevice *dev)
 {
        struct cdns_torrent_phy *cdns_phy = dev_get_priv(dev);
@@ -2491,6 +2504,7 @@ U_BOOT_DRIVER(torrent_phy_provider) = {
        .id             = UCLASS_PHY,
        .of_match       = cdns_torrent_id_table,
        .probe          = cdns_torrent_phy_probe,
+       .bind           = cdns_torrent_phy_bind,
        .remove         = cdns_torrent_phy_remove,
        .ops            = &cdns_torrent_phy_ops,
        .priv_auto      = sizeof(struct cdns_torrent_phy),
-- 
2.34.1

Reply via email to