]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
phy: Extend generic_setup_phy() with PHY mode and submode
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Sun, 8 Sep 2024 21:09:03 +0000 (23:09 +0200)
committerMarek Vasut <marex@denx.de>
Mon, 9 Sep 2024 15:18:04 +0000 (17:18 +0200)
Extend generic_setup_phy() parameter list with PHY mode and submode and
call generic_phy_set_mode() in generic_setup_phy(), so the generic PHY
setup function can configure the PHY into correct mode before powering
the PHY up.

Update all call sites of generic_setup_phy() as well, all of which are
USB host related, except for DM test which now behaves as a USB host
test.

Note that if the PHY driver does not implement the .set_mode callback,
generic_phy_set_mode() call returns 0 and does not error out, so this
should not break any existing systems.

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
drivers/phy/phy-uclass.c
drivers/usb/host/ehci-generic.c
drivers/usb/host/ehci-msm.c
drivers/usb/host/ehci-mx6.c
drivers/usb/host/ehci-pci.c
drivers/usb/host/ohci-generic.c
include/generic-phy.h
test/dm/phy.c

index acdcda15b5b85b94bb13e52ccedcfb04f4699704..777d952b041a41c68ae87898d6297c1b6fd15579 100644 (file)
@@ -508,7 +508,8 @@ int generic_phy_power_off_bulk(struct phy_bulk *bulk)
        return ret;
 }
 
-int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)
+int generic_setup_phy(struct udevice *dev, struct phy *phy, int index,
+                     enum phy_mode mode, int submode)
 {
        int ret;
 
@@ -520,10 +521,18 @@ int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)
        if (ret)
                return ret;
 
+       ret = generic_phy_set_mode(phy, mode, submode);
+       if (ret)
+               goto phys_mode_err;
+
        ret = generic_phy_power_on(phy);
        if (ret)
-               generic_phy_exit(phy);
+               goto phys_mode_err;
+
+       return 0;
 
+phys_mode_err:
+       generic_phy_exit(phy);
        return ret;
 }
 
index 23c3ed25554f9acfeac840a132d99b92e3b8fafa..1ae3619ce25db210e0c44b435558fabbf5d920be 100644 (file)
@@ -94,7 +94,7 @@ static int ehci_usb_probe(struct udevice *dev)
        if (err)
                goto reset_err;
 
-       err = generic_setup_phy(dev, &priv->phy, 0);
+       err = generic_setup_phy(dev, &priv->phy, 0, PHY_MODE_USB_HOST, 0);
        if (err)
                goto regulator_err;
 
index ff336082e3ab84a50584be79eca22a2c2dc89f78..a759aea9db38dd5af2bb85b677ac403018983cfb 100644 (file)
@@ -80,7 +80,7 @@ static int ehci_usb_probe(struct udevice *dev)
        hcor = (struct ehci_hcor *)((phys_addr_t)hccr +
                        HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
 
-       ret = generic_setup_phy(dev, &p->phy, 0);
+       ret = generic_setup_phy(dev, &p->phy, 0, PHY_MODE_USB_HOST, 0);
        if (ret)
                goto cleanup_iface;
 
index 31cd8a50f4a2258ce478db93848cbef2529564c3..a93fa5d5455d340a47ab7f69945b55f147c59401 100644 (file)
@@ -703,7 +703,7 @@ static int ehci_usb_probe(struct udevice *dev)
        usb_phy_enable(ehci, priv->phy_addr);
 #endif
 #else
-       ret = generic_setup_phy(dev, &priv->phy, 0);
+       ret = generic_setup_phy(dev, &priv->phy, 0, PHY_MODE_USB_HOST, 0);
        if (ret)
                goto err_regulator;
 #endif
index 572686580cd56d7cca87a8c89aa259f65a3c4bcd..8d05b14e898e5fb15ba2e8dde83568741617d0a7 100644 (file)
@@ -30,7 +30,7 @@ static int ehci_pci_init(struct udevice *dev, struct ehci_hccr **ret_hccr,
        int ret;
        u32 cmd;
 
-       ret = generic_setup_phy(dev, &priv->phy, 0);
+       ret = generic_setup_phy(dev, &priv->phy, 0, PHY_MODE_USB_HOST, 0);
        if (ret)
                return ret;
 
index f1325cd4953430ba98a2709461627c78f693667b..cc44226f5e0b96d86902f3421a9a803a19df1fbf 100644 (file)
@@ -50,7 +50,7 @@ static int ohci_usb_probe(struct udevice *dev)
                goto reset_err;
        }
 
-       err = generic_setup_phy(dev, &priv->phy, 0);
+       err = generic_setup_phy(dev, &priv->phy, 0, PHY_MODE_USB_HOST, 0);
        if (err)
                goto reset_err;
 
index eaab7491660d902954089f36e48c19ded90b9bc1..ba3321f484948852b03d96751565910eb75b5998 100644 (file)
@@ -415,10 +415,13 @@ int generic_phy_power_off_bulk(struct phy_bulk *bulk);
  * @dev:       The consumer device.
  * @phy:       A pointer to the PHY port
  * @index:     The index in the list of available PHYs
+ * @mode:      PHY mode
+ * @submode:   PHY submode
  *
  * Return: 0 if OK, or negative error code.
  */
-int generic_setup_phy(struct udevice *dev, struct phy *phy, int index);
+int generic_setup_phy(struct udevice *dev, struct phy *phy, int index,
+                     enum phy_mode mode, int submode);
 
 /**
  * generic_shutdown_phy() - Power off and de-initialize phy.
@@ -509,7 +512,8 @@ static inline int generic_phy_power_off_bulk(struct phy_bulk *bulk)
        return 0;
 }
 
-static inline int generic_setup_phy(struct udevice *dev, struct phy *phy, int index)
+static inline int generic_setup_phy(struct udevice *dev, struct phy *phy, int index,
+                                   enum phy_mode mode, int submode)
 {
        return 0;
 }
index 9b4cff60e6a6d45dc90dc31607636b4792aad936..8808ca3689c94898a96a948d4dc4c827d01cf952 100644 (file)
@@ -243,20 +243,20 @@ static int dm_test_phy_setup(struct unit_test_state *uts)
                                              "gen_phy_user", &parent));
 
        /* normal */
-       ut_assertok(generic_setup_phy(parent, &phy, 0));
+       ut_assertok(generic_setup_phy(parent, &phy, 0, PHY_MODE_USB_HOST, 0));
        ut_assertok(generic_shutdown_phy(&phy));
 
        /* power_off fail with -EIO */
-       ut_assertok(generic_setup_phy(parent, &phy, 1));
+       ut_assertok(generic_setup_phy(parent, &phy, 1, PHY_MODE_USB_HOST, 0));
        ut_asserteq(-EIO, generic_shutdown_phy(&phy));
 
        /* power_on fail with -EIO */
-       ut_asserteq(-EIO, generic_setup_phy(parent, &phy, 2));
+       ut_asserteq(-EIO, generic_setup_phy(parent, &phy, 2, PHY_MODE_USB_HOST, 0));
        ut_assertok(generic_shutdown_phy(&phy));
 
        /* generic_phy_get_by_index fail with -ENOENT */
        ut_asserteq(-ENOENT, generic_phy_get_by_index(parent, 3, &phy));
-       ut_assertok(generic_setup_phy(parent, &phy, 3));
+       ut_assertok(generic_setup_phy(parent, &phy, 3, PHY_MODE_USB_HOST, 0));
        ut_assertok(generic_shutdown_phy(&phy));
 
        return 0;