From patchwork Wed Oct 26 18:26:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 13020948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4762BC38A2D for ; Wed, 26 Oct 2022 18:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234155AbiJZS1w (ORCPT ); Wed, 26 Oct 2022 14:27:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234230AbiJZS1o (ORCPT ); Wed, 26 Oct 2022 14:27:44 -0400 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ABF382D34; Wed, 26 Oct 2022 11:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1666808827; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QOVVrSW/npzEAOc9hlI/DwXmmJ9MpDgUUfZkFKj4+dA=; b=lpkky17SVhLZCcTnEHZTdCGuwaziUESpWLf5k7/4e2CoVvZ0aCBSad4ivJ3hUATEKKJNyW By4+DsKFVvl9iZb9AH+gB0l6QRTIALtYy5Lrb4yg71TUnJzQL6B6tpKw/9No910txXXmoH ibtFJO2d3KQjljyzIu7S0Y/nXUmUQtk= From: Paul Cercueil To: Bin Liu , Greg Kroah-Hartman , Felipe Balbi Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-mips@vger.kernel.org, od@opendingux.net, Paul Cercueil Subject: [PATCH v2 4/7] usb: musb: Support setting OTG mode using generic PHY Date: Wed, 26 Oct 2022 19:26:54 +0100 Message-Id: <20221026182657.146630-5-paul@crapouillou.net> In-Reply-To: <20221026182657.146630-1-paul@crapouillou.net> References: <20221026182657.146630-1-paul@crapouillou.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org 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 --- drivers/usb/musb/musb_gadget.c | 4 ++++ drivers/usb/musb/musb_host.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 66c8b32b16bb..6cb9514ef340 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -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; diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 8ad39ecd3b6f..a02c29216955 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -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 */