usb: musb: Support setting OTG mode using generic PHY
authorPaul Cercueil <paul@crapouillou.net>
Wed, 26 Oct 2022 18:26:54 +0000 (19:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Nov 2022 11:39:13 +0000 (12:39 +0100)
When musb->xceiv is not provided but musb->phy is, support setting the
OTG mode (host, peripheral) using the generic PHY framework.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20221026182657.146630-5-paul@crapouillou.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/musb/musb_gadget.c
drivers/usb/musb/musb_host.c

index 66c8b32b16bb49ba89ac041fd66b2f8bb38b6848..6cb9514ef340590590717b34aef3f7a09c3fab65 100644 (file)
@@ -1854,6 +1854,8 @@ static int musb_gadget_start(struct usb_gadget *g,
 
        if (musb->xceiv)
                otg_set_peripheral(musb->xceiv->otg, &musb->g);
+       else
+               phy_set_mode(musb->phy, PHY_MODE_USB_DEVICE);
 
        musb_set_state(musb, OTG_STATE_B_IDLE);
        spin_unlock_irqrestore(&musb->lock, flags);
@@ -1905,6 +1907,8 @@ static int musb_gadget_stop(struct usb_gadget *g)
 
        if (musb->xceiv)
                otg_set_peripheral(musb->xceiv->otg, NULL);
+       else
+               phy_set_mode(musb->phy, PHY_MODE_INVALID);
 
        musb->is_active = 0;
        musb->gadget_driver = NULL;
index 8ad39ecd3b6fcebf2dd6fe13662cad6909ac0549..a02c29216955a551cb5772dc70913f97e13eddb3 100644 (file)
@@ -2726,6 +2726,8 @@ int musb_host_setup(struct musb *musb, int power_budget)
        if (musb->xceiv) {
                otg_set_host(musb->xceiv->otg, &hcd->self);
                musb->xceiv->otg->host = &hcd->self;
+       } else {
+               phy_set_mode(musb->phy, PHY_MODE_USB_HOST);
        }
 
        /* don't support otg protocols */